diff options
Diffstat (limited to 'Sources/LichessClient/Generated')
-rw-r--r-- | Sources/LichessClient/Generated/Client.swift | 14299 | ||||
-rw-r--r-- | Sources/LichessClient/Generated/Types.swift | 39108 |
2 files changed, 53407 insertions, 0 deletions
diff --git a/Sources/LichessClient/Generated/Client.swift b/Sources/LichessClient/Generated/Client.swift new file mode 100644 index 0000000..520c266 --- /dev/null +++ b/Sources/LichessClient/Generated/Client.swift @@ -0,0 +1,14299 @@ +// Generated by swift-openapi-generator, do not modify. +@_spi(Generated) import OpenAPIRuntime +#if os(Linux) +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date +#else +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date +#endif +import HTTPTypes +/// # Introduction +/// Welcome to the reference for the Lichess API! Lichess is free/libre, +/// open-source chess server powered by volunteers and donations. +/// - Get help in the [Lichess Discord channel](https://discord.gg/lichess) +/// - API demo app with OAuth2 login and gameplay: [source](https://github.com/lichess-org/api-demo) / [demo](https://lichess-org.github.io/api-demo/) +/// - API UI app with OAuth2 login and endpoint forms: [source](https://github.com/lichess-org/api-ui) / [website](https://lichess.org/api/ui) +/// - [Contribute to this documentation on Github](https://github.com/lichess-org/api) +/// - Check out [Lichess widgets to embed in your website](https://lichess.org/developers) +/// - [Download all Lichess rated games](https://database.lichess.org/) +/// - [Download all Lichess puzzles with themes, ratings and votes](https://database.lichess.org/#puzzles) +/// - [Download all evaluated positions](https://database.lichess.org/#evals) +/// +/// ## Endpoint +/// All requests go to `https://lichess.org` (unless otherwise specified). +/// +/// ## Clients +/// - [Python general API](https://github.com/lichess-org/berserk) +/// - [MicroPython general API](https://github.com/mkomon/uberserk) +/// - [Python general API - async](https://pypi.org/project/async-lichess-sdk) +/// - [Python Lichess Bot](https://github.com/lichess-bot-devs/lichess-bot) +/// - [Python Board API for Certabo](https://github.com/haklein/certabo-lichess) +/// - [Java general API](https://github.com/tors42/chariot) +/// - [JavaScript & TypeScript general API](https://github.com/devjiwonchoi/equine) +/// +/// ## Rate limiting +/// All requests are rate limited using various strategies, +/// to ensure the API remains responsive for everyone. +/// Only make one request at a time. +/// If you receive an HTTP response with a [429 status](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429), +/// please wait a full minute before resuming API usage. +/// +/// ## Streaming with ND-JSON +/// Some API endpoints stream their responses as [Newline Delimited JSON a.k.a. **nd-json**](https://github.com/ndjson/ndjson-spec), with one JSON object per line. +/// +/// Here's a [JavaScript utility function](https://gist.github.com/ornicar/a097406810939cf7be1df8ea30e94f3e) to help reading NDJSON streamed responses. +/// +/// ## Authentication +/// ### Which authentication method is right for me? +/// [Read about the Lichess API authentication methods and code examples](https://github.com/lichess-org/api/blob/master/example/README.md) +/// +/// ### Personal Access Token +/// Personal API access tokens allow you to quickly interact with Lichess API without going through an OAuth flow. +/// - [Generate a personal access token](https://lichess.org/account/oauth/token) +/// - `curl https://lichess.org/api/account -H "Authorization: Bearer {token}"` +/// - [NodeJS example](https://github.com/lichess-org/api/tree/master/example/oauth-personal-token) +/// +/// ### Authorization Code Flow with PKCE +/// The authorization code flow with PKCE allows your users to **login with Lichess**. +/// Lichess supports unregistered and public clients (no client authentication, choose any unique client id). +/// The only accepted code challenge method is `S256`. +/// Access tokens are long-lived (expect one year), unless they are revoked. +/// Refresh tokens are not supported. +/// +/// See the [documentation for the OAuth endpoints](#tag/OAuth) or +/// the [PKCE RFC](https://datatracker.ietf.org/doc/html/rfc7636#section-4) for a precise protocol description. +/// +/// - [Demo app](https://lichess-org.github.io/api-demo/) +/// - [Minimal client-side example](https://github.com/lichess-org/api/tree/master/example/oauth-app) +/// - [Flask/Python example](https://github.com/lakinwecker/lichess-oauth-flask) +/// - [Java example](https://github.com/tors42/lichess-oauth-pkce-app) +/// - [NodeJS Passport strategy to login with Lichess OAuth2](https://www.npmjs.com/package/passport-lichess) +/// +/// #### Real life examples +/// - [PyChess](https://github.com/gbtami/pychess-variants) ([source code](https://github.com/gbtami/pychess-variants)) +/// - [Lichess4545](https://www.lichess4545.com/) ([source code](https://github.com/cyanfish/heltour)) +/// - [English Chess Federation](https://ecf.octoknight.com/) +/// - [Rotherham Online Chess](https://rotherhamonlinechess.azurewebsites.net/tournaments) +/// +/// ### Token format +/// Access tokens and authorization codes match `^[A-Za-z0-9_]+$`. +/// The length of tokens can be increased without notice. Make sure your application can handle at least 512 characters. +/// By convention tokens have a recognizable prefix, but do not rely on this. +/// +internal struct Client: APIProtocol { + /// The underlying HTTP client. + private let client: UniversalClient + /// Creates a new client. + /// - Parameters: + /// - serverURL: The server URL that the client connects to. Any server + /// URLs defined in the OpenAPI document are available as static methods + /// on the ``Servers`` type. + /// - configuration: A set of configuration values for the client. + /// - transport: A transport that performs HTTP operations. + /// - middlewares: A list of middlewares to call before the transport. + internal init( + serverURL: Foundation.URL, + configuration: Configuration = .init(), + transport: any ClientTransport, + middlewares: [any ClientMiddleware] = [] + ) { + self.client = .init( + serverURL: serverURL, + configuration: configuration, + transport: transport, + middlewares: middlewares + ) + } + private var converter: Converter { + client.converter + } + /// Get real-time users status + /// + /// Read the `online`, `playing` and `streaming` flags of several users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// Use it to track players and know when they're connected on lichess and playing games. + /// + /// + /// - Remark: HTTP `GET /api/users/status`. + /// - Remark: Generated from `#/paths//api/users/status/get(apiUsersStatus)`. + internal func apiUsersStatus(_ input: Operations.apiUsersStatus.Input) async throws -> Operations.apiUsersStatus.Output { + try await client.send( + input: input, + forOperation: Operations.apiUsersStatus.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/users/status", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "ids", + value: input.query.ids + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "withGameIds", + value: input.query.withGameIds + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUsersStatus.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUsersStatus.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.apiUsersStatus.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get all top 10 + /// + /// Get the top 10 players for each speed and variant. + /// See <https://lichess.org/player>. + /// + /// + /// - Remark: HTTP `GET /api/player`. + /// - Remark: Generated from `#/paths//api/player/get(player)`. + internal func player(_ input: Operations.player.Input) async throws -> Operations.player.Output { + try await client.send( + input: input, + forOperation: Operations.player.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/player", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.player.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.player.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Top10s.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get one leaderboard + /// + /// Get the leaderboard for a single speed or variant (a.k.a. `perfType`). + /// There is no leaderboard for correspondence or puzzles. + /// See <https://lichess.org/player/top/200/bullet>. + /// + /// + /// - Remark: HTTP `GET /api/player/top/{nb}/{perfType}`. + /// - Remark: Generated from `#/paths//api/player/top/{nb}/{perfType}/get(playerTopNbPerfType)`. + internal func playerTopNbPerfType(_ input: Operations.playerTopNbPerfType.Input) async throws -> Operations.playerTopNbPerfType.Output { + try await client.send( + input: input, + forOperation: Operations.playerTopNbPerfType.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/player/top/{}/{}", + parameters: [ + input.path.nb, + input.path.perfType + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.playerTopNbPerfType.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.playerTopNbPerfType.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/vnd.lichess.v3+json" + ] + ) + switch chosenContentType { + case "application/vnd.lichess.v3+json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Leaderboard.self, + from: responseBody, + transforming: { value in + .application_vnd_period_lichess_period_v3_plus_json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get user public data + /// + /// Read public data of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}`. + /// - Remark: Generated from `#/paths//api/user/{username}/get(apiUser)`. + internal func apiUser(_ input: Operations.apiUser.Input) async throws -> Operations.apiUser.Output { + try await client.send( + input: input, + forOperation: Operations.apiUser.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "trophies", + value: input.query.trophies + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUser.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUser.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.UserExtended.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get rating history of a user + /// + /// Read rating history of a user, for all perf types. + /// There is at most one entry per day. + /// Format of an entry is `[year, month, day, rating]`. + /// `month` starts at zero (January). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/rating-history`. + /// - Remark: Generated from `#/paths//api/user/{username}/rating-history/get(apiUserRatingHistory)`. + internal func apiUserRatingHistory(_ input: Operations.apiUserRatingHistory.Input) async throws -> Operations.apiUserRatingHistory.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserRatingHistory.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/rating-history", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserRatingHistory.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserRatingHistory.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.RatingHistory.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get performance statistics of a user + /// + /// Read performance statistics of a user, for a single performance. + /// Similar to the [performance pages on the website](https://lichess.org/@/thibault/perf/bullet). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/perf/{perf}`. + /// - Remark: Generated from `#/paths//api/user/{username}/perf/{perf}/get(apiUserPerf)`. + internal func apiUserPerf(_ input: Operations.apiUserPerf.Input) async throws -> Operations.apiUserPerf.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserPerf.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/perf/{}", + parameters: [ + input.path.username, + input.path.perf + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserPerf.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserPerf.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.PerfStat.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get user activity + /// + /// Read data to generate the activity feed of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/activity`. + /// - Remark: Generated from `#/paths//api/user/{username}/activity/get(apiUserActivity)`. + internal func apiUserActivity(_ input: Operations.apiUserActivity.Input) async throws -> Operations.apiUserActivity.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserActivity.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/activity", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserActivity.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserActivity.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get the daily puzzle + /// + /// Get the daily Lichess puzzle in JSON format. + /// Alternatively, you can [post it in your slack workspace](https://lichess.org/daily-puzzle-slack). + /// + /// + /// - Remark: HTTP `GET /api/puzzle/daily`. + /// - Remark: Generated from `#/paths//api/puzzle/daily/get(apiPuzzleDaily)`. + internal func apiPuzzleDaily(_ input: Operations.apiPuzzleDaily.Input) async throws -> Operations.apiPuzzleDaily.Output { + try await client.send( + input: input, + forOperation: Operations.apiPuzzleDaily.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/puzzle/daily", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiPuzzleDaily.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiPuzzleDaily.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.PuzzleAndGame.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get a puzzle by its ID + /// + /// Get a single Lichess puzzle in JSON format. + /// + /// - Remark: HTTP `GET /api/puzzle/{id}`. + /// - Remark: Generated from `#/paths//api/puzzle/{id}/get(apiPuzzleId)`. + internal func apiPuzzleId(_ input: Operations.apiPuzzleId.Input) async throws -> Operations.apiPuzzleId.Output { + try await client.send( + input: input, + forOperation: Operations.apiPuzzleId.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/puzzle/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiPuzzleId.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiPuzzleId.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.PuzzleAndGame.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get your puzzle activity + /// + /// Download your puzzle activity in [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Puzzle activity is sorted by reverse chronological order (most recent first) + /// We recommend streaming the response, for it can be very long. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/activity`. + /// - Remark: Generated from `#/paths//api/puzzle/activity/get(apiPuzzleActivity)`. + internal func apiPuzzleActivity(_ input: Operations.apiPuzzleActivity.Input) async throws -> Operations.apiPuzzleActivity.Output { + try await client.send( + input: input, + forOperation: Operations.apiPuzzleActivity.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/puzzle/activity", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "max", + value: input.query.max + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "before", + value: input.query.before + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiPuzzleActivity.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiPuzzleActivity.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get your puzzle dashboard + /// + /// Download your [puzzle dashboard](https://lichess.org/training/dashboard/30/dashboard) as JSON. + /// Also includes all puzzle themes played, with aggregated results. + /// Allows re-creating the [improvement/strengths](https://lichess.org/training/dashboard/30/improvementAreas) interfaces. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/dashboard/{days}`. + /// - Remark: Generated from `#/paths//api/puzzle/dashboard/{days}/get(apiPuzzleDashboard)`. + internal func apiPuzzleDashboard(_ input: Operations.apiPuzzleDashboard.Input) async throws -> Operations.apiPuzzleDashboard.Output { + try await client.send( + input: input, + forOperation: Operations.apiPuzzleDashboard.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/puzzle/dashboard/{}", + parameters: [ + input.path.days + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiPuzzleDashboard.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiPuzzleDashboard.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.PuzzleDashboardJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get the storm dashboard of a player + /// + /// Download the [storm dashboard](https://lichess.org/storm/dashboard/mrbasso) of any player as JSON. + /// Contains the aggregated highscores, and the history of storm runs aggregated by days. + /// Use `?days=0` if you only care about the highscores. + /// + /// + /// - Remark: HTTP `GET /api/storm/dashboard/{username}`. + /// - Remark: Generated from `#/paths//api/storm/dashboard/{username}/get(apiStormDashboard)`. + internal func apiStormDashboard(_ input: Operations.apiStormDashboard.Input) async throws -> Operations.apiStormDashboard.Output { + try await client.send( + input: input, + forOperation: Operations.apiStormDashboard.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/storm/dashboard/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "days", + value: input.query.days + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiStormDashboard.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiStormDashboard.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.StormDashboardJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create and join a puzzle race + /// + /// Create a new private [puzzle race](https://lichess.org/racer). + /// The Lichess user who creates the race must join the race page, + /// and manually start the race when enough players have joined. + /// - <https://lichess.org/racer> + /// + /// + /// - Remark: HTTP `POST /api/racer`. + /// - Remark: Generated from `#/paths//api/racer/post(racerPost)`. + internal func racerPost(_ input: Operations.racerPost.Input) async throws -> Operations.racerPost.Output { + try await client.send( + input: input, + forOperation: Operations.racerPost.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/racer", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.racerPost.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.racerPost.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.PuzzleRaceJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get users by ID + /// + /// Get up to 300 users by their IDs. Users are returned in the same order as the IDs. + /// The method is `POST` to allow a longer list of IDs to be sent in the request body. + /// Please do not try to download all the Lichess users with this endpoint, or any other endpoint. + /// An API is not a way to fully export a website. We do not provide a full download of the Lichess users. + /// This endpoint is limited to 8,000 users every 10 minutes, and 120,000 every day. + /// + /// + /// - Remark: HTTP `POST /api/users`. + /// - Remark: Generated from `#/paths//api/users/post(apiUsers)`. + internal func apiUsers(_ input: Operations.apiUsers.Input) async throws -> Operations.apiUsers.Output { + try await client.send( + input: input, + forOperation: Operations.apiUsers.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/users", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUsers.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUsers.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.User].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my profile + /// + /// Public information about the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account`. + /// - Remark: Generated from `#/paths//api/account/get(accountMe)`. + internal func accountMe(_ input: Operations.accountMe.Input) async throws -> Operations.accountMe.Output { + try await client.send( + input: input, + forOperation: Operations.accountMe.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.accountMe.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.accountMe.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.UserExtended.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my email address + /// + /// Read the email address of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account/email`. + /// - Remark: Generated from `#/paths//api/account/email/get(accountEmail)`. + internal func accountEmail(_ input: Operations.accountEmail.Input) async throws -> Operations.accountEmail.Output { + try await client.send( + input: input, + forOperation: Operations.accountEmail.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account/email", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.accountEmail.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.accountEmail.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.accountEmail.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my preferences + /// + /// Read the preferences of the logged in user. + /// - <https://lichess.org/account/preferences/game-display> + /// - <https://github.com/ornicar/lila/blob/master/modules/pref/src/main/Pref.scala> + /// + /// + /// - Remark: HTTP `GET /api/account/preferences`. + /// - Remark: Generated from `#/paths//api/account/preferences/get(account)`. + internal func account(_ input: Operations.account.Input) async throws -> Operations.account.Output { + try await client.send( + input: input, + forOperation: Operations.account.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account/preferences", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.account.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.account.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.account.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my kid mode status + /// + /// Read the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `GET /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/get(accountKid)`. + internal func accountKid(_ input: Operations.accountKid.Input) async throws -> Operations.accountKid.Output { + try await client.send( + input: input, + forOperation: Operations.accountKid.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account/kid", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.accountKid.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.accountKid.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.accountKid.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Set my kid mode status + /// + /// Set the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `POST /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/post(accountKidPost)`. + internal func accountKidPost(_ input: Operations.accountKidPost.Input) async throws -> Operations.accountKidPost.Output { + try await client.send( + input: input, + forOperation: Operations.accountKidPost.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account/kid", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "v", + value: input.query.v + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.accountKidPost.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.accountKidPost.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my timeline + /// + /// Get the timeline events of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/timeline`. + /// - Remark: Generated from `#/paths//api/timeline/get(timeline)`. + internal func timeline(_ input: Operations.timeline.Input) async throws -> Operations.timeline.Output { + try await client.send( + input: input, + forOperation: Operations.timeline.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/timeline", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "since", + value: input.query.since + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.timeline.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.timeline.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Timeline.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export one game + /// + /// Download one game in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /game/export/{gameId}`. + /// - Remark: Generated from `#/paths//game/export/{gameId}/get(gamePgn)`. + internal func gamePgn(_ input: Operations.gamePgn.Input) async throws -> Operations.gamePgn.Output { + try await client.send( + input: input, + forOperation: Operations.gamePgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/game/export/{}", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "literate", + value: input.query.literate + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "players", + value: input.query.players + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamePgn.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamePgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/json" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.GameJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export ongoing game of a user + /// + /// Download the ongoing game, or the last game played, of a user. + /// Available in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/current-game`. + /// - Remark: Generated from `#/paths//api/user/{username}/current-game/get(apiUserCurrentGame)`. + internal func apiUserCurrentGame(_ input: Operations.apiUserCurrentGame.Input) async throws -> Operations.apiUserCurrentGame.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserCurrentGame.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/current-game", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "literate", + value: input.query.literate + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "players", + value: input.query.players + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserCurrentGame.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserCurrentGame.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/json" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.GameJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export games of a user + /// + /// Download all games of any user in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// We recommend streaming the response, for it can be very long. + /// <https://lichess.org/@/german11> for instance has more than 500,000 games. + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// - Authenticated, downloading your own games: 60 games per second + /// + /// + /// - Remark: HTTP `GET /api/games/user/{username}`. + /// - Remark: Generated from `#/paths//api/games/user/{username}/get(apiGamesUser)`. + internal func apiGamesUser(_ input: Operations.apiGamesUser.Input) async throws -> Operations.apiGamesUser.Output { + try await client.send( + input: input, + forOperation: Operations.apiGamesUser.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/games/user/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "since", + value: input.query.since + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "until", + value: input.query.until + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "max", + value: input.query.max + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "vs", + value: input.query.vs + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "rated", + value: input.query.rated + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "perfType", + value: input.query.perfType + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "color", + value: input.query.color + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "analysed", + value: input.query.analysed + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "ongoing", + value: input.query.ongoing + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "finished", + value: input.query.finished + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "literate", + value: input.query.literate + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "lastFen", + value: input.query.lastFen + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "players", + value: input.query.players + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "sort", + value: input.query.sort + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiGamesUser.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiGamesUser.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export games by IDs + /// + /// Download games by IDs in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// Games are sorted by reverse chronological order (most recent first) + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// 300 IDs can be submitted. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `POST /api/games/export/_ids`. + /// - Remark: Generated from `#/paths//api/games/export/_ids/post(gamesExportIds)`. + internal func gamesExportIds(_ input: Operations.gamesExportIds.Input) async throws -> Operations.gamesExportIds.Output { + try await client.send( + input: input, + forOperation: Operations.gamesExportIds.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/games/export/_ids", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "literate", + value: input.query.literate + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "players", + value: input.query.players + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesExportIds.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesExportIds.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream games of users + /// + /// Stream the games played between a list of users, in real time. + /// Only games where **both players** are part of the list are included. + /// The stream emits an event each time a game is started or finished. + /// To also get all current ongoing games at the beginning of the stream, use the `withCurrentGames` flag. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of users: 300. + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/stream/games-by-users`. + /// - Remark: Generated from `#/paths//api/stream/games-by-users/post(gamesByUsers)`. + internal func gamesByUsers(_ input: Operations.gamesByUsers.Input) async throws -> Operations.gamesByUsers.Output { + try await client.send( + input: input, + forOperation: Operations.gamesByUsers.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/games-by-users", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "withCurrentGames", + value: input.query.withCurrentGames + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesByUsers.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesByUsers.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream games by IDs + /// + /// Creates a stream of games from an arbitrary streamId, and a list of game IDs. + /// The stream first outputs the games that already exists, then emits an event each time a game is started or finished. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of games: 500 for anonymous requests, or 1000 for [OAuth2 authenticated](#section/Introduction/Authentication) requests. + /// While the stream is open, it is possible to [add new game IDs to watch](#operation/gamesByIdsAdd). + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/post(gamesByIds)`. + internal func gamesByIds(_ input: Operations.gamesByIds.Input) async throws -> Operations.gamesByIds.Output { + try await client.send( + input: input, + forOperation: Operations.gamesByIds.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/games/{}", + parameters: [ + input.path.streamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesByIds.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesByIds.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Add game IDs to stream + /// + /// Add new game IDs for [an existing stream](#operation/gamesByIds) to watch. + /// The stream will immediately outputs the games that already exists, then emit an event each time a game is started or finished. + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}/add`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/add/post(gamesByIdsAdd)`. + internal func gamesByIdsAdd(_ input: Operations.gamesByIdsAdd.Input) async throws -> Operations.gamesByIdsAdd.Output { + try await client.send( + input: input, + forOperation: Operations.gamesByIdsAdd.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/games/{}/add", + parameters: [ + input.path.streamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesByIdsAdd.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesByIdsAdd.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get my ongoing games + /// + /// Get the ongoing games of the current user. + /// Real-time and correspondence games are included. + /// The most urgent games are listed first. + /// + /// + /// - Remark: HTTP `GET /api/account/playing`. + /// - Remark: Generated from `#/paths//api/account/playing/get(apiAccountPlaying)`. + internal func apiAccountPlaying(_ input: Operations.apiAccountPlaying.Input) async throws -> Operations.apiAccountPlaying.Output { + try await client.send( + input: input, + forOperation: Operations.apiAccountPlaying.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/account/playing", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiAccountPlaying.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiAccountPlaying.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream moves of a game + /// + /// Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A description of the game is sent as a first message. + /// Then a message is sent each time a move is played. + /// Finally a description of the game is sent when it finishes, and the stream is closed. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// No more than 8 game streams can be opened at the same time from the same IP address. + /// + /// + /// - Remark: HTTP `GET /api/stream/game/{id}`. + /// - Remark: Generated from `#/paths//api/stream/game/{id}/get(streamGame)`. + internal func streamGame(_ input: Operations.streamGame.Input) async throws -> Operations.streamGame.Output { + try await client.send( + input: input, + forOperation: Operations.streamGame.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/game/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.streamGame.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Import one game + /// + /// Import a game from PGN. See <https://lichess.org/paste>. + /// Rate limiting: 200 games per hour for OAuth requests, 100 games per hour for anonymous requests. + /// To broadcast ongoing games, consider [pushing to a broadcast instead](#operation/broadcastPush). + /// To analyse a position or a line, just construct an analysis board URL: + /// [https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+](https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+) + /// + /// + /// - Remark: HTTP `POST /api/import`. + /// - Remark: Generated from `#/paths//api/import/post(gameImport)`. + internal func gameImport(_ input: Operations.gameImport.Input) async throws -> Operations.gameImport.Output { + try await client.send( + input: input, + forOperation: Operations.gameImport.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/import", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gameImport.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gameImport.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export your imported games + /// + /// Download all games imported by you. Games are exported in PGN format. + /// + /// - Remark: HTTP `GET /api/games/export/imports`. + /// - Remark: Generated from `#/paths//api/games/export/imports/get(apiImportedGamesUser)`. + internal func apiImportedGamesUser(_ input: Operations.apiImportedGamesUser.Input) async throws -> Operations.apiImportedGamesUser.Output { + try await client.send( + input: input, + forOperation: Operations.apiImportedGamesUser.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/games/export/imports", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiImportedGamesUser.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiImportedGamesUser.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get current TV games + /// + /// Get basic info about the best games being played for each speed and variant, + /// but also computer games and bot games. + /// See [lichess.org/tv](https://lichess.org/tv). + /// + /// + /// - Remark: HTTP `GET /api/tv/channels`. + /// - Remark: Generated from `#/paths//api/tv/channels/get(tvChannels)`. + internal func tvChannels(_ input: Operations.tvChannels.Input) async throws -> Operations.tvChannels.Output { + try await client.send( + input: input, + forOperation: Operations.tvChannels.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tv/channels", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.tvChannels.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tvChannels.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream current TV game + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/feed`. + /// - Remark: Generated from `#/paths//api/tv/feed/get(tvFeed)`. + internal func tvFeed(_ input: Operations.tvFeed.Input) async throws -> Operations.tvFeed.Output { + try await client.send( + input: input, + forOperation: Operations.tvFeed.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tv/feed", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tvFeed.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream current TV game of a TV channel + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) of a TV channel in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/rapid/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}/feed`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/feed/get(tvChannelFeed)`. + internal func tvChannelFeed(_ input: Operations.tvChannelFeed.Input) async throws -> Operations.tvChannelFeed.Output { + try await client.send( + input: input, + forOperation: Operations.tvChannelFeed.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tv/{}/feed", + parameters: [ + input.path.channel + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tvChannelFeed.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get best ongoing games of a TV channel + /// + /// Get a list of ongoing games for a given TV channel. Similar to [lichess.org/games](https://lichess.org/games). + /// Available in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/get(tvChannelGames)`. + internal func tvChannelGames(_ input: Operations.tvChannelGames.Input) async throws -> Operations.tvChannelGames.Output { + try await client.send( + input: input, + forOperation: Operations.tvChannelGames.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tv/{}", + parameters: [ + input.path.channel + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tvChannelGames.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get current tournaments + /// + /// Get recently finished, ongoing, and upcoming tournaments. + /// This API is used to display the [Lichess tournament schedule](https://lichess.org/tournament). + /// + /// + /// - Remark: HTTP `GET /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/get(apiTournament)`. + internal func apiTournament(_ input: Operations.apiTournament.Input) async throws -> Operations.apiTournament.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournament.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournament.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournament.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ArenaTournaments.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a new Arena tournament + /// + /// Create a public or private Arena tournament. + /// This endpoint mirrors the form on <https://lichess.org/tournament/new>. + /// You can create up to 12 public tournaments per day, or 24 private tournaments. + /// A team battle can be created by specifying the `teamBattleByTeam` argument. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)`. + internal func apiTournamentPost(_ input: Operations.apiTournamentPost.Input) async throws -> Operations.apiTournamentPost.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentPost.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentPost.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentPost.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ArenaTournamentVariantIsKey.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentPost.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get info about an Arena tournament + /// + /// Get detailed info about recently finished, current, or upcoming tournament's duels, player standings, and other info. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/get(tournament)`. + internal func tournament(_ input: Operations.tournament.Input) async throws -> Operations.tournament.Output { + try await client.send( + input: input, + forOperation: Operations.tournament.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "page", + value: input.query.page + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.tournament.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tournament.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ArenaTournamentVariantIsKey.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update an Arena tournament + /// + /// Update an Arena tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Can be used to update a team battle. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)`. + internal func apiTournamentUpdate(_ input: Operations.apiTournamentUpdate.Input) async throws -> Operations.apiTournamentUpdate.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentUpdate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentUpdate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentUpdate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ArenaTournamentVariantIsKey.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentUpdate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Join an Arena tournament + /// + /// Join an Arena tournament, possibly with a password and/or a team. + /// Also unpauses if you had previously [paused](#operation/apiTournamentWithdraw) the tournament. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/join`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)`. + internal func apiTournamentJoin(_ input: Operations.apiTournamentJoin.Input) async throws -> Operations.apiTournamentJoin.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentJoin.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/join", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentJoin.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentJoin.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentJoin.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Pause or leave an Arena tournament + /// + /// Leave a future Arena tournament, or take a break on an ongoing Arena tournament. + /// It's possible to join again later. Points and streaks are preserved. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)`. + internal func apiTournamentWithdraw(_ input: Operations.apiTournamentWithdraw.Input) async throws -> Operations.apiTournamentWithdraw.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentWithdraw.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/withdraw", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentWithdraw.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentWithdraw.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentWithdraw.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Terminate an Arena tournament + /// + /// Terminate an Arena tournament + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)`. + internal func apiTournamentTerminate(_ input: Operations.apiTournamentTerminate.Input) async throws -> Operations.apiTournamentTerminate.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentTerminate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/terminate", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentTerminate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentTerminate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentTerminate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update a team battle + /// + /// Set the teams and number of leaders of a team battle. + /// To update the other attributes of a team battle, use the [tournament update endpoint](#operation/apiTournamentUpdate). + /// + /// + /// - Remark: HTTP `POST /api/tournament/team-battle/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)`. + internal func apiTournamentTeamBattlePost(_ input: Operations.apiTournamentTeamBattlePost.Input) async throws -> Operations.apiTournamentTeamBattlePost.Output { + try await client.send( + input: input, + forOperation: Operations.apiTournamentTeamBattlePost.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/team-battle/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTournamentTeamBattlePost.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentTeamBattlePost.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ArenaTournamentVariantIsKey.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTournamentTeamBattlePost.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export games of an Arena tournament + /// + /// Download games of a tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/games`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/games/get(gamesByTournament)`. + internal func gamesByTournament(_ input: Operations.gamesByTournament.Input) async throws -> Operations.gamesByTournament.Output { + try await client.send( + input: input, + forOperation: Operations.gamesByTournament.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/games", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "player", + value: input.query.player + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesByTournament.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesByTournament.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get results of an Arena tournament + /// + /// Players of an Arena tournament, with their score and performance, sorted by rank (best first). + /// **Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON)**, i.e. one JSON object per line. + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/results`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/results/get(resultsByTournament)`. + internal func resultsByTournament(_ input: Operations.resultsByTournament.Input) async throws -> Operations.resultsByTournament.Output { + try await client.send( + input: input, + forOperation: Operations.resultsByTournament.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/results", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "sheet", + value: input.query.sheet + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.resultsByTournament.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.resultsByTournament.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get team standing of a team battle + /// + /// Teams of a team battle tournament, with top players, sorted by rank (best first). + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/teams`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/teams/get(teamsByTournament)`. + internal func teamsByTournament(_ input: Operations.teamsByTournament.Input) async throws -> Operations.teamsByTournament.Output { + try await client.send( + input: input, + forOperation: Operations.teamsByTournament.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/tournament/{}/teams", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamsByTournament.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamsByTournament.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get tournaments created by a user + /// + /// Get all tournaments created by a given user. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/tournament/created`. + /// - Remark: Generated from `#/paths//api/user/{username}/tournament/created/get(apiUserNameTournamentCreated)`. + internal func apiUserNameTournamentCreated(_ input: Operations.apiUserNameTournamentCreated.Input) async throws -> Operations.apiUserNameTournamentCreated.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserNameTournamentCreated.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/tournament/created", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "status", + value: input.query.status + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserNameTournamentCreated.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserNameTournamentCreated.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a new Swiss tournament + /// + /// Create a Swiss tournament for your team. + /// This endpoint mirrors the Swiss tournament form from your team pagee. + /// You can create up to 12 tournaments per day. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/new/{teamId}`. + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)`. + internal func apiSwissNew(_ input: Operations.apiSwissNew.Input) async throws -> Operations.apiSwissNew.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissNew.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/new/{}", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSwissNew.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissNew.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.SwissTournament.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissNew.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get info about a Swiss tournament + /// + /// Get detailed info about a Swiss tournament. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/get(swiss)`. + internal func swiss(_ input: Operations.swiss.Input) async throws -> Operations.swiss.Output { + try await client.send( + input: input, + forOperation: Operations.swiss.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.swiss.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.swiss.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.SwissTournament.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update a Swiss tournament + /// + /// Update a Swiss tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/edit`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)`. + internal func apiSwissUpdate(_ input: Operations.apiSwissUpdate.Input) async throws -> Operations.apiSwissUpdate.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissUpdate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/edit", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSwissUpdate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissUpdate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.SwissTournament.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissUpdate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + case 401: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissUpdate.Output.Unauthorized.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.SwissUnauthorisedEdit.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .unauthorized(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Manually schedule the next round + /// + /// Manually schedule the next round date and time of a Swiss tournament. + /// This sets the `roundInterval` field to `99999999`, i.e. manual scheduling. + /// All further rounds will need to be manually scheduled, unless the `roundInterval` field is changed back to automatic scheduling. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/schedule-next-round`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)`. + internal func apiSwissScheduleNextRound(_ input: Operations.apiSwissScheduleNextRound.Input) async throws -> Operations.apiSwissScheduleNextRound.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissScheduleNextRound.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/schedule-next-round", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 204: + let headers: Operations.apiSwissScheduleNextRound.Output.NoContent.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + return .noContent(.init(headers: headers)) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissScheduleNextRound.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + case 401: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissScheduleNextRound.Output.Unauthorized.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.SwissUnauthorisedEdit.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .unauthorized(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Join a Swiss tournament + /// + /// Join a Swiss tournament, possibly with a password. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/join`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)`. + internal func apiSwissJoin(_ input: Operations.apiSwissJoin.Input) async throws -> Operations.apiSwissJoin.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissJoin.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/join", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSwissJoin.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissJoin.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissJoin.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Pause or leave a swiss tournament + /// + /// Leave a future Swiss tournament, or take a break on an ongoing Swiss tournament. + /// It's possible to join again later. Points are preserved. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/withdraw/post(apiSwissWithdraw)`. + internal func apiSwissWithdraw(_ input: Operations.apiSwissWithdraw.Input) async throws -> Operations.apiSwissWithdraw.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissWithdraw.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/withdraw", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSwissWithdraw.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissWithdraw.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Terminate a Swiss tournament + /// + /// Terminate a Swiss tournament + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)`. + internal func apiSwissTerminate(_ input: Operations.apiSwissTerminate.Input) async throws -> Operations.apiSwissTerminate.Output { + try await client.send( + input: input, + forOperation: Operations.apiSwissTerminate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/terminate", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSwissTerminate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissTerminate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSwissTerminate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export TRF of a Swiss tournament + /// + /// Download a tournament in the Tournament Report File format, the FIDE standard. + /// Documentation: <https://www.fide.com/FIDE/handbook/C04Annex2_TRF16.pdf> + /// Example: <https://lichess.org/swiss/j8rtJ5GL.trf> + /// + /// + /// - Remark: HTTP `GET /swiss/{id}.trf`. + /// - Remark: Generated from `#/paths//swiss/{id}.trf/get(swissTrf)`. + internal func swissTrf(_ input: Operations.swissTrf.Input) async throws -> Operations.swissTrf.Output { + try await client.send( + input: input, + forOperation: Operations.swissTrf.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/swiss/{}.trf", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.swissTrf.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.swissTrf.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "text/plain" + ] + ) + switch chosenContentType { + case "text/plain": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .plainText(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export games of a Swiss tournament + /// + /// Download games of a swiss tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (last round first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/games`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/games/get(gamesBySwiss)`. + internal func gamesBySwiss(_ input: Operations.gamesBySwiss.Input) async throws -> Operations.gamesBySwiss.Output { + try await client.send( + input: input, + forOperation: Operations.gamesBySwiss.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/games", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "player", + value: input.query.player + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "pgnInJson", + value: input.query.pgnInJson + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "tags", + value: input.query.tags + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "evals", + value: input.query.evals + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "accuracy", + value: input.query.accuracy + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opening", + value: input.query.opening + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "division", + value: input.query.division + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.gamesBySwiss.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.gamesBySwiss.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn", + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get results of a swiss tournament + /// + /// Players of a swiss tournament, with their score and performance, sorted by rank (best first). + /// Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/results`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/results/get(resultsBySwiss)`. + internal func resultsBySwiss(_ input: Operations.resultsBySwiss.Input) async throws -> Operations.resultsBySwiss.Output { + try await client.send( + input: input, + forOperation: Operations.resultsBySwiss.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/swiss/{}/results", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.resultsBySwiss.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.resultsBySwiss.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get team swiss tournaments + /// + /// Get all swiss tournaments of a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/swiss`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/swiss/get(apiTeamSwiss)`. + internal func apiTeamSwiss(_ input: Operations.apiTeamSwiss.Input) async throws -> Operations.apiTeamSwiss.Output { + try await client.send( + input: input, + forOperation: Operations.apiTeamSwiss.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/swiss", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "max", + value: input.query.max + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTeamSwiss.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTeamSwiss.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/nd-json" + ] + ) + switch chosenContentType { + case "application/nd-json": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_nd_hyphen_json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export one study chapter + /// + /// Download one study chapter in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}/{chapterId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}.pgn/get(studyChapterPgn)`. + internal func studyChapterPgn(_ input: Operations.studyChapterPgn.Input) async throws -> Operations.studyChapterPgn.Output { + try await client.send( + input: input, + forOperation: Operations.studyChapterPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/{}/{}.pgn", + parameters: [ + input.path.studyId, + input.path.chapterId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "comments", + value: input.query.comments + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variations", + value: input.query.variations + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "source", + value: input.query.source + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "orientation", + value: input.query.orientation + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.studyChapterPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export all chapters + /// + /// Download all chapters of a study in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/get(studyAllChaptersPgn)`. + internal func studyAllChaptersPgn(_ input: Operations.studyAllChaptersPgn.Input) async throws -> Operations.studyAllChaptersPgn.Output { + try await client.send( + input: input, + forOperation: Operations.studyAllChaptersPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/{}.pgn", + parameters: [ + input.path.studyId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "comments", + value: input.query.comments + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variations", + value: input.query.variations + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "source", + value: input.query.source + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "orientation", + value: input.query.orientation + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.studyAllChaptersPgn.Output.Ok.Headers = .init( + Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + ), + Last_hyphen_Modified: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Last-Modified", + as: Swift.String.self + ) + ) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.studyAllChaptersPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Study metadata + /// + /// Only get the study headers, including `Last-Modified`. + /// + /// + /// - Remark: HTTP `HEAD /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/head(studyAllChaptersHead)`. + internal func studyAllChaptersHead(_ input: Operations.studyAllChaptersHead.Input) async throws -> Operations.studyAllChaptersHead.Output { + try await client.send( + input: input, + forOperation: Operations.studyAllChaptersHead.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/{}.pgn", + parameters: [ + input.path.studyId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .head + ) + suppressMutabilityWarning(&request) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.studyAllChaptersHead.Output.Ok.Headers = .init( + Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + ), + Last_hyphen_Modified: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Last-Modified", + as: Swift.String.self + ) + ) + return .ok(.init(headers: headers)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Import PGN into a study + /// + /// Imports arbitrary PGN into an existing [study](https://lichess.org/study). Creates a new chapter in the study. + /// If the PGN contains multiple games (separated by 2 or more newlines) + /// then multiple chapters will be created within the study. + /// Note that a study can contain at most 64 chapters. + /// + /// + /// - Remark: HTTP `POST /api/study/{studyId}/import-pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)`. + internal func apiStudyImportPGN(_ input: Operations.apiStudyImportPGN.Input) async throws -> Operations.apiStudyImportPGN.Output { + try await client.send( + input: input, + forOperation: Operations.apiStudyImportPGN.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/{}/import-pgn", + parameters: [ + input.path.studyId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiStudyImportPGN.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiStudyImportPGN.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.StudyImportPgnChapters.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiStudyImportPGN.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export all studies of a user + /// + /// Download all chapters of all studies of a user in PGN format. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// + /// + /// - Remark: HTTP `GET /study/by/{username}/export.pgn`. + /// - Remark: Generated from `#/paths//study/by/{username}/export.pgn/get(studyExportAllPgn)`. + internal func studyExportAllPgn(_ input: Operations.studyExportAllPgn.Input) async throws -> Operations.studyExportAllPgn.Output { + try await client.send( + input: input, + forOperation: Operations.studyExportAllPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/study/by/{}/export.pgn", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "clocks", + value: input.query.clocks + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "comments", + value: input.query.comments + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variations", + value: input.query.variations + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "source", + value: input.query.source + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "orientation", + value: input.query.orientation + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.studyExportAllPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// List studies of a user + /// + /// Get metadata (name and dates) of all studies of a user. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// Studies are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/study/by/{username}`. + /// - Remark: Generated from `#/paths//api/study/by/{username}/get(studyListMetadata)`. + internal func studyListMetadata(_ input: Operations.studyListMetadata.Input) async throws -> Operations.studyListMetadata.Output { + try await client.send( + input: input, + forOperation: Operations.studyListMetadata.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/by/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.studyListMetadata.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.studyListMetadata.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Delete a study chapter + /// + /// Delete a chapter of a study you own. This is definitive. + /// A study must have at least one chapter; so if you delete the last chapter, + /// an empty one will be automatically created to replace it. + /// + /// + /// - Remark: HTTP `DELETE /api/study/{studyId}/{chapterId}`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}/delete(apiStudyStudyIdChapterIdDelete)`. + internal func apiStudyStudyIdChapterIdDelete(_ input: Operations.apiStudyStudyIdChapterIdDelete.Input) async throws -> Operations.apiStudyStudyIdChapterIdDelete.Output { + try await client.send( + input: input, + forOperation: Operations.apiStudyStudyIdChapterIdDelete.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/study/{}/{}", + parameters: [ + input.path.studyId, + input.path.chapterId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .delete + ) + suppressMutabilityWarning(&request) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 204: + let headers: Operations.apiStudyStudyIdChapterIdDelete.Output.NoContent.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + return .noContent(.init(headers: headers)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get official broadcasts + /// + /// Get all incoming, ongoing, and finished official broadcasts. + /// The broadcasts are sorted by start date, most recent first. + /// Broadcasts are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/broadcast`. + /// - Remark: Generated from `#/paths//api/broadcast/get(broadcastIndex)`. + internal func broadcastIndex(_ input: Operations.broadcastIndex.Input) async throws -> Operations.broadcastIndex.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastIndex.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastIndex.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastIndex.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a broadcast tournament + /// + /// Create a new broadcast tournament to relay external games. + /// This endpoint accepts the same form data as the [web form](https://lichess.org/broadcast/new). + /// + /// + /// - Remark: HTTP `POST /broadcast/new`. + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)`. + internal func broadcastTourCreate(_ input: Operations.broadcastTourCreate.Input) async throws -> Operations.broadcastTourCreate.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastTourCreate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/new", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastTourCreate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastTourCreate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastTour.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastTourCreate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get a broadcast tournament + /// + /// Get information about a broadcast tournament. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}/get(broadcastTourGet)`. + internal func broadcastTourGet(_ input: Operations.broadcastTourGet.Input) async throws -> Operations.broadcastTourGet.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastTourGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast/{}", + parameters: [ + input.path.broadcastTournamentId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastTourGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastTour.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get a broadcast leaderboard + /// + /// Get the leaderboard of a broadcast tournament, if available. + /// + /// + /// - Remark: HTTP `GET /broadcast/{broadcastTournamentId}/leaderboard`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/leaderboard/get(broadcastLeaderboardGet)`. + internal func broadcastLeaderboardGet(_ input: Operations.broadcastLeaderboardGet.Input) async throws -> Operations.broadcastLeaderboardGet.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastLeaderboardGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/{}/leaderboard", + parameters: [ + input.path.broadcastTournamentId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastLeaderboardGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.BroadcastLeaderboardEntry].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update your broadcast tournament + /// + /// Update information about a broadcast tournament that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)`. + internal func broadcastTourUpdate(_ input: Operations.broadcastTourUpdate.Input) async throws -> Operations.broadcastTourUpdate.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastTourUpdate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/{}/edit", + parameters: [ + input.path.broadcastTournamentId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastTourUpdate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastTourUpdate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastTourUpdate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a broadcast round + /// + /// Create a new broadcast round to relay external games. + /// This endpoint accepts the same form data as the web form. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/new`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)`. + internal func broadcastRoundCreate(_ input: Operations.broadcastRoundCreate.Input) async throws -> Operations.broadcastRoundCreate.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastRoundCreate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/{}/new", + parameters: [ + input.path.broadcastTournamentId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastRoundCreate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundCreate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastRound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundCreate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get a broadcast round + /// + /// Get information about a broadcast round. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/get(broadcastRoundGet)`. + internal func broadcastRoundGet(_ input: Operations.broadcastRoundGet.Input) async throws -> Operations.broadcastRoundGet.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastRoundGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast/{}/{}/{}", + parameters: [ + input.path.broadcastTournamentSlug, + input.path.broadcastRoundSlug, + input.path.broadcastRoundId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastRound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update your broadcast round + /// + /// Update information about a broadcast round that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// For instance, if you omit `startDate`, then any pre-existing start date will be removed. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)`. + internal func broadcastRoundUpdate(_ input: Operations.broadcastRoundUpdate.Input) async throws -> Operations.broadcastRoundUpdate.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastRoundUpdate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/round/{}/edit", + parameters: [ + input.path.broadcastRoundId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastRoundUpdate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundUpdate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundUpdate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Push PGN to your broadcast round + /// + /// Update your broadcast with new PGN. + /// Only for broadcast without a source URL. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/push`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)`. + internal func broadcastPush(_ input: Operations.broadcastPush.Input) async throws -> Operations.broadcastPush.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastPush.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/broadcast/round/{}/push", + parameters: [ + input.path.broadcastRoundId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastPush.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastPush.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastPgnPush.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let headers: Operations.broadcastPush.Output.BadRequest.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastPush.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.broadcastPush.Output.BadRequest.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream an ongoing broadcast tournament as PGN + /// + /// This streaming endpoint first sends all games of a broadcast tournament in PGN format. + /// Then, it waits for new moves to be played. As soon as it happens, the entire PGN of the game is sent to the stream. + /// The stream will also send PGNs when games are added to the tournament. + /// This is the best way to get updates about an ongoing tournament. Streaming means no polling, + /// and no pollings means no latency, and minimum impact on the server. + /// + /// + /// - Remark: HTTP `GET /api/stream/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/stream/broadcast/round/{broadcastRoundId}.pgn/get(broadcastStreamRoundPgn)`. + internal func broadcastStreamRoundPgn(_ input: Operations.broadcastStreamRoundPgn.Input) async throws -> Operations.broadcastStreamRoundPgn.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastStreamRoundPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/broadcast/round/{}.pgn", + parameters: [ + input.path.broadcastRoundId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastStreamRoundPgn.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastStreamRoundPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export one round as PGN + /// + /// Download all games of a single round of a broadcast tournament in PGN format. + /// You *could* poll this endpoint to get updates about a tournament, but it would be slow, + /// and very inefficient. + /// Instead, consider [streaming the tournament](#operation/broadcastStreamRoundPgn) to get + /// a new PGN every time a game is updated, in real-time. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/round/{broadcastRoundId}.pgn/get(broadcastRoundPgn)`. + internal func broadcastRoundPgn(_ input: Operations.broadcastRoundPgn.Input) async throws -> Operations.broadcastRoundPgn.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastRoundPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast/round/{}.pgn", + parameters: [ + input.path.broadcastRoundId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastRoundPgn.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastRoundPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Export all rounds as PGN + /// + /// Download all games of all rounds of a broadcast in PGN format. + /// If a `study:read` [OAuth token](#tag/OAuth) is provided, + /// the private rounds where the user is a contributor will be available. + /// You may want to [download only the games of a single round](#operation/broadcastRoundPgn) instead. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}.pgn/get(broadcastAllRoundsPgn)`. + internal func broadcastAllRoundsPgn(_ input: Operations.broadcastAllRoundsPgn.Input) async throws -> Operations.broadcastAllRoundsPgn.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastAllRoundsPgn.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast/{}.pgn", + parameters: [ + input.path.broadcastTournamentId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.broadcastAllRoundsPgn.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastAllRoundsPgn.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get your broadcast rounds + /// + /// Stream all broadcast rounds you are a member of. + /// Also includes broadcasts rounds you did not create, but were invited to. + /// Also includes broadcasts rounds where you're a non-writing member. See the `writeable` flag in the response. + /// Rounds are ordered by rank, which is roughly chronological, most recent first, slightly pondered with popularity. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/my-rounds`. + /// - Remark: Generated from `#/paths//api/broadcast/my-rounds/get(broadcastMyRoundsGet)`. + internal func broadcastMyRoundsGet(_ input: Operations.broadcastMyRoundsGet.Input) async throws -> Operations.broadcastMyRoundsGet.Output { + try await client.send( + input: input, + forOperation: Operations.broadcastMyRoundsGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/broadcast/my-rounds", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.broadcastMyRoundsGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BroadcastMyRound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get current simuls + /// + /// Get recently created, started, finished, simuls. + /// Created and finished simul lists are not exhaustives, only those with + /// strong enough host will be listed, the same filter is used to display simuls on https://lichess.org/simul. + /// When [authenticated with OAuth2](#section/Introduction/Authentication), the pending list will be populated with your created, but unstarted simuls. + /// + /// + /// - Remark: HTTP `GET /api/simul`. + /// - Remark: Generated from `#/paths//api/simul/get(apiSimul)`. + internal func apiSimul(_ input: Operations.apiSimul.Input) async throws -> Operations.apiSimul.Output { + try await client.send( + input: input, + forOperation: Operations.apiSimul.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/simul", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiSimul.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiSimul.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.apiSimul.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get a single team + /// + /// Public info about a team. Includes the list of publicly visible leaders. + /// + /// - Remark: HTTP `GET /api/team/{teamId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/get(teamShow)`. + internal func teamShow(_ input: Operations.teamShow.Input) async throws -> Operations.teamShow.Output { + try await client.send( + input: input, + forOperation: Operations.teamShow.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamShow.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamShow.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Team.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get popular teams + /// + /// Paginator of the most popular teams. + /// + /// + /// - Remark: HTTP `GET /api/team/all`. + /// - Remark: Generated from `#/paths//api/team/all/get(teamAll)`. + internal func teamAll(_ input: Operations.teamAll.Input) async throws -> Operations.teamAll.Output { + try await client.send( + input: input, + forOperation: Operations.teamAll.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/all", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "page", + value: input.query.page + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamAll.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamAll.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.TeamPaginatorJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Teams of a player + /// + /// All the teams a player is a member of. + /// + /// + /// - Remark: HTTP `GET /api/team/of/{username}`. + /// - Remark: Generated from `#/paths//api/team/of/{username}/get(teamOfUsername)`. + internal func teamOfUsername(_ input: Operations.teamOfUsername.Input) async throws -> Operations.teamOfUsername.Output { + try await client.send( + input: input, + forOperation: Operations.teamOfUsername.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/of/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamOfUsername.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamOfUsername.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.Team].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Search teams + /// + /// Paginator of team search results for a keyword. + /// + /// + /// - Remark: HTTP `GET /api/team/search`. + /// - Remark: Generated from `#/paths//api/team/search/get(teamSearch)`. + internal func teamSearch(_ input: Operations.teamSearch.Input) async throws -> Operations.teamSearch.Output { + try await client.send( + input: input, + forOperation: Operations.teamSearch.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/search", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "text", + value: input.query.text + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "page", + value: input.query.page + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamSearch.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamSearch.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.TeamPaginatorJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get members of a team + /// + /// Members are sorted by reverse chronological order of joining the team (most recent first). + /// OAuth is only required if the list of members is private. + /// Members are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/users`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/users/get(teamIdUsers)`. + internal func teamIdUsers(_ input: Operations.teamIdUsers.Input) async throws -> Operations.teamIdUsers.Output { + try await client.send( + input: input, + forOperation: Operations.teamIdUsers.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/users", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamIdUsers.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdUsers.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get team Arena tournaments + /// + /// Get all Arena tournaments relevant to a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/arena`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/arena/get(apiTeamArena)`. + internal func apiTeamArena(_ input: Operations.apiTeamArena.Input) async throws -> Operations.apiTeamArena.Output { + try await client.send( + input: input, + forOperation: Operations.apiTeamArena.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/arena", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "max", + value: input.query.max + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiTeamArena.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiTeamArena.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Join a team + /// + /// Join a team. + /// If the team requires a password but the `password` field is incorrect, + /// then the call fails with `403 Forbidden`. + /// Similarly, if the team join policy requires a confirmation but the + /// `message` parameter is not given, then the call fails with + /// `403 Forbidden`. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/join`. + /// - Remark: Generated from `#/paths//team/{teamId}/join/post(teamIdJoin)`. + internal func teamIdJoin(_ input: Operations.teamIdJoin.Input) async throws -> Operations.teamIdJoin.Output { + try await client.send( + input: input, + forOperation: Operations.teamIdJoin.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/team/{}/join", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdJoin.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Leave a team + /// + /// Leave a team. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/quit`. + /// - Remark: Generated from `#/paths//team/{teamId}/quit/post(teamIdQuit)`. + internal func teamIdQuit(_ input: Operations.teamIdQuit.Input) async throws -> Operations.teamIdQuit.Output { + try await client.send( + input: input, + forOperation: Operations.teamIdQuit.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/team/{}/quit", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdQuit.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get join requests + /// + /// Get pending join requests of your team + /// + /// - Remark: HTTP `GET /api/team/{teamId}/requests`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/requests/get(teamRequests)`. + internal func teamRequests(_ input: Operations.teamRequests.Input) async throws -> Operations.teamRequests.Output { + try await client.send( + input: input, + forOperation: Operations.teamRequests.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/requests", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "declined", + value: input.query.declined + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamRequests.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.TeamRequestWithUser].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Accept join request + /// + /// Accept someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/accept`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/accept/post(teamRequestAccept)`. + internal func teamRequestAccept(_ input: Operations.teamRequestAccept.Input) async throws -> Operations.teamRequestAccept.Output { + try await client.send( + input: input, + forOperation: Operations.teamRequestAccept.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/request/{}/accept", + parameters: [ + input.path.teamId, + input.path.userId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamRequestAccept.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Decline join request + /// + /// Decline someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/decline`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/decline/post(teamRequestDecline)`. + internal func teamRequestDecline(_ input: Operations.teamRequestDecline.Input) async throws -> Operations.teamRequestDecline.Output { + try await client.send( + input: input, + forOperation: Operations.teamRequestDecline.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/request/{}/decline", + parameters: [ + input.path.teamId, + input.path.userId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamRequestDecline.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Kick a user from your team + /// + /// Kick a member out of one of your teams. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /api/team/{teamId}/kick/{userId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/kick/{userId}/post(teamIdKickUserId)`. + internal func teamIdKickUserId(_ input: Operations.teamIdKickUserId.Input) async throws -> Operations.teamIdKickUserId.Output { + try await client.send( + input: input, + forOperation: Operations.teamIdKickUserId.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/team/{}/kick/{}", + parameters: [ + input.path.teamId, + input.path.userId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdKickUserId.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Message all members + /// + /// Send a private message to all members of a team. + /// You must be a team leader with the "Messages" permission. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/pm-all`. + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)`. + internal func teamIdPmAll(_ input: Operations.teamIdPmAll.Input) async throws -> Operations.teamIdPmAll.Output { + try await client.send( + input: input, + forOperation: Operations.teamIdPmAll.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/team/{}/pm-all", + parameters: [ + input.path.teamId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.teamIdPmAll.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdPmAll.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.teamIdPmAll.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get live streamers + /// + /// Get basic info about currently streaming users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// + /// + /// - Remark: HTTP `GET /api/streamer/live`. + /// - Remark: Generated from `#/paths//api/streamer/live/get(streamerLive)`. + internal func streamerLive(_ input: Operations.streamerLive.Input) async throws -> Operations.streamerLive.Output { + try await client.send( + input: input, + forOperation: Operations.streamerLive.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/streamer/live", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.streamerLive.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.streamerLive.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.LightUser].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get crosstable + /// + /// Get total number of games, and current score, of any two users. + /// If the `matchup` flag is provided, and the users are currently playing, also gets the current match game number and scores. + /// + /// + /// - Remark: HTTP `GET /api/crosstable/{user1}/{user2}`. + /// - Remark: Generated from `#/paths//api/crosstable/{user1}/{user2}/get(apiCrosstable)`. + internal func apiCrosstable(_ input: Operations.apiCrosstable.Input) async throws -> Operations.apiCrosstable.Output { + try await client.send( + input: input, + forOperation: Operations.apiCrosstable.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/crosstable/{}/{}", + parameters: [ + input.path.user1, + input.path.user2 + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "matchup", + value: input.query.matchup + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiCrosstable.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiCrosstable.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Crosstable.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Autocomplete usernames + /// + /// Provides autocompletion options for an incomplete username. + /// + /// + /// - Remark: HTTP `GET /api/player/autocomplete`. + /// - Remark: Generated from `#/paths//api/player/autocomplete/get(apiPlayerAutocomplete)`. + internal func apiPlayerAutocomplete(_ input: Operations.apiPlayerAutocomplete.Input) async throws -> Operations.apiPlayerAutocomplete.Output { + try await client.send( + input: input, + forOperation: Operations.apiPlayerAutocomplete.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/player/autocomplete", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "term", + value: input.query.term + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "object", + value: input.query.object + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "friend", + value: input.query.friend + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiPlayerAutocomplete.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiPlayerAutocomplete.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.apiPlayerAutocomplete.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get notes for a user + /// + /// Get the private notes that you have added for a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/get(readNote)`. + internal func readNote(_ input: Operations.readNote.Input) async throws -> Operations.readNote.Output { + try await client.send( + input: input, + forOperation: Operations.readNote.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/note", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.readNote.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.readNote.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.UserNote].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Add a note for a user + /// + /// Add a private note available only to you about this account. + /// + /// + /// - Remark: HTTP `POST /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/post(writeNote)`. + internal func writeNote(_ input: Operations.writeNote.Input) async throws -> Operations.writeNote.Output { + try await client.send( + input: input, + forOperation: Operations.writeNote.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/user/{}/note", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.writeNote.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get users followed by the logged in user + /// + /// Users are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/rel/following`. + /// - Remark: Generated from `#/paths//api/rel/following/get(apiUserFollowing)`. + internal func apiUserFollowing(_ input: Operations.apiUserFollowing.Input) async throws -> Operations.apiUserFollowing.Output { + try await client.send( + input: input, + forOperation: Operations.apiUserFollowing.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/rel/following", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiUserFollowing.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiUserFollowing.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Follow a player + /// + /// Follow a player, adding them to your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/follow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/follow/{username}/post(followUser)`. + internal func followUser(_ input: Operations.followUser.Input) async throws -> Operations.followUser.Output { + try await client.send( + input: input, + forOperation: Operations.followUser.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/rel/follow/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.followUser.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Unfollow a player + /// + /// Unfollow a player, removing them from your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/unfollow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/unfollow/{username}/post(unfollowUser)`. + internal func unfollowUser(_ input: Operations.unfollowUser.Input) async throws -> Operations.unfollowUser.Output { + try await client.send( + input: input, + forOperation: Operations.unfollowUser.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/rel/unfollow/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.unfollowUser.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream incoming events + /// + /// + /// Stream the events reaching a lichess user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// An empty line is sent every 6 seconds for keep alive purposes. + /// + /// Each non-empty line is a JSON object containing a `type` field. Possible values are: + /// - `gameStart` Start of a game + /// - `gameFinish` Completion of a game + /// - `challenge` A player sends you a challenge or you challenge someone + /// - `challengeCanceled` A player cancels their challenge to you + /// - `challengeDeclined` The opponent declines your challenge + /// + /// When the stream opens, all current challenges and games are sent. + /// + /// - Remark: HTTP `GET /api/stream/event`. + /// - Remark: Generated from `#/paths//api/stream/event/get(apiStreamEvent)`. + internal func apiStreamEvent(_ input: Operations.apiStreamEvent.Input) async throws -> Operations.apiStreamEvent.Output { + try await client.send( + input: input, + forOperation: Operations.apiStreamEvent.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/stream/event", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiStreamEvent.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiStreamEvent.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a seek + /// + /// + /// Create a public seek, to start a game with a random player. + /// + /// ### Real-time seek + /// + /// Specify the `time` and `increment` clock values. The response is streamed but doesn't contain any information. + /// + /// **Keep the connection open to keep the seek active**. + /// + /// If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. + /// When the seek is accepted, or expires, the server closes the connection. + /// + /// **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. + /// We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, + /// you won't miss the game event if the seek is accepted immediately. + /// + /// ### Correspondence seek + /// + /// Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone. + /// + /// - Remark: HTTP `POST /api/board/seek`. + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)`. + internal func apiBoardSeek(_ input: Operations.apiBoardSeek.Input) async throws -> Operations.apiBoardSeek.Output { + try await client.send( + input: input, + forOperation: Operations.apiBoardSeek.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/seek", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiBoardSeek.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiBoardSeek.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "text/plain" + ] + ) + switch chosenContentType { + case "text/plain": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .plainText(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiBoardSeek.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream Board game state + /// + /// Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, a draw is offered, or when the game ends. + /// - `chatLine` Chat message sent by a user in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// + /// The server closes the stream when the game ends, or if the game has already ended. + /// + /// - Remark: HTTP `GET /api/board/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)`. + internal func boardGameStream(_ input: Operations.boardGameStream.Input) async throws -> Operations.boardGameStream.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameStream.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/stream/{}", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameStream.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameStream.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameStream.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Make a Board move + /// + /// Make a move in a game being played with the Board API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)`. + internal func boardGameMove(_ input: Operations.boardGameMove.Input) async throws -> Operations.boardGameMove.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameMove.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/move/{}", + parameters: [ + input.path.gameId, + input.path.move + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "offeringDraw", + value: input.query.offeringDraw + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameMove.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameMove.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameMove.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/get(boardGameChatGet)`. + internal func boardGameChatGet(_ input: Operations.boardGameChatGet.Input) async throws -> Operations.boardGameChatGet.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameChatGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/chat", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameChatGet.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameChatGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)`. + internal func boardGameChatPost(_ input: Operations.boardGameChatPost.Input) async throws -> Operations.boardGameChatPost.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameChatPost.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/chat", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameChatPost.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameChatPost.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameChatPost.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Abort a game + /// + /// Abort a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)`. + internal func boardGameAbort(_ input: Operations.boardGameAbort.Input) async throws -> Operations.boardGameAbort.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameAbort.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/abort", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameAbort.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameAbort.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameAbort.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Resign a game + /// + /// Resign a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)`. + internal func boardGameResign(_ input: Operations.boardGameResign.Input) async throws -> Operations.boardGameResign.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameResign.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/resign", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameResign.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameResign.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameResign.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)`. + internal func boardGameDraw(_ input: Operations.boardGameDraw.Input) async throws -> Operations.boardGameDraw.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameDraw.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/draw/{}", + parameters: [ + input.path.gameId, + input.path.accept + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameDraw.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameDraw.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameDraw.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)`. + internal func boardGameTakeback(_ input: Operations.boardGameTakeback.Input) async throws -> Operations.boardGameTakeback.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameTakeback.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/takeback/{}", + parameters: [ + input.path.gameId, + input.path.accept + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameTakeback.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameTakeback.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameTakeback.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Claim victory of a game + /// + /// Claim victory when the opponent has left the game for a while. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/claim-victory`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)`. + internal func boardGameClaimVictory(_ input: Operations.boardGameClaimVictory.Input) async throws -> Operations.boardGameClaimVictory.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameClaimVictory.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/claim-victory", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameClaimVictory.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameClaimVictory.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameClaimVictory.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Berserk a tournament game + /// + /// Go berserk on an arena tournament game. Halves the clock time, grants an extra point upon winning. + /// Only available in arena tournaments that allow berserk, and before each player has made a move. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/berserk`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)`. + internal func boardGameBerserk(_ input: Operations.boardGameBerserk.Input) async throws -> Operations.boardGameBerserk.Output { + try await client.send( + input: input, + forOperation: Operations.boardGameBerserk.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/board/game/{}/berserk", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.boardGameBerserk.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameBerserk.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.boardGameBerserk.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get online bots + /// + /// Stream the [online bot users](https://lichess.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second. + /// + /// - Remark: HTTP `GET /api/bot/online`. + /// - Remark: Generated from `#/paths//api/bot/online/get(apiBotOnline)`. + internal func apiBotOnline(_ input: Operations.apiBotOnline.Input) async throws -> Operations.apiBotOnline.Output { + try await client.send( + input: input, + forOperation: Operations.apiBotOnline.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/online", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "nb", + value: input.query.nb + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiBotOnline.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiBotOnline.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Upgrade to Bot account + /// + /// Upgrade a lichess player account into a Bot account. Only Bot accounts can use the Bot API. + /// The account **cannot have played any game** before becoming a Bot account. The upgrade is **irreversible**. The account will only be able to play as a Bot. + /// To upgrade an account to Bot, use the [official lichess-bot client](https://github.com/lichess-bot-devs/lichess-bot), or follow these steps: + /// - Create an [API access token](https://lichess.org/account/oauth/token/create?scopes[]=bot:play) with "Play bot moves" permission. + /// - `curl -d '' https://lichess.org/api/bot/account/upgrade -H "Authorization: Bearer <yourTokenHere>"` + /// To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): + /// the `title` field should be set to `BOT`. + /// + /// + /// - Remark: HTTP `POST /api/bot/account/upgrade`. + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)`. + internal func botAccountUpgrade(_ input: Operations.botAccountUpgrade.Input) async throws -> Operations.botAccountUpgrade.Output { + try await client.send( + input: input, + forOperation: Operations.botAccountUpgrade.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/account/upgrade", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botAccountUpgrade.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botAccountUpgrade.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botAccountUpgrade.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Stream Bot game state + /// + /// Stream the state of a game being played with the Bot API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. + /// - `chatLine` Chat message sent by a user (or the bot itself) in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// - Remark: HTTP `GET /api/bot/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)`. + internal func botGameStream(_ input: Operations.botGameStream.Input) async throws -> Operations.botGameStream.Output { + try await client.send( + input: input, + forOperation: Operations.botGameStream.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/stream/{}", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameStream.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameStream.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameStream.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Make a Bot move + /// + /// Make a move in a game being played with the Bot API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)`. + internal func botGameMove(_ input: Operations.botGameMove.Input) async throws -> Operations.botGameMove.Output { + try await client.send( + input: input, + forOperation: Operations.botGameMove.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/move/{}", + parameters: [ + input.path.gameId, + input.path.move + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "offeringDraw", + value: input.query.offeringDraw + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameMove.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameMove.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameMove.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/get(botGameChatGet)`. + internal func botGameChatGet(_ input: Operations.botGameChatGet.Input) async throws -> Operations.botGameChatGet.Output { + try await client.send( + input: input, + forOperation: Operations.botGameChatGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/chat", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameChatGet.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameChatGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)`. + internal func botGameChat(_ input: Operations.botGameChat.Input) async throws -> Operations.botGameChat.Output { + try await client.send( + input: input, + forOperation: Operations.botGameChat.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/chat", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameChat.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameChat.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameChat.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Abort a game + /// + /// Abort a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)`. + internal func botGameAbort(_ input: Operations.botGameAbort.Input) async throws -> Operations.botGameAbort.Output { + try await client.send( + input: input, + forOperation: Operations.botGameAbort.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/abort", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameAbort.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameAbort.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameAbort.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Resign a game + /// + /// Resign a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)`. + internal func botGameResign(_ input: Operations.botGameResign.Input) async throws -> Operations.botGameResign.Output { + try await client.send( + input: input, + forOperation: Operations.botGameResign.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/resign", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameResign.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameResign.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameResign.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers with the Bot API. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)`. + internal func botGameDraw(_ input: Operations.botGameDraw.Input) async throws -> Operations.botGameDraw.Output { + try await client.send( + input: input, + forOperation: Operations.botGameDraw.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/draw/{}", + parameters: [ + input.path.gameId, + input.path.accept + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameDraw.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameDraw.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameDraw.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks with the Bot API. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)`. + internal func botGameTakeback(_ input: Operations.botGameTakeback.Input) async throws -> Operations.botGameTakeback.Output { + try await client.send( + input: input, + forOperation: Operations.botGameTakeback.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bot/game/{}/takeback/{}", + parameters: [ + input.path.gameId, + input.path.accept + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.botGameTakeback.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameTakeback.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.botGameTakeback.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// List your challenges + /// + /// Get a list of challenges created by or targeted at you. + /// + /// + /// - Remark: HTTP `GET /api/challenge`. + /// - Remark: Generated from `#/paths//api/challenge/get(challengeList)`. + internal func challengeList(_ input: Operations.challengeList.Input) async throws -> Operations.challengeList.Output { + try await client.send( + input: input, + forOperation: Operations.challengeList.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeList.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeList.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.challengeList.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a challenge + /// + /// Challenge someone to play. The targeted player can choose to accept or decline. + /// If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) + /// that a new game has started. The game ID will be the same as the challenge ID. + /// Challenges for realtime games (not correspondence) expire after 20s if not accepted. + /// To prevent that, use the `keepAliveStream` flag described below. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{username}`. + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)`. + internal func challengeCreate(_ input: Operations.challengeCreate.Input) async throws -> Operations.challengeCreate.Output { + try await client.send( + input: input, + forOperation: Operations.challengeCreate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeCreate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeCreate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.challengeCreate.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeCreate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Accept a challenge + /// + /// Accept an incoming challenge. + /// You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent). + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/accept`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)`. + internal func challengeAccept(_ input: Operations.challengeAccept.Input) async throws -> Operations.challengeAccept.Output { + try await client.send( + input: input, + forOperation: Operations.challengeAccept.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/{}/accept", + parameters: [ + input.path.challengeId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeAccept.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeAccept.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeAccept.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Decline a challenge + /// + /// Decline an incoming challenge. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/decline`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)`. + internal func challengeDecline(_ input: Operations.challengeDecline.Input) async throws -> Operations.challengeDecline.Output { + try await client.send( + input: input, + forOperation: Operations.challengeDecline.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/{}/decline", + parameters: [ + input.path.challengeId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case .none: + body = nil + case let .urlEncodedForm(value): + body = try converter.setOptionalRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeDecline.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeDecline.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeDecline.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Cancel a challenge + /// + /// Cancel a challenge you sent, or aborts the game if the challenge was accepted, but the game was not yet played. + /// Note that the ID of a game is the same as the ID of the challenge that created it. + /// Works for user challenges and open challenges alike. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/cancel`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)`. + internal func challengeCancel(_ input: Operations.challengeCancel.Input) async throws -> Operations.challengeCancel.Output { + try await client.send( + input: input, + forOperation: Operations.challengeCancel.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/{}/cancel", + parameters: [ + input.path.challengeId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "opponentToken", + value: input.query.opponentToken + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeCancel.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeCancel.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeCancel.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Challenge the AI + /// + /// Start a game with Lichess AI. + /// You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. + /// + /// + /// - Remark: HTTP `POST /api/challenge/ai`. + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)`. + internal func challengeAi(_ input: Operations.challengeAi.Input) async throws -> Operations.challengeAi.Output { + try await client.send( + input: input, + forOperation: Operations.challengeAi.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/ai", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 201: + let headers: Operations.challengeAi.Output.Created.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeAi.Output.Created.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.GameJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .created(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeAi.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Open-ended challenge + /// + /// Create a challenge that any 2 players can join. + /// Share the URL of the challenge. the first 2 players to click it will be paired for a game. + /// The response body also contains `whiteUrl` and `blackUrl`. + /// You can control which color each player gets by giving them these URLs, + /// instead of the main challenge URL. + /// Open challenges expire after 24h. + /// If the challenge creation is [authenticated with OAuth2](#section/Introduction/Authentication), + /// then you can use the [challenge cancel endpoint](#operation/challengeCancel) to cancel it. + /// To directly pair 2 known players, use [this endpoint](#operation/bulkPairingList) instead. + /// + /// + /// - Remark: HTTP `POST /api/challenge/open`. + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)`. + internal func challengeOpen(_ input: Operations.challengeOpen.Input) async throws -> Operations.challengeOpen.Output { + try await client.send( + input: input, + forOperation: Operations.challengeOpen.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/open", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeOpen.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeOpen.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ChallengeOpenJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeOpen.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Start clocks of a game + /// + /// Start the clocks of a game immediately, even if a player has not yet made a move. + /// Requires the OAuth tokens of both players with `challenge:write` scope. + /// If the clocks have already started, the call will have no effect. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{gameId}/start-clocks`. + /// - Remark: Generated from `#/paths//api/challenge/{gameId}/start-clocks/post(challengeStartClocks)`. + internal func challengeStartClocks(_ input: Operations.challengeStartClocks.Input) async throws -> Operations.challengeStartClocks.Output { + try await client.send( + input: input, + forOperation: Operations.challengeStartClocks.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/challenge/{}/start-clocks", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "token1", + value: input.query.token1 + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "token2", + value: input.query.token2 + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.challengeStartClocks.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.challengeStartClocks.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// View your bulk pairings + /// + /// Get a list of bulk pairings you created. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/get(bulkPairingList)`. + internal func bulkPairingList(_ input: Operations.bulkPairingList.Input) async throws -> Operations.bulkPairingList.Output { + try await client.send( + input: input, + forOperation: Operations.bulkPairingList.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bulk-pairing", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.bulkPairingList.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingList.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.BulkPairing].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create a bulk pairing + /// + /// Schedule many games at once, up to 24h in advance. + /// OAuth tokens are required for all paired players, with the `challenge:write` scope. + /// You can schedule up to 500 games every 10 minutes. [Contact us](mailto:contact@lichess.org) if you need higher limits. + /// If games have a real-time clock, each player must have only one pairing. + /// For correspondence games, players can have multiple pairings within the same bulk. + /// The entire bulk is rejected if: + /// - a token is missing + /// - a token is present more than once (except in correspondence) + /// - a token lacks the `challenge:write` scope + /// - a player account is closed + /// - a player is paired more than once (except in correspondence) + /// - a bulk is already scheduled to start at the same time with the same player + /// - you have 20 scheduled bulks + /// - you have 1000 scheduled games + /// Partial bulks are never created. Either it all fails, or it all succeeds. + /// When it fails, it does so with an error message explaining the issue. + /// Failed bulks are not counted in the rate limiting, they are free. + /// Fix the issues, manually or programmatically, then retry to schedule the bulk. + /// A successful bulk creation returns a JSON bulk document. Its ID can be used for further operations. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)`. + internal func bulkPairingCreate(_ input: Operations.bulkPairingCreate.Input) async throws -> Operations.bulkPairingCreate.Output { + try await client.send( + input: input, + forOperation: Operations.bulkPairingCreate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bulk-pairing", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.bulkPairingCreate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingCreate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BulkPairing.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingCreate.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Manually start clocks + /// + /// Immediately start all clocks of the games of a bulk pairing. + /// This overrides the `startClocksAt` value of an existing bulk pairing. + /// If the games have not yet been created (`bulk.pairAt` is in the future), then this does nothing. + /// If the clocks have already started (`bulk.startClocksAt` is in the past), then this does nothing. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing/{id}/start-clocks`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)`. + internal func bulkPairingStartClocks(_ input: Operations.bulkPairingStartClocks.Input) async throws -> Operations.bulkPairingStartClocks.Output { + try await client.send( + input: input, + forOperation: Operations.bulkPairingStartClocks.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bulk-pairing/{}/start-clocks", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.bulkPairingStartClocks.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingStartClocks.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingStartClocks.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Show a bulk pairing + /// + /// Get a single bulk pairing by its ID. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)`. + internal func bulkPairingGet(_ input: Operations.bulkPairingGet.Input) async throws -> Operations.bulkPairingGet.Output { + try await client.send( + input: input, + forOperation: Operations.bulkPairingGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bulk-pairing/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.bulkPairingGet.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.BulkPairing.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingGet.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Cancel a bulk pairing + /// + /// Cancel and delete a bulk pairing that is scheduled in the future. + /// If the games have already been created, then this does nothing. + /// Canceling a bulk pairing does not refund the rate limit cost of that bulk pairing. + /// + /// + /// - Remark: HTTP `DELETE /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)`. + internal func bulkPairingDelete(_ input: Operations.bulkPairingDelete.Input) async throws -> Operations.bulkPairingDelete.Output { + try await client.send( + input: input, + forOperation: Operations.bulkPairingDelete.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/bulk-pairing/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .delete + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.bulkPairingDelete.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingDelete.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 404: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.bulkPairingDelete.Output.NotFound.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.NotFound.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .notFound(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Add time to the opponent clock + /// + /// Add seconds to the opponent's clock. Can be used to create games with time odds. + /// + /// + /// - Remark: HTTP `POST /api/round/{gameId}/add-time/{seconds}`. + /// - Remark: Generated from `#/paths//api/round/{gameId}/add-time/{seconds}/post(roundAddTime)`. + internal func roundAddTime(_ input: Operations.roundAddTime.Input) async throws -> Operations.roundAddTime.Output { + try await client.send( + input: input, + forOperation: Operations.roundAddTime.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/round/{}/add-time/{}", + parameters: [ + input.path.gameId, + input.path.seconds + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.roundAddTime.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.roundAddTime.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Admin challenge tokens + /// + /// **This endpoint can only be used by Lichess administrators. It will not work if you do not have the appropriate permissions.** Tournament organizers should instead use [OAuth](#tag/OAuth) to obtain `challenge:write` tokens from users in order to perform bulk pairing.* + /// Create and obtain `challenge:write` tokens for multiple users. + /// If a similar token already exists for a user, it is reused. This endpoint is idempotent. + /// + /// + /// - Remark: HTTP `POST /api/token/admin-challenge`. + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)`. + internal func adminChallengeTokens(_ input: Operations.adminChallengeTokens.Input) async throws -> Operations.adminChallengeTokens.Output { + try await client.send( + input: input, + forOperation: Operations.adminChallengeTokens.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/token/admin-challenge", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.adminChallengeTokens.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.adminChallengeTokens.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.adminChallengeTokens.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Send a private message + /// + /// Send a private message to another player. + /// + /// + /// - Remark: HTTP `POST /inbox/{username}`. + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)`. + internal func inboxUsername(_ input: Operations.inboxUsername.Input) async throws -> Operations.inboxUsername.Output { + try await client.send( + input: input, + forOperation: Operations.inboxUsername.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/inbox/{}", + parameters: [ + input.path.username + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.inboxUsername.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + case 400: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.inboxUsername.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas._Error.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get cloud evaluation of a position. + /// + /// Get the cached evaluation of a position, if available. + /// Opening positions have more chances of being available. There are about 15 million positions in the database. + /// Up to 5 variations may be available. Variants are supported. + /// Use this endpoint to fetch a few positions here and there. + /// If you want to download a lot of positions, [get the full list](https://database.lichess.org/#evals) from our exported database. + /// + /// + /// - Remark: HTTP `GET /api/cloud-eval`. + /// - Remark: Generated from `#/paths//api/cloud-eval/get(apiCloudEval)`. + internal func apiCloudEval(_ input: Operations.apiCloudEval.Input) async throws -> Operations.apiCloudEval.Output { + try await client.send( + input: input, + forOperation: Operations.apiCloudEval.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/cloud-eval", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "fen", + value: input.query.fen + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "multiPv", + value: input.query.multiPv + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variant", + value: input.query.variant + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiCloudEval.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiCloudEval.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// List external engines + /// + /// Lists all external engines that have been registered for the user, + /// and the credentials required to use them. + /// + /// + /// - Remark: HTTP `GET /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/get(apiExternalEngineList)`. + internal func apiExternalEngineList(_ input: Operations.apiExternalEngineList.Input) async throws -> Operations.apiExternalEngineList.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineList.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineList.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineList.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + [Components.Schemas.ExternalEngine].self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Create external engine + /// + /// Registers a new external engine for the user. It can then be selected + /// and used on the analysis board. + /// After registering, the provider should start waiting for analyis requests. + /// + /// + /// - Remark: HTTP `POST /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/post(apiExternalEngineCreate)`. + internal func apiExternalEngineCreate(_ input: Operations.apiExternalEngineCreate.Input) async throws -> Operations.apiExternalEngineCreate.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineCreate.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .json(value): + body = try converter.setRequiredRequestBodyAsJSON( + value, + headerFields: &request.headerFields, + contentType: "application/json; charset=utf-8" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineCreate.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineCreate.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ExternalEngine.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Get external engine + /// + /// Get properties and credentials of an external engine. + /// + /// + /// - Remark: HTTP `GET /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/get(apiExternalEngineGet)`. + internal func apiExternalEngineGet(_ input: Operations.apiExternalEngineGet.Input) async throws -> Operations.apiExternalEngineGet.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineGet.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineGet.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineGet.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ExternalEngine.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Update external engine + /// + /// Updates the properties of an external engine. + /// + /// + /// - Remark: HTTP `PUT /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/put(apiExternalEnginePut)`. + internal func apiExternalEnginePut(_ input: Operations.apiExternalEnginePut.Input) async throws -> Operations.apiExternalEnginePut.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEnginePut.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .put + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .json(value): + body = try converter.setRequiredRequestBodyAsJSON( + value, + headerFields: &request.headerFields, + contentType: "application/json; charset=utf-8" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEnginePut.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEnginePut.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ExternalEngine.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Delete external engine + /// + /// Unregisters an external engine. + /// + /// + /// - Remark: HTTP `DELETE /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/delete(apiExternalEngineDelete)`. + internal func apiExternalEngineDelete(_ input: Operations.apiExternalEngineDelete.Input) async throws -> Operations.apiExternalEngineDelete.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineDelete.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .delete + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineDelete.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.Ok.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Analyse with external engine + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/{id}/analyse`** + /// Request analysis from an external engine. + /// Response content is streamed as [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). + /// The properties are based on the [UCI specification](https://backscattering.de/chess/uci/#engine). + /// Analysis stops when the client goes away, the requested limit + /// is reached, or the provider goes away. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/{id}/analyse`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/analyse/post(apiExternalEngineAnalyse)`. + internal func apiExternalEngineAnalyse(_ input: Operations.apiExternalEngineAnalyse.Input) async throws -> Operations.apiExternalEngineAnalyse.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineAnalyse.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/{}/analyse", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .json(value): + body = try converter.setRequiredRequestBodyAsJSON( + value, + headerFields: &request.headerFields, + contentType: "application/json; charset=utf-8" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineAnalyse.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineAnalyse.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-ndjson" + ] + ) + switch chosenContentType { + case "application/x-ndjson": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_ndjson(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Acquire analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work`** + /// Wait for an analysis requests to any of the external engines that + /// have been registered with the given `secret`. + /// Uses long polling. + /// After acquiring a request, the provider should immediately + /// [start streaming the results](#tag/External-engine/operation/apiExternalEngineSubmit). + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work`. + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)`. + internal func apiExternalEngineAcquire(_ input: Operations.apiExternalEngineAcquire.Input) async throws -> Operations.apiExternalEngineAcquire.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineAcquire.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/work", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .json(value): + body = try converter.setRequiredRequestBodyAsJSON( + value, + headerFields: &request.headerFields, + contentType: "application/json; charset=utf-8" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineAcquire.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiExternalEngineAcquire.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.apiExternalEngineAcquire.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 204: + let headers: Operations.apiExternalEngineAcquire.Output.NoContent.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + return .noContent(.init(headers: headers)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Answer analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work/{id}`** + /// Submit a stream of analysis as [UCI output](https://backscattering.de/chess/uci/#engine-info). + /// * The engine should always be in `UCI_Chess960` mode. + /// * `UCI_AnalyseMode` enabled if available. + /// * It produces `info` with at least: + /// - `depth` + /// - `multipv` (between 1 and 5) + /// - `score` + /// - `nodes` + /// - `time` + /// - `pv` + /// The server may close the connection at any time, indicating that + /// the requester has gone away and analysis should be stopped. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/work/{id}/post(apiExternalEngineSubmit)`. + internal func apiExternalEngineSubmit(_ input: Operations.apiExternalEngineSubmit.Input) async throws -> Operations.apiExternalEngineSubmit.Output { + try await client.send( + input: input, + forOperation: Operations.apiExternalEngineSubmit.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/external-engine/work/{}", + parameters: [ + input.path.id + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiExternalEngineSubmit.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + return .ok(.init(headers: headers)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Request authorization code + /// + /// OAuth2 authorization endpoint. + /// Start the OAuth2 Authorization Code Flow with PKCE by securely + /// generating two random strings unique to each authorization + /// request: + /// * `code_verifier` + /// * `state` + /// Store these in session storage. Make sure not to reveal `code_verifier` + /// to eavesdroppers. Do not show it in URLs, do not abuse `state` to store + /// it, do not send it over insecure connections. However it is fine if + /// the user themselves can extract `code_verifier`, which will always be + /// possible for fully client-side apps. + /// Then send the user to this endpoint. They will be prompted to grant + /// authorization and then be redirected back to the given `redirect_uri`. + /// If the authorization failed, the following query string parameters will + /// be appended to the redirection: + /// * `error`, in particular with value `access_denied` if the user + /// cancelled authorization + /// * `error_description` to aid debugging + /// * `state`, exactly as passed in the `state` parameter + /// If the authorization succeeded, the following query string parameters + /// will be appended to the redirection: + /// * `code`, containing a fresh short-lived authorization code + /// * `state`, exactly as passed in the `state` parameter + /// Next, to defend against cross site request forgery, check that the + /// returned `state` matches the `state` you originally generated. + /// Finally, continue by using the authorization code to + /// [obtain an access token](#operation/apiToken). + /// + /// + /// - Remark: HTTP `GET /oauth`. + /// - Remark: Generated from `#/paths//oauth/get(oauth)`. + internal func oauth(_ input: Operations.oauth.Input) async throws -> Operations.oauth.Output { + try await client.send( + input: input, + forOperation: Operations.oauth.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/oauth", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "response_type", + value: input.query.response_type + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "client_id", + value: input.query.client_id + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "redirect_uri", + value: input.query.redirect_uri + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "code_challenge_method", + value: input.query.code_challenge_method + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "code_challenge", + value: input.query.code_challenge + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "scope", + value: input.query.scope + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "username", + value: input.query.username + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "state", + value: input.query.state + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + return .ok(.init()) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Obtain access token + /// + /// OAuth2 token endpoint. Exchanges an authorization code for an access token. + /// + /// + /// - Remark: HTTP `POST /api/token`. + /// - Remark: Generated from `#/paths//api/token/post(apiToken)`. + internal func apiToken(_ input: Operations.apiToken.Input) async throws -> Operations.apiToken.Output { + try await client.send( + input: input, + forOperation: Operations.apiToken.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/token", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .urlEncodedForm(value): + body = try converter.setRequiredRequestBodyAsURLEncodedForm( + value, + headerFields: &request.headerFields, + contentType: "application/x-www-form-urlencoded" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.apiToken.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiToken.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIValueContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + case 400: + let headers: Operations.apiToken.Output.BadRequest.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.apiToken.Output.BadRequest.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.OAuthError.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .badRequest(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Revoke access token + /// + /// Revokes the access token sent as Bearer for this request. + /// + /// - Remark: HTTP `DELETE /api/token`. + /// - Remark: Generated from `#/paths//api/token/delete(apiTokenDelete)`. + internal func apiTokenDelete(_ input: Operations.apiTokenDelete.Input) async throws -> Operations.apiTokenDelete.Output { + try await client.send( + input: input, + forOperation: Operations.apiTokenDelete.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/token", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .delete + ) + suppressMutabilityWarning(&request) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 204: + let headers: Operations.apiTokenDelete.Output.NoContent.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + return .noContent(.init(headers: headers)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Test multiple OAuth tokens + /// + /// For up to 1000 OAuth tokens, + /// returns their associated user ID and scopes, + /// or `null` if the token is invalid. + /// The method is `POST` so a longer list of tokens can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/token/test`. + /// - Remark: Generated from `#/paths//api/token/test/post(tokenTest)`. + internal func tokenTest(_ input: Operations.tokenTest.Input) async throws -> Operations.tokenTest.Output { + try await client.send( + input: input, + forOperation: Operations.tokenTest.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/api/token/test", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + let body: OpenAPIRuntime.HTTPBody? + switch input.body { + case let .plainText(value): + body = try converter.setRequiredRequestBodyAsBinary( + value, + headerFields: &request.headerFields, + contentType: "text/plain" + ) + } + return (request, body) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tokenTest.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Operations.tokenTest.Output.Ok.Body.jsonPayload.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init(body: body)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Masters database + /// + /// **Endpoint: <https://explorer.lichess.ovh/masters>** + /// Example: `curl https://explorer.lichess.ovh/masters?play=d2d4,d7d5,c2c4,c7c6,c4d5` + /// + /// + /// - Remark: HTTP `GET /masters`. + /// - Remark: Generated from `#/paths//masters/get(openingExplorerMaster)`. + internal func openingExplorerMaster(_ input: Operations.openingExplorerMaster.Input) async throws -> Operations.openingExplorerMaster.Output { + try await client.send( + input: input, + forOperation: Operations.openingExplorerMaster.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/masters", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "fen", + value: input.query.fen + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "play", + value: input.query.play + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "since", + value: input.query.since + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "until", + value: input.query.until + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "topGames", + value: input.query.topGames + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.openingExplorerMaster.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.openingExplorerMaster.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.OpeningExplorerJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Lichess games + /// + /// **Endpoint: <https://explorer.lichess.ovh/lichess>** + /// Games sampled from all Lichess players. + /// Example: `curl https://explorer.lichess.ovh/lichess?variant=standard&speeds=blitz,rapid,classical&ratings=2200,2500&fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201` + /// + /// + /// - Remark: HTTP `GET /lichess`. + /// - Remark: Generated from `#/paths//lichess/get(openingExplorerLichess)`. + internal func openingExplorerLichess(_ input: Operations.openingExplorerLichess.Input) async throws -> Operations.openingExplorerLichess.Output { + try await client.send( + input: input, + forOperation: Operations.openingExplorerLichess.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/lichess", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variant", + value: input.query.variant + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "fen", + value: input.query.fen + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "play", + value: input.query.play + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "speeds", + value: input.query.speeds + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "ratings", + value: input.query.ratings + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "since", + value: input.query.since + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "until", + value: input.query.until + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "topGames", + value: input.query.topGames + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "recentGames", + value: input.query.recentGames + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "history", + value: input.query.history + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.openingExplorerLichess.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.openingExplorerLichess.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.OpeningExplorerJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Player games + /// + /// **Endpoint: <https://explorer.lichess.ovh/player>** + /// Games of a Lichess player. + /// Responds with a stream of [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). Will start indexing + /// on demand, immediately respond with the current results, and stream + /// more updates until indexing is complete. The stream is throttled + /// and deduplicated. Empty lines may be sent to avoid timeouts. + /// Will index new games at most once per minute, and revisit previously + /// ongoing games at most once every day. + /// Example: `curl https://explorer.lichess.ovh/player?player=revoof&color=white&play=d2d4,d7d5&recentGames=1` + /// + /// + /// - Remark: HTTP `GET /player`. + /// - Remark: Generated from `#/paths//player/get(openingExplorerPlayer)`. + internal func openingExplorerPlayer(_ input: Operations.openingExplorerPlayer.Input) async throws -> Operations.openingExplorerPlayer.Output { + try await client.send( + input: input, + forOperation: Operations.openingExplorerPlayer.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/player", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "player", + value: input.query.player + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "variant", + value: input.query.variant + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "fen", + value: input.query.fen + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "play", + value: input.query.play + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "speeds", + value: input.query.speeds + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "modes", + value: input.query.modes + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "since", + value: input.query.since + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "until", + value: input.query.until + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "moves", + value: input.query.moves + ) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "recentGames", + value: input.query.recentGames + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.openingExplorerPlayer.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.openingExplorerPlayer.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/nd-json" + ] + ) + switch chosenContentType { + case "application/nd-json": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_nd_hyphen_json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// OTB master game + /// + /// **Endpoint: `https://explorer.lichess.ovh/masters/pgn/{gameId}`** + /// Example: `curl https://explorer.lichess.ovh/masters/pgn/aAbqI4ey` + /// + /// + /// - Remark: HTTP `GET /master/pgn/{gameId}`. + /// - Remark: Generated from `#/paths//master/pgn/{gameId}/get(openingExplorerMasterGame)`. + internal func openingExplorerMasterGame(_ input: Operations.openingExplorerMasterGame.Input) async throws -> Operations.openingExplorerMasterGame.Output { + try await client.send( + input: input, + forOperation: Operations.openingExplorerMasterGame.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/master/pgn/{}", + parameters: [ + input.path.gameId + ] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.openingExplorerMasterGame.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.openingExplorerMasterGame.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/x-chess-pgn" + ] + ) + switch chosenContentType { + case "application/x-chess-pgn": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .application_x_hyphen_chess_hyphen_pgn(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Tablebase lookup + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// Example: `curl http://tablebase.lichess.ovh/standard?fen=4k3/6KP/8/8/8/8/7p/8_w_-_-_0_1` + /// + /// + /// - Remark: HTTP `GET /standard`. + /// - Remark: Generated from `#/paths//standard/get(tablebaseStandard)`. + internal func tablebaseStandard(_ input: Operations.tablebaseStandard.Input) async throws -> Operations.tablebaseStandard.Output { + try await client.send( + input: input, + forOperation: Operations.tablebaseStandard.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/standard", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + try converter.setQueryItemAsURI( + in: &request, + style: .form, + explode: true, + name: "fen", + value: input.query.fen + ) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.tablebaseStandard.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tablebaseStandard.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.TablebaseJson.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Tablebase lookup for Atomic chess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /atomic`. + /// - Remark: Generated from `#/paths//atomic/get(tablebaseAtomic)`. + internal func tablebaseAtomic(_ input: Operations.tablebaseAtomic.Input) async throws -> Operations.tablebaseAtomic.Output { + try await client.send( + input: input, + forOperation: Operations.tablebaseAtomic.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/atomic", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.tablebaseAtomic.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.tablebaseAtomic.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "text/plain" + ] + ) + switch chosenContentType { + case "text/plain": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .plainText(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } + /// Tablebase lookup for Antichess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /antichess`. + /// - Remark: Generated from `#/paths//antichess/get(antichessAtomic)`. + internal func antichessAtomic(_ input: Operations.antichessAtomic.Input) async throws -> Operations.antichessAtomic.Output { + try await client.send( + input: input, + forOperation: Operations.antichessAtomic.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/antichess", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .get + ) + suppressMutabilityWarning(&request) + converter.setAcceptHeader( + in: &request.headerFields, + contentTypes: input.headers.accept + ) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let headers: Operations.antichessAtomic.Output.Ok.Headers = .init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: try converter.getOptionalHeaderFieldAsURI( + in: response.headerFields, + name: "Access-Control-Allow-Origin", + as: Swift.String.self + )) + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.antichessAtomic.Output.Ok.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "text/plain" + ] + ) + switch chosenContentType { + case "text/plain": + body = try converter.getResponseBodyAsBinary( + OpenAPIRuntime.HTTPBody.self, + from: responseBody, + transforming: { value in + .plainText(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .ok(.init( + headers: headers, + body: body + )) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } +} diff --git a/Sources/LichessClient/Generated/Types.swift b/Sources/LichessClient/Generated/Types.swift new file mode 100644 index 0000000..2dd9821 --- /dev/null +++ b/Sources/LichessClient/Generated/Types.swift @@ -0,0 +1,39108 @@ +// Generated by swift-openapi-generator, do not modify. +@_spi(Generated) import OpenAPIRuntime +#if os(Linux) +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date +#else +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date +#endif +/// A type that performs HTTP operations defined by the OpenAPI document. +internal protocol APIProtocol: Sendable { + /// Get real-time users status + /// + /// Read the `online`, `playing` and `streaming` flags of several users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// Use it to track players and know when they're connected on lichess and playing games. + /// + /// + /// - Remark: HTTP `GET /api/users/status`. + /// - Remark: Generated from `#/paths//api/users/status/get(apiUsersStatus)`. + func apiUsersStatus(_ input: Operations.apiUsersStatus.Input) async throws -> Operations.apiUsersStatus.Output + /// Get all top 10 + /// + /// Get the top 10 players for each speed and variant. + /// See <https://lichess.org/player>. + /// + /// + /// - Remark: HTTP `GET /api/player`. + /// - Remark: Generated from `#/paths//api/player/get(player)`. + func player(_ input: Operations.player.Input) async throws -> Operations.player.Output + /// Get one leaderboard + /// + /// Get the leaderboard for a single speed or variant (a.k.a. `perfType`). + /// There is no leaderboard for correspondence or puzzles. + /// See <https://lichess.org/player/top/200/bullet>. + /// + /// + /// - Remark: HTTP `GET /api/player/top/{nb}/{perfType}`. + /// - Remark: Generated from `#/paths//api/player/top/{nb}/{perfType}/get(playerTopNbPerfType)`. + func playerTopNbPerfType(_ input: Operations.playerTopNbPerfType.Input) async throws -> Operations.playerTopNbPerfType.Output + /// Get user public data + /// + /// Read public data of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}`. + /// - Remark: Generated from `#/paths//api/user/{username}/get(apiUser)`. + func apiUser(_ input: Operations.apiUser.Input) async throws -> Operations.apiUser.Output + /// Get rating history of a user + /// + /// Read rating history of a user, for all perf types. + /// There is at most one entry per day. + /// Format of an entry is `[year, month, day, rating]`. + /// `month` starts at zero (January). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/rating-history`. + /// - Remark: Generated from `#/paths//api/user/{username}/rating-history/get(apiUserRatingHistory)`. + func apiUserRatingHistory(_ input: Operations.apiUserRatingHistory.Input) async throws -> Operations.apiUserRatingHistory.Output + /// Get performance statistics of a user + /// + /// Read performance statistics of a user, for a single performance. + /// Similar to the [performance pages on the website](https://lichess.org/@/thibault/perf/bullet). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/perf/{perf}`. + /// - Remark: Generated from `#/paths//api/user/{username}/perf/{perf}/get(apiUserPerf)`. + func apiUserPerf(_ input: Operations.apiUserPerf.Input) async throws -> Operations.apiUserPerf.Output + /// Get user activity + /// + /// Read data to generate the activity feed of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/activity`. + /// - Remark: Generated from `#/paths//api/user/{username}/activity/get(apiUserActivity)`. + func apiUserActivity(_ input: Operations.apiUserActivity.Input) async throws -> Operations.apiUserActivity.Output + /// Get the daily puzzle + /// + /// Get the daily Lichess puzzle in JSON format. + /// Alternatively, you can [post it in your slack workspace](https://lichess.org/daily-puzzle-slack). + /// + /// + /// - Remark: HTTP `GET /api/puzzle/daily`. + /// - Remark: Generated from `#/paths//api/puzzle/daily/get(apiPuzzleDaily)`. + func apiPuzzleDaily(_ input: Operations.apiPuzzleDaily.Input) async throws -> Operations.apiPuzzleDaily.Output + /// Get a puzzle by its ID + /// + /// Get a single Lichess puzzle in JSON format. + /// + /// - Remark: HTTP `GET /api/puzzle/{id}`. + /// - Remark: Generated from `#/paths//api/puzzle/{id}/get(apiPuzzleId)`. + func apiPuzzleId(_ input: Operations.apiPuzzleId.Input) async throws -> Operations.apiPuzzleId.Output + /// Get your puzzle activity + /// + /// Download your puzzle activity in [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Puzzle activity is sorted by reverse chronological order (most recent first) + /// We recommend streaming the response, for it can be very long. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/activity`. + /// - Remark: Generated from `#/paths//api/puzzle/activity/get(apiPuzzleActivity)`. + func apiPuzzleActivity(_ input: Operations.apiPuzzleActivity.Input) async throws -> Operations.apiPuzzleActivity.Output + /// Get your puzzle dashboard + /// + /// Download your [puzzle dashboard](https://lichess.org/training/dashboard/30/dashboard) as JSON. + /// Also includes all puzzle themes played, with aggregated results. + /// Allows re-creating the [improvement/strengths](https://lichess.org/training/dashboard/30/improvementAreas) interfaces. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/dashboard/{days}`. + /// - Remark: Generated from `#/paths//api/puzzle/dashboard/{days}/get(apiPuzzleDashboard)`. + func apiPuzzleDashboard(_ input: Operations.apiPuzzleDashboard.Input) async throws -> Operations.apiPuzzleDashboard.Output + /// Get the storm dashboard of a player + /// + /// Download the [storm dashboard](https://lichess.org/storm/dashboard/mrbasso) of any player as JSON. + /// Contains the aggregated highscores, and the history of storm runs aggregated by days. + /// Use `?days=0` if you only care about the highscores. + /// + /// + /// - Remark: HTTP `GET /api/storm/dashboard/{username}`. + /// - Remark: Generated from `#/paths//api/storm/dashboard/{username}/get(apiStormDashboard)`. + func apiStormDashboard(_ input: Operations.apiStormDashboard.Input) async throws -> Operations.apiStormDashboard.Output + /// Create and join a puzzle race + /// + /// Create a new private [puzzle race](https://lichess.org/racer). + /// The Lichess user who creates the race must join the race page, + /// and manually start the race when enough players have joined. + /// - <https://lichess.org/racer> + /// + /// + /// - Remark: HTTP `POST /api/racer`. + /// - Remark: Generated from `#/paths//api/racer/post(racerPost)`. + func racerPost(_ input: Operations.racerPost.Input) async throws -> Operations.racerPost.Output + /// Get users by ID + /// + /// Get up to 300 users by their IDs. Users are returned in the same order as the IDs. + /// The method is `POST` to allow a longer list of IDs to be sent in the request body. + /// Please do not try to download all the Lichess users with this endpoint, or any other endpoint. + /// An API is not a way to fully export a website. We do not provide a full download of the Lichess users. + /// This endpoint is limited to 8,000 users every 10 minutes, and 120,000 every day. + /// + /// + /// - Remark: HTTP `POST /api/users`. + /// - Remark: Generated from `#/paths//api/users/post(apiUsers)`. + func apiUsers(_ input: Operations.apiUsers.Input) async throws -> Operations.apiUsers.Output + /// Get my profile + /// + /// Public information about the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account`. + /// - Remark: Generated from `#/paths//api/account/get(accountMe)`. + func accountMe(_ input: Operations.accountMe.Input) async throws -> Operations.accountMe.Output + /// Get my email address + /// + /// Read the email address of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account/email`. + /// - Remark: Generated from `#/paths//api/account/email/get(accountEmail)`. + func accountEmail(_ input: Operations.accountEmail.Input) async throws -> Operations.accountEmail.Output + /// Get my preferences + /// + /// Read the preferences of the logged in user. + /// - <https://lichess.org/account/preferences/game-display> + /// - <https://github.com/ornicar/lila/blob/master/modules/pref/src/main/Pref.scala> + /// + /// + /// - Remark: HTTP `GET /api/account/preferences`. + /// - Remark: Generated from `#/paths//api/account/preferences/get(account)`. + func account(_ input: Operations.account.Input) async throws -> Operations.account.Output + /// Get my kid mode status + /// + /// Read the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `GET /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/get(accountKid)`. + func accountKid(_ input: Operations.accountKid.Input) async throws -> Operations.accountKid.Output + /// Set my kid mode status + /// + /// Set the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `POST /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/post(accountKidPost)`. + func accountKidPost(_ input: Operations.accountKidPost.Input) async throws -> Operations.accountKidPost.Output + /// Get my timeline + /// + /// Get the timeline events of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/timeline`. + /// - Remark: Generated from `#/paths//api/timeline/get(timeline)`. + func timeline(_ input: Operations.timeline.Input) async throws -> Operations.timeline.Output + /// Export one game + /// + /// Download one game in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /game/export/{gameId}`. + /// - Remark: Generated from `#/paths//game/export/{gameId}/get(gamePgn)`. + func gamePgn(_ input: Operations.gamePgn.Input) async throws -> Operations.gamePgn.Output + /// Export ongoing game of a user + /// + /// Download the ongoing game, or the last game played, of a user. + /// Available in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/current-game`. + /// - Remark: Generated from `#/paths//api/user/{username}/current-game/get(apiUserCurrentGame)`. + func apiUserCurrentGame(_ input: Operations.apiUserCurrentGame.Input) async throws -> Operations.apiUserCurrentGame.Output + /// Export games of a user + /// + /// Download all games of any user in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// We recommend streaming the response, for it can be very long. + /// <https://lichess.org/@/german11> for instance has more than 500,000 games. + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// - Authenticated, downloading your own games: 60 games per second + /// + /// + /// - Remark: HTTP `GET /api/games/user/{username}`. + /// - Remark: Generated from `#/paths//api/games/user/{username}/get(apiGamesUser)`. + func apiGamesUser(_ input: Operations.apiGamesUser.Input) async throws -> Operations.apiGamesUser.Output + /// Export games by IDs + /// + /// Download games by IDs in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// Games are sorted by reverse chronological order (most recent first) + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// 300 IDs can be submitted. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `POST /api/games/export/_ids`. + /// - Remark: Generated from `#/paths//api/games/export/_ids/post(gamesExportIds)`. + func gamesExportIds(_ input: Operations.gamesExportIds.Input) async throws -> Operations.gamesExportIds.Output + /// Stream games of users + /// + /// Stream the games played between a list of users, in real time. + /// Only games where **both players** are part of the list are included. + /// The stream emits an event each time a game is started or finished. + /// To also get all current ongoing games at the beginning of the stream, use the `withCurrentGames` flag. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of users: 300. + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/stream/games-by-users`. + /// - Remark: Generated from `#/paths//api/stream/games-by-users/post(gamesByUsers)`. + func gamesByUsers(_ input: Operations.gamesByUsers.Input) async throws -> Operations.gamesByUsers.Output + /// Stream games by IDs + /// + /// Creates a stream of games from an arbitrary streamId, and a list of game IDs. + /// The stream first outputs the games that already exists, then emits an event each time a game is started or finished. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of games: 500 for anonymous requests, or 1000 for [OAuth2 authenticated](#section/Introduction/Authentication) requests. + /// While the stream is open, it is possible to [add new game IDs to watch](#operation/gamesByIdsAdd). + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/post(gamesByIds)`. + func gamesByIds(_ input: Operations.gamesByIds.Input) async throws -> Operations.gamesByIds.Output + /// Add game IDs to stream + /// + /// Add new game IDs for [an existing stream](#operation/gamesByIds) to watch. + /// The stream will immediately outputs the games that already exists, then emit an event each time a game is started or finished. + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}/add`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/add/post(gamesByIdsAdd)`. + func gamesByIdsAdd(_ input: Operations.gamesByIdsAdd.Input) async throws -> Operations.gamesByIdsAdd.Output + /// Get my ongoing games + /// + /// Get the ongoing games of the current user. + /// Real-time and correspondence games are included. + /// The most urgent games are listed first. + /// + /// + /// - Remark: HTTP `GET /api/account/playing`. + /// - Remark: Generated from `#/paths//api/account/playing/get(apiAccountPlaying)`. + func apiAccountPlaying(_ input: Operations.apiAccountPlaying.Input) async throws -> Operations.apiAccountPlaying.Output + /// Stream moves of a game + /// + /// Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A description of the game is sent as a first message. + /// Then a message is sent each time a move is played. + /// Finally a description of the game is sent when it finishes, and the stream is closed. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// No more than 8 game streams can be opened at the same time from the same IP address. + /// + /// + /// - Remark: HTTP `GET /api/stream/game/{id}`. + /// - Remark: Generated from `#/paths//api/stream/game/{id}/get(streamGame)`. + func streamGame(_ input: Operations.streamGame.Input) async throws -> Operations.streamGame.Output + /// Import one game + /// + /// Import a game from PGN. See <https://lichess.org/paste>. + /// Rate limiting: 200 games per hour for OAuth requests, 100 games per hour for anonymous requests. + /// To broadcast ongoing games, consider [pushing to a broadcast instead](#operation/broadcastPush). + /// To analyse a position or a line, just construct an analysis board URL: + /// [https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+](https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+) + /// + /// + /// - Remark: HTTP `POST /api/import`. + /// - Remark: Generated from `#/paths//api/import/post(gameImport)`. + func gameImport(_ input: Operations.gameImport.Input) async throws -> Operations.gameImport.Output + /// Export your imported games + /// + /// Download all games imported by you. Games are exported in PGN format. + /// + /// - Remark: HTTP `GET /api/games/export/imports`. + /// - Remark: Generated from `#/paths//api/games/export/imports/get(apiImportedGamesUser)`. + func apiImportedGamesUser(_ input: Operations.apiImportedGamesUser.Input) async throws -> Operations.apiImportedGamesUser.Output + /// Get current TV games + /// + /// Get basic info about the best games being played for each speed and variant, + /// but also computer games and bot games. + /// See [lichess.org/tv](https://lichess.org/tv). + /// + /// + /// - Remark: HTTP `GET /api/tv/channels`. + /// - Remark: Generated from `#/paths//api/tv/channels/get(tvChannels)`. + func tvChannels(_ input: Operations.tvChannels.Input) async throws -> Operations.tvChannels.Output + /// Stream current TV game + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/feed`. + /// - Remark: Generated from `#/paths//api/tv/feed/get(tvFeed)`. + func tvFeed(_ input: Operations.tvFeed.Input) async throws -> Operations.tvFeed.Output + /// Stream current TV game of a TV channel + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) of a TV channel in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/rapid/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}/feed`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/feed/get(tvChannelFeed)`. + func tvChannelFeed(_ input: Operations.tvChannelFeed.Input) async throws -> Operations.tvChannelFeed.Output + /// Get best ongoing games of a TV channel + /// + /// Get a list of ongoing games for a given TV channel. Similar to [lichess.org/games](https://lichess.org/games). + /// Available in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/get(tvChannelGames)`. + func tvChannelGames(_ input: Operations.tvChannelGames.Input) async throws -> Operations.tvChannelGames.Output + /// Get current tournaments + /// + /// Get recently finished, ongoing, and upcoming tournaments. + /// This API is used to display the [Lichess tournament schedule](https://lichess.org/tournament). + /// + /// + /// - Remark: HTTP `GET /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/get(apiTournament)`. + func apiTournament(_ input: Operations.apiTournament.Input) async throws -> Operations.apiTournament.Output + /// Create a new Arena tournament + /// + /// Create a public or private Arena tournament. + /// This endpoint mirrors the form on <https://lichess.org/tournament/new>. + /// You can create up to 12 public tournaments per day, or 24 private tournaments. + /// A team battle can be created by specifying the `teamBattleByTeam` argument. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)`. + func apiTournamentPost(_ input: Operations.apiTournamentPost.Input) async throws -> Operations.apiTournamentPost.Output + /// Get info about an Arena tournament + /// + /// Get detailed info about recently finished, current, or upcoming tournament's duels, player standings, and other info. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/get(tournament)`. + func tournament(_ input: Operations.tournament.Input) async throws -> Operations.tournament.Output + /// Update an Arena tournament + /// + /// Update an Arena tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Can be used to update a team battle. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)`. + func apiTournamentUpdate(_ input: Operations.apiTournamentUpdate.Input) async throws -> Operations.apiTournamentUpdate.Output + /// Join an Arena tournament + /// + /// Join an Arena tournament, possibly with a password and/or a team. + /// Also unpauses if you had previously [paused](#operation/apiTournamentWithdraw) the tournament. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/join`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)`. + func apiTournamentJoin(_ input: Operations.apiTournamentJoin.Input) async throws -> Operations.apiTournamentJoin.Output + /// Pause or leave an Arena tournament + /// + /// Leave a future Arena tournament, or take a break on an ongoing Arena tournament. + /// It's possible to join again later. Points and streaks are preserved. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)`. + func apiTournamentWithdraw(_ input: Operations.apiTournamentWithdraw.Input) async throws -> Operations.apiTournamentWithdraw.Output + /// Terminate an Arena tournament + /// + /// Terminate an Arena tournament + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)`. + func apiTournamentTerminate(_ input: Operations.apiTournamentTerminate.Input) async throws -> Operations.apiTournamentTerminate.Output + /// Update a team battle + /// + /// Set the teams and number of leaders of a team battle. + /// To update the other attributes of a team battle, use the [tournament update endpoint](#operation/apiTournamentUpdate). + /// + /// + /// - Remark: HTTP `POST /api/tournament/team-battle/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)`. + func apiTournamentTeamBattlePost(_ input: Operations.apiTournamentTeamBattlePost.Input) async throws -> Operations.apiTournamentTeamBattlePost.Output + /// Export games of an Arena tournament + /// + /// Download games of a tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/games`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/games/get(gamesByTournament)`. + func gamesByTournament(_ input: Operations.gamesByTournament.Input) async throws -> Operations.gamesByTournament.Output + /// Get results of an Arena tournament + /// + /// Players of an Arena tournament, with their score and performance, sorted by rank (best first). + /// **Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON)**, i.e. one JSON object per line. + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/results`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/results/get(resultsByTournament)`. + func resultsByTournament(_ input: Operations.resultsByTournament.Input) async throws -> Operations.resultsByTournament.Output + /// Get team standing of a team battle + /// + /// Teams of a team battle tournament, with top players, sorted by rank (best first). + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/teams`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/teams/get(teamsByTournament)`. + func teamsByTournament(_ input: Operations.teamsByTournament.Input) async throws -> Operations.teamsByTournament.Output + /// Get tournaments created by a user + /// + /// Get all tournaments created by a given user. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/tournament/created`. + /// - Remark: Generated from `#/paths//api/user/{username}/tournament/created/get(apiUserNameTournamentCreated)`. + func apiUserNameTournamentCreated(_ input: Operations.apiUserNameTournamentCreated.Input) async throws -> Operations.apiUserNameTournamentCreated.Output + /// Create a new Swiss tournament + /// + /// Create a Swiss tournament for your team. + /// This endpoint mirrors the Swiss tournament form from your team pagee. + /// You can create up to 12 tournaments per day. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/new/{teamId}`. + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)`. + func apiSwissNew(_ input: Operations.apiSwissNew.Input) async throws -> Operations.apiSwissNew.Output + /// Get info about a Swiss tournament + /// + /// Get detailed info about a Swiss tournament. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/get(swiss)`. + func swiss(_ input: Operations.swiss.Input) async throws -> Operations.swiss.Output + /// Update a Swiss tournament + /// + /// Update a Swiss tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/edit`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)`. + func apiSwissUpdate(_ input: Operations.apiSwissUpdate.Input) async throws -> Operations.apiSwissUpdate.Output + /// Manually schedule the next round + /// + /// Manually schedule the next round date and time of a Swiss tournament. + /// This sets the `roundInterval` field to `99999999`, i.e. manual scheduling. + /// All further rounds will need to be manually scheduled, unless the `roundInterval` field is changed back to automatic scheduling. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/schedule-next-round`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)`. + func apiSwissScheduleNextRound(_ input: Operations.apiSwissScheduleNextRound.Input) async throws -> Operations.apiSwissScheduleNextRound.Output + /// Join a Swiss tournament + /// + /// Join a Swiss tournament, possibly with a password. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/join`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)`. + func apiSwissJoin(_ input: Operations.apiSwissJoin.Input) async throws -> Operations.apiSwissJoin.Output + /// Pause or leave a swiss tournament + /// + /// Leave a future Swiss tournament, or take a break on an ongoing Swiss tournament. + /// It's possible to join again later. Points are preserved. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/withdraw/post(apiSwissWithdraw)`. + func apiSwissWithdraw(_ input: Operations.apiSwissWithdraw.Input) async throws -> Operations.apiSwissWithdraw.Output + /// Terminate a Swiss tournament + /// + /// Terminate a Swiss tournament + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)`. + func apiSwissTerminate(_ input: Operations.apiSwissTerminate.Input) async throws -> Operations.apiSwissTerminate.Output + /// Export TRF of a Swiss tournament + /// + /// Download a tournament in the Tournament Report File format, the FIDE standard. + /// Documentation: <https://www.fide.com/FIDE/handbook/C04Annex2_TRF16.pdf> + /// Example: <https://lichess.org/swiss/j8rtJ5GL.trf> + /// + /// + /// - Remark: HTTP `GET /swiss/{id}.trf`. + /// - Remark: Generated from `#/paths//swiss/{id}.trf/get(swissTrf)`. + func swissTrf(_ input: Operations.swissTrf.Input) async throws -> Operations.swissTrf.Output + /// Export games of a Swiss tournament + /// + /// Download games of a swiss tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (last round first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/games`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/games/get(gamesBySwiss)`. + func gamesBySwiss(_ input: Operations.gamesBySwiss.Input) async throws -> Operations.gamesBySwiss.Output + /// Get results of a swiss tournament + /// + /// Players of a swiss tournament, with their score and performance, sorted by rank (best first). + /// Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/results`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/results/get(resultsBySwiss)`. + func resultsBySwiss(_ input: Operations.resultsBySwiss.Input) async throws -> Operations.resultsBySwiss.Output + /// Get team swiss tournaments + /// + /// Get all swiss tournaments of a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/swiss`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/swiss/get(apiTeamSwiss)`. + func apiTeamSwiss(_ input: Operations.apiTeamSwiss.Input) async throws -> Operations.apiTeamSwiss.Output + /// Export one study chapter + /// + /// Download one study chapter in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}/{chapterId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}.pgn/get(studyChapterPgn)`. + func studyChapterPgn(_ input: Operations.studyChapterPgn.Input) async throws -> Operations.studyChapterPgn.Output + /// Export all chapters + /// + /// Download all chapters of a study in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/get(studyAllChaptersPgn)`. + func studyAllChaptersPgn(_ input: Operations.studyAllChaptersPgn.Input) async throws -> Operations.studyAllChaptersPgn.Output + /// Study metadata + /// + /// Only get the study headers, including `Last-Modified`. + /// + /// + /// - Remark: HTTP `HEAD /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/head(studyAllChaptersHead)`. + func studyAllChaptersHead(_ input: Operations.studyAllChaptersHead.Input) async throws -> Operations.studyAllChaptersHead.Output + /// Import PGN into a study + /// + /// Imports arbitrary PGN into an existing [study](https://lichess.org/study). Creates a new chapter in the study. + /// If the PGN contains multiple games (separated by 2 or more newlines) + /// then multiple chapters will be created within the study. + /// Note that a study can contain at most 64 chapters. + /// + /// + /// - Remark: HTTP `POST /api/study/{studyId}/import-pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)`. + func apiStudyImportPGN(_ input: Operations.apiStudyImportPGN.Input) async throws -> Operations.apiStudyImportPGN.Output + /// Export all studies of a user + /// + /// Download all chapters of all studies of a user in PGN format. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// + /// + /// - Remark: HTTP `GET /study/by/{username}/export.pgn`. + /// - Remark: Generated from `#/paths//study/by/{username}/export.pgn/get(studyExportAllPgn)`. + func studyExportAllPgn(_ input: Operations.studyExportAllPgn.Input) async throws -> Operations.studyExportAllPgn.Output + /// List studies of a user + /// + /// Get metadata (name and dates) of all studies of a user. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// Studies are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/study/by/{username}`. + /// - Remark: Generated from `#/paths//api/study/by/{username}/get(studyListMetadata)`. + func studyListMetadata(_ input: Operations.studyListMetadata.Input) async throws -> Operations.studyListMetadata.Output + /// Delete a study chapter + /// + /// Delete a chapter of a study you own. This is definitive. + /// A study must have at least one chapter; so if you delete the last chapter, + /// an empty one will be automatically created to replace it. + /// + /// + /// - Remark: HTTP `DELETE /api/study/{studyId}/{chapterId}`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}/delete(apiStudyStudyIdChapterIdDelete)`. + func apiStudyStudyIdChapterIdDelete(_ input: Operations.apiStudyStudyIdChapterIdDelete.Input) async throws -> Operations.apiStudyStudyIdChapterIdDelete.Output + /// Get official broadcasts + /// + /// Get all incoming, ongoing, and finished official broadcasts. + /// The broadcasts are sorted by start date, most recent first. + /// Broadcasts are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/broadcast`. + /// - Remark: Generated from `#/paths//api/broadcast/get(broadcastIndex)`. + func broadcastIndex(_ input: Operations.broadcastIndex.Input) async throws -> Operations.broadcastIndex.Output + /// Create a broadcast tournament + /// + /// Create a new broadcast tournament to relay external games. + /// This endpoint accepts the same form data as the [web form](https://lichess.org/broadcast/new). + /// + /// + /// - Remark: HTTP `POST /broadcast/new`. + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)`. + func broadcastTourCreate(_ input: Operations.broadcastTourCreate.Input) async throws -> Operations.broadcastTourCreate.Output + /// Get a broadcast tournament + /// + /// Get information about a broadcast tournament. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}/get(broadcastTourGet)`. + func broadcastTourGet(_ input: Operations.broadcastTourGet.Input) async throws -> Operations.broadcastTourGet.Output + /// Get a broadcast leaderboard + /// + /// Get the leaderboard of a broadcast tournament, if available. + /// + /// + /// - Remark: HTTP `GET /broadcast/{broadcastTournamentId}/leaderboard`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/leaderboard/get(broadcastLeaderboardGet)`. + func broadcastLeaderboardGet(_ input: Operations.broadcastLeaderboardGet.Input) async throws -> Operations.broadcastLeaderboardGet.Output + /// Update your broadcast tournament + /// + /// Update information about a broadcast tournament that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)`. + func broadcastTourUpdate(_ input: Operations.broadcastTourUpdate.Input) async throws -> Operations.broadcastTourUpdate.Output + /// Create a broadcast round + /// + /// Create a new broadcast round to relay external games. + /// This endpoint accepts the same form data as the web form. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/new`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)`. + func broadcastRoundCreate(_ input: Operations.broadcastRoundCreate.Input) async throws -> Operations.broadcastRoundCreate.Output + /// Get a broadcast round + /// + /// Get information about a broadcast round. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/get(broadcastRoundGet)`. + func broadcastRoundGet(_ input: Operations.broadcastRoundGet.Input) async throws -> Operations.broadcastRoundGet.Output + /// Update your broadcast round + /// + /// Update information about a broadcast round that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// For instance, if you omit `startDate`, then any pre-existing start date will be removed. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)`. + func broadcastRoundUpdate(_ input: Operations.broadcastRoundUpdate.Input) async throws -> Operations.broadcastRoundUpdate.Output + /// Push PGN to your broadcast round + /// + /// Update your broadcast with new PGN. + /// Only for broadcast without a source URL. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/push`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)`. + func broadcastPush(_ input: Operations.broadcastPush.Input) async throws -> Operations.broadcastPush.Output + /// Stream an ongoing broadcast tournament as PGN + /// + /// This streaming endpoint first sends all games of a broadcast tournament in PGN format. + /// Then, it waits for new moves to be played. As soon as it happens, the entire PGN of the game is sent to the stream. + /// The stream will also send PGNs when games are added to the tournament. + /// This is the best way to get updates about an ongoing tournament. Streaming means no polling, + /// and no pollings means no latency, and minimum impact on the server. + /// + /// + /// - Remark: HTTP `GET /api/stream/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/stream/broadcast/round/{broadcastRoundId}.pgn/get(broadcastStreamRoundPgn)`. + func broadcastStreamRoundPgn(_ input: Operations.broadcastStreamRoundPgn.Input) async throws -> Operations.broadcastStreamRoundPgn.Output + /// Export one round as PGN + /// + /// Download all games of a single round of a broadcast tournament in PGN format. + /// You *could* poll this endpoint to get updates about a tournament, but it would be slow, + /// and very inefficient. + /// Instead, consider [streaming the tournament](#operation/broadcastStreamRoundPgn) to get + /// a new PGN every time a game is updated, in real-time. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/round/{broadcastRoundId}.pgn/get(broadcastRoundPgn)`. + func broadcastRoundPgn(_ input: Operations.broadcastRoundPgn.Input) async throws -> Operations.broadcastRoundPgn.Output + /// Export all rounds as PGN + /// + /// Download all games of all rounds of a broadcast in PGN format. + /// If a `study:read` [OAuth token](#tag/OAuth) is provided, + /// the private rounds where the user is a contributor will be available. + /// You may want to [download only the games of a single round](#operation/broadcastRoundPgn) instead. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}.pgn/get(broadcastAllRoundsPgn)`. + func broadcastAllRoundsPgn(_ input: Operations.broadcastAllRoundsPgn.Input) async throws -> Operations.broadcastAllRoundsPgn.Output + /// Get your broadcast rounds + /// + /// Stream all broadcast rounds you are a member of. + /// Also includes broadcasts rounds you did not create, but were invited to. + /// Also includes broadcasts rounds where you're a non-writing member. See the `writeable` flag in the response. + /// Rounds are ordered by rank, which is roughly chronological, most recent first, slightly pondered with popularity. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/my-rounds`. + /// - Remark: Generated from `#/paths//api/broadcast/my-rounds/get(broadcastMyRoundsGet)`. + func broadcastMyRoundsGet(_ input: Operations.broadcastMyRoundsGet.Input) async throws -> Operations.broadcastMyRoundsGet.Output + /// Get current simuls + /// + /// Get recently created, started, finished, simuls. + /// Created and finished simul lists are not exhaustives, only those with + /// strong enough host will be listed, the same filter is used to display simuls on https://lichess.org/simul. + /// When [authenticated with OAuth2](#section/Introduction/Authentication), the pending list will be populated with your created, but unstarted simuls. + /// + /// + /// - Remark: HTTP `GET /api/simul`. + /// - Remark: Generated from `#/paths//api/simul/get(apiSimul)`. + func apiSimul(_ input: Operations.apiSimul.Input) async throws -> Operations.apiSimul.Output + /// Get a single team + /// + /// Public info about a team. Includes the list of publicly visible leaders. + /// + /// - Remark: HTTP `GET /api/team/{teamId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/get(teamShow)`. + func teamShow(_ input: Operations.teamShow.Input) async throws -> Operations.teamShow.Output + /// Get popular teams + /// + /// Paginator of the most popular teams. + /// + /// + /// - Remark: HTTP `GET /api/team/all`. + /// - Remark: Generated from `#/paths//api/team/all/get(teamAll)`. + func teamAll(_ input: Operations.teamAll.Input) async throws -> Operations.teamAll.Output + /// Teams of a player + /// + /// All the teams a player is a member of. + /// + /// + /// - Remark: HTTP `GET /api/team/of/{username}`. + /// - Remark: Generated from `#/paths//api/team/of/{username}/get(teamOfUsername)`. + func teamOfUsername(_ input: Operations.teamOfUsername.Input) async throws -> Operations.teamOfUsername.Output + /// Search teams + /// + /// Paginator of team search results for a keyword. + /// + /// + /// - Remark: HTTP `GET /api/team/search`. + /// - Remark: Generated from `#/paths//api/team/search/get(teamSearch)`. + func teamSearch(_ input: Operations.teamSearch.Input) async throws -> Operations.teamSearch.Output + /// Get members of a team + /// + /// Members are sorted by reverse chronological order of joining the team (most recent first). + /// OAuth is only required if the list of members is private. + /// Members are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/users`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/users/get(teamIdUsers)`. + func teamIdUsers(_ input: Operations.teamIdUsers.Input) async throws -> Operations.teamIdUsers.Output + /// Get team Arena tournaments + /// + /// Get all Arena tournaments relevant to a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/arena`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/arena/get(apiTeamArena)`. + func apiTeamArena(_ input: Operations.apiTeamArena.Input) async throws -> Operations.apiTeamArena.Output + /// Join a team + /// + /// Join a team. + /// If the team requires a password but the `password` field is incorrect, + /// then the call fails with `403 Forbidden`. + /// Similarly, if the team join policy requires a confirmation but the + /// `message` parameter is not given, then the call fails with + /// `403 Forbidden`. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/join`. + /// - Remark: Generated from `#/paths//team/{teamId}/join/post(teamIdJoin)`. + func teamIdJoin(_ input: Operations.teamIdJoin.Input) async throws -> Operations.teamIdJoin.Output + /// Leave a team + /// + /// Leave a team. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/quit`. + /// - Remark: Generated from `#/paths//team/{teamId}/quit/post(teamIdQuit)`. + func teamIdQuit(_ input: Operations.teamIdQuit.Input) async throws -> Operations.teamIdQuit.Output + /// Get join requests + /// + /// Get pending join requests of your team + /// + /// - Remark: HTTP `GET /api/team/{teamId}/requests`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/requests/get(teamRequests)`. + func teamRequests(_ input: Operations.teamRequests.Input) async throws -> Operations.teamRequests.Output + /// Accept join request + /// + /// Accept someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/accept`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/accept/post(teamRequestAccept)`. + func teamRequestAccept(_ input: Operations.teamRequestAccept.Input) async throws -> Operations.teamRequestAccept.Output + /// Decline join request + /// + /// Decline someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/decline`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/decline/post(teamRequestDecline)`. + func teamRequestDecline(_ input: Operations.teamRequestDecline.Input) async throws -> Operations.teamRequestDecline.Output + /// Kick a user from your team + /// + /// Kick a member out of one of your teams. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /api/team/{teamId}/kick/{userId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/kick/{userId}/post(teamIdKickUserId)`. + func teamIdKickUserId(_ input: Operations.teamIdKickUserId.Input) async throws -> Operations.teamIdKickUserId.Output + /// Message all members + /// + /// Send a private message to all members of a team. + /// You must be a team leader with the "Messages" permission. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/pm-all`. + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)`. + func teamIdPmAll(_ input: Operations.teamIdPmAll.Input) async throws -> Operations.teamIdPmAll.Output + /// Get live streamers + /// + /// Get basic info about currently streaming users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// + /// + /// - Remark: HTTP `GET /api/streamer/live`. + /// - Remark: Generated from `#/paths//api/streamer/live/get(streamerLive)`. + func streamerLive(_ input: Operations.streamerLive.Input) async throws -> Operations.streamerLive.Output + /// Get crosstable + /// + /// Get total number of games, and current score, of any two users. + /// If the `matchup` flag is provided, and the users are currently playing, also gets the current match game number and scores. + /// + /// + /// - Remark: HTTP `GET /api/crosstable/{user1}/{user2}`. + /// - Remark: Generated from `#/paths//api/crosstable/{user1}/{user2}/get(apiCrosstable)`. + func apiCrosstable(_ input: Operations.apiCrosstable.Input) async throws -> Operations.apiCrosstable.Output + /// Autocomplete usernames + /// + /// Provides autocompletion options for an incomplete username. + /// + /// + /// - Remark: HTTP `GET /api/player/autocomplete`. + /// - Remark: Generated from `#/paths//api/player/autocomplete/get(apiPlayerAutocomplete)`. + func apiPlayerAutocomplete(_ input: Operations.apiPlayerAutocomplete.Input) async throws -> Operations.apiPlayerAutocomplete.Output + /// Get notes for a user + /// + /// Get the private notes that you have added for a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/get(readNote)`. + func readNote(_ input: Operations.readNote.Input) async throws -> Operations.readNote.Output + /// Add a note for a user + /// + /// Add a private note available only to you about this account. + /// + /// + /// - Remark: HTTP `POST /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/post(writeNote)`. + func writeNote(_ input: Operations.writeNote.Input) async throws -> Operations.writeNote.Output + /// Get users followed by the logged in user + /// + /// Users are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/rel/following`. + /// - Remark: Generated from `#/paths//api/rel/following/get(apiUserFollowing)`. + func apiUserFollowing(_ input: Operations.apiUserFollowing.Input) async throws -> Operations.apiUserFollowing.Output + /// Follow a player + /// + /// Follow a player, adding them to your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/follow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/follow/{username}/post(followUser)`. + func followUser(_ input: Operations.followUser.Input) async throws -> Operations.followUser.Output + /// Unfollow a player + /// + /// Unfollow a player, removing them from your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/unfollow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/unfollow/{username}/post(unfollowUser)`. + func unfollowUser(_ input: Operations.unfollowUser.Input) async throws -> Operations.unfollowUser.Output + /// Stream incoming events + /// + /// + /// Stream the events reaching a lichess user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// An empty line is sent every 6 seconds for keep alive purposes. + /// + /// Each non-empty line is a JSON object containing a `type` field. Possible values are: + /// - `gameStart` Start of a game + /// - `gameFinish` Completion of a game + /// - `challenge` A player sends you a challenge or you challenge someone + /// - `challengeCanceled` A player cancels their challenge to you + /// - `challengeDeclined` The opponent declines your challenge + /// + /// When the stream opens, all current challenges and games are sent. + /// + /// - Remark: HTTP `GET /api/stream/event`. + /// - Remark: Generated from `#/paths//api/stream/event/get(apiStreamEvent)`. + func apiStreamEvent(_ input: Operations.apiStreamEvent.Input) async throws -> Operations.apiStreamEvent.Output + /// Create a seek + /// + /// + /// Create a public seek, to start a game with a random player. + /// + /// ### Real-time seek + /// + /// Specify the `time` and `increment` clock values. The response is streamed but doesn't contain any information. + /// + /// **Keep the connection open to keep the seek active**. + /// + /// If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. + /// When the seek is accepted, or expires, the server closes the connection. + /// + /// **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. + /// We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, + /// you won't miss the game event if the seek is accepted immediately. + /// + /// ### Correspondence seek + /// + /// Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone. + /// + /// - Remark: HTTP `POST /api/board/seek`. + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)`. + func apiBoardSeek(_ input: Operations.apiBoardSeek.Input) async throws -> Operations.apiBoardSeek.Output + /// Stream Board game state + /// + /// Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, a draw is offered, or when the game ends. + /// - `chatLine` Chat message sent by a user in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// + /// The server closes the stream when the game ends, or if the game has already ended. + /// + /// - Remark: HTTP `GET /api/board/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)`. + func boardGameStream(_ input: Operations.boardGameStream.Input) async throws -> Operations.boardGameStream.Output + /// Make a Board move + /// + /// Make a move in a game being played with the Board API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)`. + func boardGameMove(_ input: Operations.boardGameMove.Input) async throws -> Operations.boardGameMove.Output + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/get(boardGameChatGet)`. + func boardGameChatGet(_ input: Operations.boardGameChatGet.Input) async throws -> Operations.boardGameChatGet.Output + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)`. + func boardGameChatPost(_ input: Operations.boardGameChatPost.Input) async throws -> Operations.boardGameChatPost.Output + /// Abort a game + /// + /// Abort a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)`. + func boardGameAbort(_ input: Operations.boardGameAbort.Input) async throws -> Operations.boardGameAbort.Output + /// Resign a game + /// + /// Resign a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)`. + func boardGameResign(_ input: Operations.boardGameResign.Input) async throws -> Operations.boardGameResign.Output + /// Handle draw offers + /// + /// Create/accept/decline draw offers. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)`. + func boardGameDraw(_ input: Operations.boardGameDraw.Input) async throws -> Operations.boardGameDraw.Output + /// Handle takeback offers + /// + /// Create/accept/decline takebacks. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)`. + func boardGameTakeback(_ input: Operations.boardGameTakeback.Input) async throws -> Operations.boardGameTakeback.Output + /// Claim victory of a game + /// + /// Claim victory when the opponent has left the game for a while. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/claim-victory`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)`. + func boardGameClaimVictory(_ input: Operations.boardGameClaimVictory.Input) async throws -> Operations.boardGameClaimVictory.Output + /// Berserk a tournament game + /// + /// Go berserk on an arena tournament game. Halves the clock time, grants an extra point upon winning. + /// Only available in arena tournaments that allow berserk, and before each player has made a move. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/berserk`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)`. + func boardGameBerserk(_ input: Operations.boardGameBerserk.Input) async throws -> Operations.boardGameBerserk.Output + /// Get online bots + /// + /// Stream the [online bot users](https://lichess.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second. + /// + /// - Remark: HTTP `GET /api/bot/online`. + /// - Remark: Generated from `#/paths//api/bot/online/get(apiBotOnline)`. + func apiBotOnline(_ input: Operations.apiBotOnline.Input) async throws -> Operations.apiBotOnline.Output + /// Upgrade to Bot account + /// + /// Upgrade a lichess player account into a Bot account. Only Bot accounts can use the Bot API. + /// The account **cannot have played any game** before becoming a Bot account. The upgrade is **irreversible**. The account will only be able to play as a Bot. + /// To upgrade an account to Bot, use the [official lichess-bot client](https://github.com/lichess-bot-devs/lichess-bot), or follow these steps: + /// - Create an [API access token](https://lichess.org/account/oauth/token/create?scopes[]=bot:play) with "Play bot moves" permission. + /// - `curl -d '' https://lichess.org/api/bot/account/upgrade -H "Authorization: Bearer <yourTokenHere>"` + /// To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): + /// the `title` field should be set to `BOT`. + /// + /// + /// - Remark: HTTP `POST /api/bot/account/upgrade`. + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)`. + func botAccountUpgrade(_ input: Operations.botAccountUpgrade.Input) async throws -> Operations.botAccountUpgrade.Output + /// Stream Bot game state + /// + /// Stream the state of a game being played with the Bot API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. + /// - `chatLine` Chat message sent by a user (or the bot itself) in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// - Remark: HTTP `GET /api/bot/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)`. + func botGameStream(_ input: Operations.botGameStream.Input) async throws -> Operations.botGameStream.Output + /// Make a Bot move + /// + /// Make a move in a game being played with the Bot API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)`. + func botGameMove(_ input: Operations.botGameMove.Input) async throws -> Operations.botGameMove.Output + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/get(botGameChatGet)`. + func botGameChatGet(_ input: Operations.botGameChatGet.Input) async throws -> Operations.botGameChatGet.Output + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)`. + func botGameChat(_ input: Operations.botGameChat.Input) async throws -> Operations.botGameChat.Output + /// Abort a game + /// + /// Abort a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)`. + func botGameAbort(_ input: Operations.botGameAbort.Input) async throws -> Operations.botGameAbort.Output + /// Resign a game + /// + /// Resign a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)`. + func botGameResign(_ input: Operations.botGameResign.Input) async throws -> Operations.botGameResign.Output + /// Handle draw offers + /// + /// Create/accept/decline draw offers with the Bot API. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)`. + func botGameDraw(_ input: Operations.botGameDraw.Input) async throws -> Operations.botGameDraw.Output + /// Handle takeback offers + /// + /// Create/accept/decline takebacks with the Bot API. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)`. + func botGameTakeback(_ input: Operations.botGameTakeback.Input) async throws -> Operations.botGameTakeback.Output + /// List your challenges + /// + /// Get a list of challenges created by or targeted at you. + /// + /// + /// - Remark: HTTP `GET /api/challenge`. + /// - Remark: Generated from `#/paths//api/challenge/get(challengeList)`. + func challengeList(_ input: Operations.challengeList.Input) async throws -> Operations.challengeList.Output + /// Create a challenge + /// + /// Challenge someone to play. The targeted player can choose to accept or decline. + /// If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) + /// that a new game has started. The game ID will be the same as the challenge ID. + /// Challenges for realtime games (not correspondence) expire after 20s if not accepted. + /// To prevent that, use the `keepAliveStream` flag described below. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{username}`. + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)`. + func challengeCreate(_ input: Operations.challengeCreate.Input) async throws -> Operations.challengeCreate.Output + /// Accept a challenge + /// + /// Accept an incoming challenge. + /// You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent). + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/accept`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)`. + func challengeAccept(_ input: Operations.challengeAccept.Input) async throws -> Operations.challengeAccept.Output + /// Decline a challenge + /// + /// Decline an incoming challenge. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/decline`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)`. + func challengeDecline(_ input: Operations.challengeDecline.Input) async throws -> Operations.challengeDecline.Output + /// Cancel a challenge + /// + /// Cancel a challenge you sent, or aborts the game if the challenge was accepted, but the game was not yet played. + /// Note that the ID of a game is the same as the ID of the challenge that created it. + /// Works for user challenges and open challenges alike. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/cancel`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)`. + func challengeCancel(_ input: Operations.challengeCancel.Input) async throws -> Operations.challengeCancel.Output + /// Challenge the AI + /// + /// Start a game with Lichess AI. + /// You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. + /// + /// + /// - Remark: HTTP `POST /api/challenge/ai`. + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)`. + func challengeAi(_ input: Operations.challengeAi.Input) async throws -> Operations.challengeAi.Output + /// Open-ended challenge + /// + /// Create a challenge that any 2 players can join. + /// Share the URL of the challenge. the first 2 players to click it will be paired for a game. + /// The response body also contains `whiteUrl` and `blackUrl`. + /// You can control which color each player gets by giving them these URLs, + /// instead of the main challenge URL. + /// Open challenges expire after 24h. + /// If the challenge creation is [authenticated with OAuth2](#section/Introduction/Authentication), + /// then you can use the [challenge cancel endpoint](#operation/challengeCancel) to cancel it. + /// To directly pair 2 known players, use [this endpoint](#operation/bulkPairingList) instead. + /// + /// + /// - Remark: HTTP `POST /api/challenge/open`. + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)`. + func challengeOpen(_ input: Operations.challengeOpen.Input) async throws -> Operations.challengeOpen.Output + /// Start clocks of a game + /// + /// Start the clocks of a game immediately, even if a player has not yet made a move. + /// Requires the OAuth tokens of both players with `challenge:write` scope. + /// If the clocks have already started, the call will have no effect. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{gameId}/start-clocks`. + /// - Remark: Generated from `#/paths//api/challenge/{gameId}/start-clocks/post(challengeStartClocks)`. + func challengeStartClocks(_ input: Operations.challengeStartClocks.Input) async throws -> Operations.challengeStartClocks.Output + /// View your bulk pairings + /// + /// Get a list of bulk pairings you created. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/get(bulkPairingList)`. + func bulkPairingList(_ input: Operations.bulkPairingList.Input) async throws -> Operations.bulkPairingList.Output + /// Create a bulk pairing + /// + /// Schedule many games at once, up to 24h in advance. + /// OAuth tokens are required for all paired players, with the `challenge:write` scope. + /// You can schedule up to 500 games every 10 minutes. [Contact us](mailto:contact@lichess.org) if you need higher limits. + /// If games have a real-time clock, each player must have only one pairing. + /// For correspondence games, players can have multiple pairings within the same bulk. + /// The entire bulk is rejected if: + /// - a token is missing + /// - a token is present more than once (except in correspondence) + /// - a token lacks the `challenge:write` scope + /// - a player account is closed + /// - a player is paired more than once (except in correspondence) + /// - a bulk is already scheduled to start at the same time with the same player + /// - you have 20 scheduled bulks + /// - you have 1000 scheduled games + /// Partial bulks are never created. Either it all fails, or it all succeeds. + /// When it fails, it does so with an error message explaining the issue. + /// Failed bulks are not counted in the rate limiting, they are free. + /// Fix the issues, manually or programmatically, then retry to schedule the bulk. + /// A successful bulk creation returns a JSON bulk document. Its ID can be used for further operations. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)`. + func bulkPairingCreate(_ input: Operations.bulkPairingCreate.Input) async throws -> Operations.bulkPairingCreate.Output + /// Manually start clocks + /// + /// Immediately start all clocks of the games of a bulk pairing. + /// This overrides the `startClocksAt` value of an existing bulk pairing. + /// If the games have not yet been created (`bulk.pairAt` is in the future), then this does nothing. + /// If the clocks have already started (`bulk.startClocksAt` is in the past), then this does nothing. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing/{id}/start-clocks`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)`. + func bulkPairingStartClocks(_ input: Operations.bulkPairingStartClocks.Input) async throws -> Operations.bulkPairingStartClocks.Output + /// Show a bulk pairing + /// + /// Get a single bulk pairing by its ID. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)`. + func bulkPairingGet(_ input: Operations.bulkPairingGet.Input) async throws -> Operations.bulkPairingGet.Output + /// Cancel a bulk pairing + /// + /// Cancel and delete a bulk pairing that is scheduled in the future. + /// If the games have already been created, then this does nothing. + /// Canceling a bulk pairing does not refund the rate limit cost of that bulk pairing. + /// + /// + /// - Remark: HTTP `DELETE /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)`. + func bulkPairingDelete(_ input: Operations.bulkPairingDelete.Input) async throws -> Operations.bulkPairingDelete.Output + /// Add time to the opponent clock + /// + /// Add seconds to the opponent's clock. Can be used to create games with time odds. + /// + /// + /// - Remark: HTTP `POST /api/round/{gameId}/add-time/{seconds}`. + /// - Remark: Generated from `#/paths//api/round/{gameId}/add-time/{seconds}/post(roundAddTime)`. + func roundAddTime(_ input: Operations.roundAddTime.Input) async throws -> Operations.roundAddTime.Output + /// Admin challenge tokens + /// + /// **This endpoint can only be used by Lichess administrators. It will not work if you do not have the appropriate permissions.** Tournament organizers should instead use [OAuth](#tag/OAuth) to obtain `challenge:write` tokens from users in order to perform bulk pairing.* + /// Create and obtain `challenge:write` tokens for multiple users. + /// If a similar token already exists for a user, it is reused. This endpoint is idempotent. + /// + /// + /// - Remark: HTTP `POST /api/token/admin-challenge`. + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)`. + func adminChallengeTokens(_ input: Operations.adminChallengeTokens.Input) async throws -> Operations.adminChallengeTokens.Output + /// Send a private message + /// + /// Send a private message to another player. + /// + /// + /// - Remark: HTTP `POST /inbox/{username}`. + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)`. + func inboxUsername(_ input: Operations.inboxUsername.Input) async throws -> Operations.inboxUsername.Output + /// Get cloud evaluation of a position. + /// + /// Get the cached evaluation of a position, if available. + /// Opening positions have more chances of being available. There are about 15 million positions in the database. + /// Up to 5 variations may be available. Variants are supported. + /// Use this endpoint to fetch a few positions here and there. + /// If you want to download a lot of positions, [get the full list](https://database.lichess.org/#evals) from our exported database. + /// + /// + /// - Remark: HTTP `GET /api/cloud-eval`. + /// - Remark: Generated from `#/paths//api/cloud-eval/get(apiCloudEval)`. + func apiCloudEval(_ input: Operations.apiCloudEval.Input) async throws -> Operations.apiCloudEval.Output + /// List external engines + /// + /// Lists all external engines that have been registered for the user, + /// and the credentials required to use them. + /// + /// + /// - Remark: HTTP `GET /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/get(apiExternalEngineList)`. + func apiExternalEngineList(_ input: Operations.apiExternalEngineList.Input) async throws -> Operations.apiExternalEngineList.Output + /// Create external engine + /// + /// Registers a new external engine for the user. It can then be selected + /// and used on the analysis board. + /// After registering, the provider should start waiting for analyis requests. + /// + /// + /// - Remark: HTTP `POST /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/post(apiExternalEngineCreate)`. + func apiExternalEngineCreate(_ input: Operations.apiExternalEngineCreate.Input) async throws -> Operations.apiExternalEngineCreate.Output + /// Get external engine + /// + /// Get properties and credentials of an external engine. + /// + /// + /// - Remark: HTTP `GET /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/get(apiExternalEngineGet)`. + func apiExternalEngineGet(_ input: Operations.apiExternalEngineGet.Input) async throws -> Operations.apiExternalEngineGet.Output + /// Update external engine + /// + /// Updates the properties of an external engine. + /// + /// + /// - Remark: HTTP `PUT /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/put(apiExternalEnginePut)`. + func apiExternalEnginePut(_ input: Operations.apiExternalEnginePut.Input) async throws -> Operations.apiExternalEnginePut.Output + /// Delete external engine + /// + /// Unregisters an external engine. + /// + /// + /// - Remark: HTTP `DELETE /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/delete(apiExternalEngineDelete)`. + func apiExternalEngineDelete(_ input: Operations.apiExternalEngineDelete.Input) async throws -> Operations.apiExternalEngineDelete.Output + /// Analyse with external engine + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/{id}/analyse`** + /// Request analysis from an external engine. + /// Response content is streamed as [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). + /// The properties are based on the [UCI specification](https://backscattering.de/chess/uci/#engine). + /// Analysis stops when the client goes away, the requested limit + /// is reached, or the provider goes away. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/{id}/analyse`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/analyse/post(apiExternalEngineAnalyse)`. + func apiExternalEngineAnalyse(_ input: Operations.apiExternalEngineAnalyse.Input) async throws -> Operations.apiExternalEngineAnalyse.Output + /// Acquire analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work`** + /// Wait for an analysis requests to any of the external engines that + /// have been registered with the given `secret`. + /// Uses long polling. + /// After acquiring a request, the provider should immediately + /// [start streaming the results](#tag/External-engine/operation/apiExternalEngineSubmit). + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work`. + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)`. + func apiExternalEngineAcquire(_ input: Operations.apiExternalEngineAcquire.Input) async throws -> Operations.apiExternalEngineAcquire.Output + /// Answer analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work/{id}`** + /// Submit a stream of analysis as [UCI output](https://backscattering.de/chess/uci/#engine-info). + /// * The engine should always be in `UCI_Chess960` mode. + /// * `UCI_AnalyseMode` enabled if available. + /// * It produces `info` with at least: + /// - `depth` + /// - `multipv` (between 1 and 5) + /// - `score` + /// - `nodes` + /// - `time` + /// - `pv` + /// The server may close the connection at any time, indicating that + /// the requester has gone away and analysis should be stopped. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/work/{id}/post(apiExternalEngineSubmit)`. + func apiExternalEngineSubmit(_ input: Operations.apiExternalEngineSubmit.Input) async throws -> Operations.apiExternalEngineSubmit.Output + /// Request authorization code + /// + /// OAuth2 authorization endpoint. + /// Start the OAuth2 Authorization Code Flow with PKCE by securely + /// generating two random strings unique to each authorization + /// request: + /// * `code_verifier` + /// * `state` + /// Store these in session storage. Make sure not to reveal `code_verifier` + /// to eavesdroppers. Do not show it in URLs, do not abuse `state` to store + /// it, do not send it over insecure connections. However it is fine if + /// the user themselves can extract `code_verifier`, which will always be + /// possible for fully client-side apps. + /// Then send the user to this endpoint. They will be prompted to grant + /// authorization and then be redirected back to the given `redirect_uri`. + /// If the authorization failed, the following query string parameters will + /// be appended to the redirection: + /// * `error`, in particular with value `access_denied` if the user + /// cancelled authorization + /// * `error_description` to aid debugging + /// * `state`, exactly as passed in the `state` parameter + /// If the authorization succeeded, the following query string parameters + /// will be appended to the redirection: + /// * `code`, containing a fresh short-lived authorization code + /// * `state`, exactly as passed in the `state` parameter + /// Next, to defend against cross site request forgery, check that the + /// returned `state` matches the `state` you originally generated. + /// Finally, continue by using the authorization code to + /// [obtain an access token](#operation/apiToken). + /// + /// + /// - Remark: HTTP `GET /oauth`. + /// - Remark: Generated from `#/paths//oauth/get(oauth)`. + func oauth(_ input: Operations.oauth.Input) async throws -> Operations.oauth.Output + /// Obtain access token + /// + /// OAuth2 token endpoint. Exchanges an authorization code for an access token. + /// + /// + /// - Remark: HTTP `POST /api/token`. + /// - Remark: Generated from `#/paths//api/token/post(apiToken)`. + func apiToken(_ input: Operations.apiToken.Input) async throws -> Operations.apiToken.Output + /// Revoke access token + /// + /// Revokes the access token sent as Bearer for this request. + /// + /// - Remark: HTTP `DELETE /api/token`. + /// - Remark: Generated from `#/paths//api/token/delete(apiTokenDelete)`. + func apiTokenDelete(_ input: Operations.apiTokenDelete.Input) async throws -> Operations.apiTokenDelete.Output + /// Test multiple OAuth tokens + /// + /// For up to 1000 OAuth tokens, + /// returns their associated user ID and scopes, + /// or `null` if the token is invalid. + /// The method is `POST` so a longer list of tokens can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/token/test`. + /// - Remark: Generated from `#/paths//api/token/test/post(tokenTest)`. + func tokenTest(_ input: Operations.tokenTest.Input) async throws -> Operations.tokenTest.Output + /// Masters database + /// + /// **Endpoint: <https://explorer.lichess.ovh/masters>** + /// Example: `curl https://explorer.lichess.ovh/masters?play=d2d4,d7d5,c2c4,c7c6,c4d5` + /// + /// + /// - Remark: HTTP `GET /masters`. + /// - Remark: Generated from `#/paths//masters/get(openingExplorerMaster)`. + func openingExplorerMaster(_ input: Operations.openingExplorerMaster.Input) async throws -> Operations.openingExplorerMaster.Output + /// Lichess games + /// + /// **Endpoint: <https://explorer.lichess.ovh/lichess>** + /// Games sampled from all Lichess players. + /// Example: `curl https://explorer.lichess.ovh/lichess?variant=standard&speeds=blitz,rapid,classical&ratings=2200,2500&fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201` + /// + /// + /// - Remark: HTTP `GET /lichess`. + /// - Remark: Generated from `#/paths//lichess/get(openingExplorerLichess)`. + func openingExplorerLichess(_ input: Operations.openingExplorerLichess.Input) async throws -> Operations.openingExplorerLichess.Output + /// Player games + /// + /// **Endpoint: <https://explorer.lichess.ovh/player>** + /// Games of a Lichess player. + /// Responds with a stream of [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). Will start indexing + /// on demand, immediately respond with the current results, and stream + /// more updates until indexing is complete. The stream is throttled + /// and deduplicated. Empty lines may be sent to avoid timeouts. + /// Will index new games at most once per minute, and revisit previously + /// ongoing games at most once every day. + /// Example: `curl https://explorer.lichess.ovh/player?player=revoof&color=white&play=d2d4,d7d5&recentGames=1` + /// + /// + /// - Remark: HTTP `GET /player`. + /// - Remark: Generated from `#/paths//player/get(openingExplorerPlayer)`. + func openingExplorerPlayer(_ input: Operations.openingExplorerPlayer.Input) async throws -> Operations.openingExplorerPlayer.Output + /// OTB master game + /// + /// **Endpoint: `https://explorer.lichess.ovh/masters/pgn/{gameId}`** + /// Example: `curl https://explorer.lichess.ovh/masters/pgn/aAbqI4ey` + /// + /// + /// - Remark: HTTP `GET /master/pgn/{gameId}`. + /// - Remark: Generated from `#/paths//master/pgn/{gameId}/get(openingExplorerMasterGame)`. + func openingExplorerMasterGame(_ input: Operations.openingExplorerMasterGame.Input) async throws -> Operations.openingExplorerMasterGame.Output + /// Tablebase lookup + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// Example: `curl http://tablebase.lichess.ovh/standard?fen=4k3/6KP/8/8/8/8/7p/8_w_-_-_0_1` + /// + /// + /// - Remark: HTTP `GET /standard`. + /// - Remark: Generated from `#/paths//standard/get(tablebaseStandard)`. + func tablebaseStandard(_ input: Operations.tablebaseStandard.Input) async throws -> Operations.tablebaseStandard.Output + /// Tablebase lookup for Atomic chess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /atomic`. + /// - Remark: Generated from `#/paths//atomic/get(tablebaseAtomic)`. + func tablebaseAtomic(_ input: Operations.tablebaseAtomic.Input) async throws -> Operations.tablebaseAtomic.Output + /// Tablebase lookup for Antichess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /antichess`. + /// - Remark: Generated from `#/paths//antichess/get(antichessAtomic)`. + func antichessAtomic(_ input: Operations.antichessAtomic.Input) async throws -> Operations.antichessAtomic.Output +} + +/// Convenience overloads for operation inputs. +extension APIProtocol { + /// Get real-time users status + /// + /// Read the `online`, `playing` and `streaming` flags of several users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// Use it to track players and know when they're connected on lichess and playing games. + /// + /// + /// - Remark: HTTP `GET /api/users/status`. + /// - Remark: Generated from `#/paths//api/users/status/get(apiUsersStatus)`. + internal func apiUsersStatus( + query: Operations.apiUsersStatus.Input.Query, + headers: Operations.apiUsersStatus.Input.Headers = .init() + ) async throws -> Operations.apiUsersStatus.Output { + try await apiUsersStatus(Operations.apiUsersStatus.Input( + query: query, + headers: headers + )) + } + /// Get all top 10 + /// + /// Get the top 10 players for each speed and variant. + /// See <https://lichess.org/player>. + /// + /// + /// - Remark: HTTP `GET /api/player`. + /// - Remark: Generated from `#/paths//api/player/get(player)`. + internal func player(headers: Operations.player.Input.Headers = .init()) async throws -> Operations.player.Output { + try await player(Operations.player.Input(headers: headers)) + } + /// Get one leaderboard + /// + /// Get the leaderboard for a single speed or variant (a.k.a. `perfType`). + /// There is no leaderboard for correspondence or puzzles. + /// See <https://lichess.org/player/top/200/bullet>. + /// + /// + /// - Remark: HTTP `GET /api/player/top/{nb}/{perfType}`. + /// - Remark: Generated from `#/paths//api/player/top/{nb}/{perfType}/get(playerTopNbPerfType)`. + internal func playerTopNbPerfType( + path: Operations.playerTopNbPerfType.Input.Path, + headers: Operations.playerTopNbPerfType.Input.Headers = .init() + ) async throws -> Operations.playerTopNbPerfType.Output { + try await playerTopNbPerfType(Operations.playerTopNbPerfType.Input( + path: path, + headers: headers + )) + } + /// Get user public data + /// + /// Read public data of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}`. + /// - Remark: Generated from `#/paths//api/user/{username}/get(apiUser)`. + internal func apiUser( + path: Operations.apiUser.Input.Path, + query: Operations.apiUser.Input.Query = .init(), + headers: Operations.apiUser.Input.Headers = .init() + ) async throws -> Operations.apiUser.Output { + try await apiUser(Operations.apiUser.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get rating history of a user + /// + /// Read rating history of a user, for all perf types. + /// There is at most one entry per day. + /// Format of an entry is `[year, month, day, rating]`. + /// `month` starts at zero (January). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/rating-history`. + /// - Remark: Generated from `#/paths//api/user/{username}/rating-history/get(apiUserRatingHistory)`. + internal func apiUserRatingHistory( + path: Operations.apiUserRatingHistory.Input.Path, + headers: Operations.apiUserRatingHistory.Input.Headers = .init() + ) async throws -> Operations.apiUserRatingHistory.Output { + try await apiUserRatingHistory(Operations.apiUserRatingHistory.Input( + path: path, + headers: headers + )) + } + /// Get performance statistics of a user + /// + /// Read performance statistics of a user, for a single performance. + /// Similar to the [performance pages on the website](https://lichess.org/@/thibault/perf/bullet). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/perf/{perf}`. + /// - Remark: Generated from `#/paths//api/user/{username}/perf/{perf}/get(apiUserPerf)`. + internal func apiUserPerf( + path: Operations.apiUserPerf.Input.Path, + headers: Operations.apiUserPerf.Input.Headers = .init() + ) async throws -> Operations.apiUserPerf.Output { + try await apiUserPerf(Operations.apiUserPerf.Input( + path: path, + headers: headers + )) + } + /// Get user activity + /// + /// Read data to generate the activity feed of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/activity`. + /// - Remark: Generated from `#/paths//api/user/{username}/activity/get(apiUserActivity)`. + internal func apiUserActivity( + path: Operations.apiUserActivity.Input.Path, + headers: Operations.apiUserActivity.Input.Headers = .init() + ) async throws -> Operations.apiUserActivity.Output { + try await apiUserActivity(Operations.apiUserActivity.Input( + path: path, + headers: headers + )) + } + /// Get the daily puzzle + /// + /// Get the daily Lichess puzzle in JSON format. + /// Alternatively, you can [post it in your slack workspace](https://lichess.org/daily-puzzle-slack). + /// + /// + /// - Remark: HTTP `GET /api/puzzle/daily`. + /// - Remark: Generated from `#/paths//api/puzzle/daily/get(apiPuzzleDaily)`. + internal func apiPuzzleDaily(headers: Operations.apiPuzzleDaily.Input.Headers = .init()) async throws -> Operations.apiPuzzleDaily.Output { + try await apiPuzzleDaily(Operations.apiPuzzleDaily.Input(headers: headers)) + } + /// Get a puzzle by its ID + /// + /// Get a single Lichess puzzle in JSON format. + /// + /// - Remark: HTTP `GET /api/puzzle/{id}`. + /// - Remark: Generated from `#/paths//api/puzzle/{id}/get(apiPuzzleId)`. + internal func apiPuzzleId( + path: Operations.apiPuzzleId.Input.Path, + headers: Operations.apiPuzzleId.Input.Headers = .init() + ) async throws -> Operations.apiPuzzleId.Output { + try await apiPuzzleId(Operations.apiPuzzleId.Input( + path: path, + headers: headers + )) + } + /// Get your puzzle activity + /// + /// Download your puzzle activity in [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Puzzle activity is sorted by reverse chronological order (most recent first) + /// We recommend streaming the response, for it can be very long. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/activity`. + /// - Remark: Generated from `#/paths//api/puzzle/activity/get(apiPuzzleActivity)`. + internal func apiPuzzleActivity( + query: Operations.apiPuzzleActivity.Input.Query = .init(), + headers: Operations.apiPuzzleActivity.Input.Headers = .init() + ) async throws -> Operations.apiPuzzleActivity.Output { + try await apiPuzzleActivity(Operations.apiPuzzleActivity.Input( + query: query, + headers: headers + )) + } + /// Get your puzzle dashboard + /// + /// Download your [puzzle dashboard](https://lichess.org/training/dashboard/30/dashboard) as JSON. + /// Also includes all puzzle themes played, with aggregated results. + /// Allows re-creating the [improvement/strengths](https://lichess.org/training/dashboard/30/improvementAreas) interfaces. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/dashboard/{days}`. + /// - Remark: Generated from `#/paths//api/puzzle/dashboard/{days}/get(apiPuzzleDashboard)`. + internal func apiPuzzleDashboard( + path: Operations.apiPuzzleDashboard.Input.Path, + headers: Operations.apiPuzzleDashboard.Input.Headers = .init() + ) async throws -> Operations.apiPuzzleDashboard.Output { + try await apiPuzzleDashboard(Operations.apiPuzzleDashboard.Input( + path: path, + headers: headers + )) + } + /// Get the storm dashboard of a player + /// + /// Download the [storm dashboard](https://lichess.org/storm/dashboard/mrbasso) of any player as JSON. + /// Contains the aggregated highscores, and the history of storm runs aggregated by days. + /// Use `?days=0` if you only care about the highscores. + /// + /// + /// - Remark: HTTP `GET /api/storm/dashboard/{username}`. + /// - Remark: Generated from `#/paths//api/storm/dashboard/{username}/get(apiStormDashboard)`. + internal func apiStormDashboard( + path: Operations.apiStormDashboard.Input.Path, + query: Operations.apiStormDashboard.Input.Query = .init(), + headers: Operations.apiStormDashboard.Input.Headers = .init() + ) async throws -> Operations.apiStormDashboard.Output { + try await apiStormDashboard(Operations.apiStormDashboard.Input( + path: path, + query: query, + headers: headers + )) + } + /// Create and join a puzzle race + /// + /// Create a new private [puzzle race](https://lichess.org/racer). + /// The Lichess user who creates the race must join the race page, + /// and manually start the race when enough players have joined. + /// - <https://lichess.org/racer> + /// + /// + /// - Remark: HTTP `POST /api/racer`. + /// - Remark: Generated from `#/paths//api/racer/post(racerPost)`. + internal func racerPost(headers: Operations.racerPost.Input.Headers = .init()) async throws -> Operations.racerPost.Output { + try await racerPost(Operations.racerPost.Input(headers: headers)) + } + /// Get users by ID + /// + /// Get up to 300 users by their IDs. Users are returned in the same order as the IDs. + /// The method is `POST` to allow a longer list of IDs to be sent in the request body. + /// Please do not try to download all the Lichess users with this endpoint, or any other endpoint. + /// An API is not a way to fully export a website. We do not provide a full download of the Lichess users. + /// This endpoint is limited to 8,000 users every 10 minutes, and 120,000 every day. + /// + /// + /// - Remark: HTTP `POST /api/users`. + /// - Remark: Generated from `#/paths//api/users/post(apiUsers)`. + internal func apiUsers( + headers: Operations.apiUsers.Input.Headers = .init(), + body: Operations.apiUsers.Input.Body + ) async throws -> Operations.apiUsers.Output { + try await apiUsers(Operations.apiUsers.Input( + headers: headers, + body: body + )) + } + /// Get my profile + /// + /// Public information about the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account`. + /// - Remark: Generated from `#/paths//api/account/get(accountMe)`. + internal func accountMe(headers: Operations.accountMe.Input.Headers = .init()) async throws -> Operations.accountMe.Output { + try await accountMe(Operations.accountMe.Input(headers: headers)) + } + /// Get my email address + /// + /// Read the email address of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account/email`. + /// - Remark: Generated from `#/paths//api/account/email/get(accountEmail)`. + internal func accountEmail(headers: Operations.accountEmail.Input.Headers = .init()) async throws -> Operations.accountEmail.Output { + try await accountEmail(Operations.accountEmail.Input(headers: headers)) + } + /// Get my preferences + /// + /// Read the preferences of the logged in user. + /// - <https://lichess.org/account/preferences/game-display> + /// - <https://github.com/ornicar/lila/blob/master/modules/pref/src/main/Pref.scala> + /// + /// + /// - Remark: HTTP `GET /api/account/preferences`. + /// - Remark: Generated from `#/paths//api/account/preferences/get(account)`. + internal func account(headers: Operations.account.Input.Headers = .init()) async throws -> Operations.account.Output { + try await account(Operations.account.Input(headers: headers)) + } + /// Get my kid mode status + /// + /// Read the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `GET /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/get(accountKid)`. + internal func accountKid(headers: Operations.accountKid.Input.Headers = .init()) async throws -> Operations.accountKid.Output { + try await accountKid(Operations.accountKid.Input(headers: headers)) + } + /// Set my kid mode status + /// + /// Set the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `POST /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/post(accountKidPost)`. + internal func accountKidPost( + query: Operations.accountKidPost.Input.Query, + headers: Operations.accountKidPost.Input.Headers = .init() + ) async throws -> Operations.accountKidPost.Output { + try await accountKidPost(Operations.accountKidPost.Input( + query: query, + headers: headers + )) + } + /// Get my timeline + /// + /// Get the timeline events of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/timeline`. + /// - Remark: Generated from `#/paths//api/timeline/get(timeline)`. + internal func timeline( + query: Operations.timeline.Input.Query = .init(), + headers: Operations.timeline.Input.Headers = .init() + ) async throws -> Operations.timeline.Output { + try await timeline(Operations.timeline.Input( + query: query, + headers: headers + )) + } + /// Export one game + /// + /// Download one game in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /game/export/{gameId}`. + /// - Remark: Generated from `#/paths//game/export/{gameId}/get(gamePgn)`. + internal func gamePgn( + path: Operations.gamePgn.Input.Path, + query: Operations.gamePgn.Input.Query = .init(), + headers: Operations.gamePgn.Input.Headers = .init() + ) async throws -> Operations.gamePgn.Output { + try await gamePgn(Operations.gamePgn.Input( + path: path, + query: query, + headers: headers + )) + } + /// Export ongoing game of a user + /// + /// Download the ongoing game, or the last game played, of a user. + /// Available in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/current-game`. + /// - Remark: Generated from `#/paths//api/user/{username}/current-game/get(apiUserCurrentGame)`. + internal func apiUserCurrentGame( + path: Operations.apiUserCurrentGame.Input.Path, + query: Operations.apiUserCurrentGame.Input.Query = .init(), + headers: Operations.apiUserCurrentGame.Input.Headers = .init() + ) async throws -> Operations.apiUserCurrentGame.Output { + try await apiUserCurrentGame(Operations.apiUserCurrentGame.Input( + path: path, + query: query, + headers: headers + )) + } + /// Export games of a user + /// + /// Download all games of any user in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// We recommend streaming the response, for it can be very long. + /// <https://lichess.org/@/german11> for instance has more than 500,000 games. + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// - Authenticated, downloading your own games: 60 games per second + /// + /// + /// - Remark: HTTP `GET /api/games/user/{username}`. + /// - Remark: Generated from `#/paths//api/games/user/{username}/get(apiGamesUser)`. + internal func apiGamesUser( + path: Operations.apiGamesUser.Input.Path, + query: Operations.apiGamesUser.Input.Query = .init(), + headers: Operations.apiGamesUser.Input.Headers = .init() + ) async throws -> Operations.apiGamesUser.Output { + try await apiGamesUser(Operations.apiGamesUser.Input( + path: path, + query: query, + headers: headers + )) + } + /// Export games by IDs + /// + /// Download games by IDs in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// Games are sorted by reverse chronological order (most recent first) + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// 300 IDs can be submitted. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `POST /api/games/export/_ids`. + /// - Remark: Generated from `#/paths//api/games/export/_ids/post(gamesExportIds)`. + internal func gamesExportIds( + query: Operations.gamesExportIds.Input.Query = .init(), + headers: Operations.gamesExportIds.Input.Headers = .init(), + body: Operations.gamesExportIds.Input.Body + ) async throws -> Operations.gamesExportIds.Output { + try await gamesExportIds(Operations.gamesExportIds.Input( + query: query, + headers: headers, + body: body + )) + } + /// Stream games of users + /// + /// Stream the games played between a list of users, in real time. + /// Only games where **both players** are part of the list are included. + /// The stream emits an event each time a game is started or finished. + /// To also get all current ongoing games at the beginning of the stream, use the `withCurrentGames` flag. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of users: 300. + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/stream/games-by-users`. + /// - Remark: Generated from `#/paths//api/stream/games-by-users/post(gamesByUsers)`. + internal func gamesByUsers( + query: Operations.gamesByUsers.Input.Query = .init(), + headers: Operations.gamesByUsers.Input.Headers = .init(), + body: Operations.gamesByUsers.Input.Body + ) async throws -> Operations.gamesByUsers.Output { + try await gamesByUsers(Operations.gamesByUsers.Input( + query: query, + headers: headers, + body: body + )) + } + /// Stream games by IDs + /// + /// Creates a stream of games from an arbitrary streamId, and a list of game IDs. + /// The stream first outputs the games that already exists, then emits an event each time a game is started or finished. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of games: 500 for anonymous requests, or 1000 for [OAuth2 authenticated](#section/Introduction/Authentication) requests. + /// While the stream is open, it is possible to [add new game IDs to watch](#operation/gamesByIdsAdd). + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/post(gamesByIds)`. + internal func gamesByIds( + path: Operations.gamesByIds.Input.Path, + headers: Operations.gamesByIds.Input.Headers = .init(), + body: Operations.gamesByIds.Input.Body + ) async throws -> Operations.gamesByIds.Output { + try await gamesByIds(Operations.gamesByIds.Input( + path: path, + headers: headers, + body: body + )) + } + /// Add game IDs to stream + /// + /// Add new game IDs for [an existing stream](#operation/gamesByIds) to watch. + /// The stream will immediately outputs the games that already exists, then emit an event each time a game is started or finished. + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}/add`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/add/post(gamesByIdsAdd)`. + internal func gamesByIdsAdd( + path: Operations.gamesByIdsAdd.Input.Path, + headers: Operations.gamesByIdsAdd.Input.Headers = .init(), + body: Operations.gamesByIdsAdd.Input.Body + ) async throws -> Operations.gamesByIdsAdd.Output { + try await gamesByIdsAdd(Operations.gamesByIdsAdd.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get my ongoing games + /// + /// Get the ongoing games of the current user. + /// Real-time and correspondence games are included. + /// The most urgent games are listed first. + /// + /// + /// - Remark: HTTP `GET /api/account/playing`. + /// - Remark: Generated from `#/paths//api/account/playing/get(apiAccountPlaying)`. + internal func apiAccountPlaying( + query: Operations.apiAccountPlaying.Input.Query = .init(), + headers: Operations.apiAccountPlaying.Input.Headers = .init() + ) async throws -> Operations.apiAccountPlaying.Output { + try await apiAccountPlaying(Operations.apiAccountPlaying.Input( + query: query, + headers: headers + )) + } + /// Stream moves of a game + /// + /// Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A description of the game is sent as a first message. + /// Then a message is sent each time a move is played. + /// Finally a description of the game is sent when it finishes, and the stream is closed. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// No more than 8 game streams can be opened at the same time from the same IP address. + /// + /// + /// - Remark: HTTP `GET /api/stream/game/{id}`. + /// - Remark: Generated from `#/paths//api/stream/game/{id}/get(streamGame)`. + internal func streamGame( + path: Operations.streamGame.Input.Path, + headers: Operations.streamGame.Input.Headers = .init() + ) async throws -> Operations.streamGame.Output { + try await streamGame(Operations.streamGame.Input( + path: path, + headers: headers + )) + } + /// Import one game + /// + /// Import a game from PGN. See <https://lichess.org/paste>. + /// Rate limiting: 200 games per hour for OAuth requests, 100 games per hour for anonymous requests. + /// To broadcast ongoing games, consider [pushing to a broadcast instead](#operation/broadcastPush). + /// To analyse a position or a line, just construct an analysis board URL: + /// [https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+](https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+) + /// + /// + /// - Remark: HTTP `POST /api/import`. + /// - Remark: Generated from `#/paths//api/import/post(gameImport)`. + internal func gameImport( + headers: Operations.gameImport.Input.Headers = .init(), + body: Operations.gameImport.Input.Body + ) async throws -> Operations.gameImport.Output { + try await gameImport(Operations.gameImport.Input( + headers: headers, + body: body + )) + } + /// Export your imported games + /// + /// Download all games imported by you. Games are exported in PGN format. + /// + /// - Remark: HTTP `GET /api/games/export/imports`. + /// - Remark: Generated from `#/paths//api/games/export/imports/get(apiImportedGamesUser)`. + internal func apiImportedGamesUser(headers: Operations.apiImportedGamesUser.Input.Headers = .init()) async throws -> Operations.apiImportedGamesUser.Output { + try await apiImportedGamesUser(Operations.apiImportedGamesUser.Input(headers: headers)) + } + /// Get current TV games + /// + /// Get basic info about the best games being played for each speed and variant, + /// but also computer games and bot games. + /// See [lichess.org/tv](https://lichess.org/tv). + /// + /// + /// - Remark: HTTP `GET /api/tv/channels`. + /// - Remark: Generated from `#/paths//api/tv/channels/get(tvChannels)`. + internal func tvChannels(headers: Operations.tvChannels.Input.Headers = .init()) async throws -> Operations.tvChannels.Output { + try await tvChannels(Operations.tvChannels.Input(headers: headers)) + } + /// Stream current TV game + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/feed`. + /// - Remark: Generated from `#/paths//api/tv/feed/get(tvFeed)`. + internal func tvFeed(headers: Operations.tvFeed.Input.Headers = .init()) async throws -> Operations.tvFeed.Output { + try await tvFeed(Operations.tvFeed.Input(headers: headers)) + } + /// Stream current TV game of a TV channel + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) of a TV channel in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/rapid/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}/feed`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/feed/get(tvChannelFeed)`. + internal func tvChannelFeed( + path: Operations.tvChannelFeed.Input.Path, + headers: Operations.tvChannelFeed.Input.Headers = .init() + ) async throws -> Operations.tvChannelFeed.Output { + try await tvChannelFeed(Operations.tvChannelFeed.Input( + path: path, + headers: headers + )) + } + /// Get best ongoing games of a TV channel + /// + /// Get a list of ongoing games for a given TV channel. Similar to [lichess.org/games](https://lichess.org/games). + /// Available in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/get(tvChannelGames)`. + internal func tvChannelGames( + path: Operations.tvChannelGames.Input.Path, + query: Operations.tvChannelGames.Input.Query = .init(), + headers: Operations.tvChannelGames.Input.Headers = .init() + ) async throws -> Operations.tvChannelGames.Output { + try await tvChannelGames(Operations.tvChannelGames.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get current tournaments + /// + /// Get recently finished, ongoing, and upcoming tournaments. + /// This API is used to display the [Lichess tournament schedule](https://lichess.org/tournament). + /// + /// + /// - Remark: HTTP `GET /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/get(apiTournament)`. + internal func apiTournament(headers: Operations.apiTournament.Input.Headers = .init()) async throws -> Operations.apiTournament.Output { + try await apiTournament(Operations.apiTournament.Input(headers: headers)) + } + /// Create a new Arena tournament + /// + /// Create a public or private Arena tournament. + /// This endpoint mirrors the form on <https://lichess.org/tournament/new>. + /// You can create up to 12 public tournaments per day, or 24 private tournaments. + /// A team battle can be created by specifying the `teamBattleByTeam` argument. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)`. + internal func apiTournamentPost( + headers: Operations.apiTournamentPost.Input.Headers = .init(), + body: Operations.apiTournamentPost.Input.Body + ) async throws -> Operations.apiTournamentPost.Output { + try await apiTournamentPost(Operations.apiTournamentPost.Input( + headers: headers, + body: body + )) + } + /// Get info about an Arena tournament + /// + /// Get detailed info about recently finished, current, or upcoming tournament's duels, player standings, and other info. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/get(tournament)`. + internal func tournament( + path: Operations.tournament.Input.Path, + query: Operations.tournament.Input.Query = .init(), + headers: Operations.tournament.Input.Headers = .init() + ) async throws -> Operations.tournament.Output { + try await tournament(Operations.tournament.Input( + path: path, + query: query, + headers: headers + )) + } + /// Update an Arena tournament + /// + /// Update an Arena tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Can be used to update a team battle. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)`. + internal func apiTournamentUpdate( + path: Operations.apiTournamentUpdate.Input.Path, + headers: Operations.apiTournamentUpdate.Input.Headers = .init(), + body: Operations.apiTournamentUpdate.Input.Body + ) async throws -> Operations.apiTournamentUpdate.Output { + try await apiTournamentUpdate(Operations.apiTournamentUpdate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Join an Arena tournament + /// + /// Join an Arena tournament, possibly with a password and/or a team. + /// Also unpauses if you had previously [paused](#operation/apiTournamentWithdraw) the tournament. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/join`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)`. + internal func apiTournamentJoin( + path: Operations.apiTournamentJoin.Input.Path, + headers: Operations.apiTournamentJoin.Input.Headers = .init(), + body: Operations.apiTournamentJoin.Input.Body + ) async throws -> Operations.apiTournamentJoin.Output { + try await apiTournamentJoin(Operations.apiTournamentJoin.Input( + path: path, + headers: headers, + body: body + )) + } + /// Pause or leave an Arena tournament + /// + /// Leave a future Arena tournament, or take a break on an ongoing Arena tournament. + /// It's possible to join again later. Points and streaks are preserved. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)`. + internal func apiTournamentWithdraw( + path: Operations.apiTournamentWithdraw.Input.Path, + headers: Operations.apiTournamentWithdraw.Input.Headers = .init() + ) async throws -> Operations.apiTournamentWithdraw.Output { + try await apiTournamentWithdraw(Operations.apiTournamentWithdraw.Input( + path: path, + headers: headers + )) + } + /// Terminate an Arena tournament + /// + /// Terminate an Arena tournament + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)`. + internal func apiTournamentTerminate( + path: Operations.apiTournamentTerminate.Input.Path, + headers: Operations.apiTournamentTerminate.Input.Headers = .init() + ) async throws -> Operations.apiTournamentTerminate.Output { + try await apiTournamentTerminate(Operations.apiTournamentTerminate.Input( + path: path, + headers: headers + )) + } + /// Update a team battle + /// + /// Set the teams and number of leaders of a team battle. + /// To update the other attributes of a team battle, use the [tournament update endpoint](#operation/apiTournamentUpdate). + /// + /// + /// - Remark: HTTP `POST /api/tournament/team-battle/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)`. + internal func apiTournamentTeamBattlePost( + path: Operations.apiTournamentTeamBattlePost.Input.Path, + headers: Operations.apiTournamentTeamBattlePost.Input.Headers = .init(), + body: Operations.apiTournamentTeamBattlePost.Input.Body + ) async throws -> Operations.apiTournamentTeamBattlePost.Output { + try await apiTournamentTeamBattlePost(Operations.apiTournamentTeamBattlePost.Input( + path: path, + headers: headers, + body: body + )) + } + /// Export games of an Arena tournament + /// + /// Download games of a tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/games`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/games/get(gamesByTournament)`. + internal func gamesByTournament( + path: Operations.gamesByTournament.Input.Path, + query: Operations.gamesByTournament.Input.Query = .init(), + headers: Operations.gamesByTournament.Input.Headers = .init() + ) async throws -> Operations.gamesByTournament.Output { + try await gamesByTournament(Operations.gamesByTournament.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get results of an Arena tournament + /// + /// Players of an Arena tournament, with their score and performance, sorted by rank (best first). + /// **Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON)**, i.e. one JSON object per line. + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/results`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/results/get(resultsByTournament)`. + internal func resultsByTournament( + path: Operations.resultsByTournament.Input.Path, + query: Operations.resultsByTournament.Input.Query = .init(), + headers: Operations.resultsByTournament.Input.Headers = .init() + ) async throws -> Operations.resultsByTournament.Output { + try await resultsByTournament(Operations.resultsByTournament.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get team standing of a team battle + /// + /// Teams of a team battle tournament, with top players, sorted by rank (best first). + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/teams`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/teams/get(teamsByTournament)`. + internal func teamsByTournament( + path: Operations.teamsByTournament.Input.Path, + headers: Operations.teamsByTournament.Input.Headers = .init() + ) async throws -> Operations.teamsByTournament.Output { + try await teamsByTournament(Operations.teamsByTournament.Input( + path: path, + headers: headers + )) + } + /// Get tournaments created by a user + /// + /// Get all tournaments created by a given user. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/tournament/created`. + /// - Remark: Generated from `#/paths//api/user/{username}/tournament/created/get(apiUserNameTournamentCreated)`. + internal func apiUserNameTournamentCreated( + path: Operations.apiUserNameTournamentCreated.Input.Path, + query: Operations.apiUserNameTournamentCreated.Input.Query = .init(), + headers: Operations.apiUserNameTournamentCreated.Input.Headers = .init() + ) async throws -> Operations.apiUserNameTournamentCreated.Output { + try await apiUserNameTournamentCreated(Operations.apiUserNameTournamentCreated.Input( + path: path, + query: query, + headers: headers + )) + } + /// Create a new Swiss tournament + /// + /// Create a Swiss tournament for your team. + /// This endpoint mirrors the Swiss tournament form from your team pagee. + /// You can create up to 12 tournaments per day. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/new/{teamId}`. + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)`. + internal func apiSwissNew( + path: Operations.apiSwissNew.Input.Path, + headers: Operations.apiSwissNew.Input.Headers = .init(), + body: Operations.apiSwissNew.Input.Body + ) async throws -> Operations.apiSwissNew.Output { + try await apiSwissNew(Operations.apiSwissNew.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get info about a Swiss tournament + /// + /// Get detailed info about a Swiss tournament. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/get(swiss)`. + internal func swiss( + path: Operations.swiss.Input.Path, + headers: Operations.swiss.Input.Headers = .init() + ) async throws -> Operations.swiss.Output { + try await swiss(Operations.swiss.Input( + path: path, + headers: headers + )) + } + /// Update a Swiss tournament + /// + /// Update a Swiss tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/edit`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)`. + internal func apiSwissUpdate( + path: Operations.apiSwissUpdate.Input.Path, + headers: Operations.apiSwissUpdate.Input.Headers = .init(), + body: Operations.apiSwissUpdate.Input.Body + ) async throws -> Operations.apiSwissUpdate.Output { + try await apiSwissUpdate(Operations.apiSwissUpdate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Manually schedule the next round + /// + /// Manually schedule the next round date and time of a Swiss tournament. + /// This sets the `roundInterval` field to `99999999`, i.e. manual scheduling. + /// All further rounds will need to be manually scheduled, unless the `roundInterval` field is changed back to automatic scheduling. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/schedule-next-round`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)`. + internal func apiSwissScheduleNextRound( + path: Operations.apiSwissScheduleNextRound.Input.Path, + headers: Operations.apiSwissScheduleNextRound.Input.Headers = .init(), + body: Operations.apiSwissScheduleNextRound.Input.Body + ) async throws -> Operations.apiSwissScheduleNextRound.Output { + try await apiSwissScheduleNextRound(Operations.apiSwissScheduleNextRound.Input( + path: path, + headers: headers, + body: body + )) + } + /// Join a Swiss tournament + /// + /// Join a Swiss tournament, possibly with a password. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/join`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)`. + internal func apiSwissJoin( + path: Operations.apiSwissJoin.Input.Path, + headers: Operations.apiSwissJoin.Input.Headers = .init(), + body: Operations.apiSwissJoin.Input.Body + ) async throws -> Operations.apiSwissJoin.Output { + try await apiSwissJoin(Operations.apiSwissJoin.Input( + path: path, + headers: headers, + body: body + )) + } + /// Pause or leave a swiss tournament + /// + /// Leave a future Swiss tournament, or take a break on an ongoing Swiss tournament. + /// It's possible to join again later. Points are preserved. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/withdraw/post(apiSwissWithdraw)`. + internal func apiSwissWithdraw( + path: Operations.apiSwissWithdraw.Input.Path, + headers: Operations.apiSwissWithdraw.Input.Headers = .init() + ) async throws -> Operations.apiSwissWithdraw.Output { + try await apiSwissWithdraw(Operations.apiSwissWithdraw.Input( + path: path, + headers: headers + )) + } + /// Terminate a Swiss tournament + /// + /// Terminate a Swiss tournament + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)`. + internal func apiSwissTerminate( + path: Operations.apiSwissTerminate.Input.Path, + headers: Operations.apiSwissTerminate.Input.Headers = .init() + ) async throws -> Operations.apiSwissTerminate.Output { + try await apiSwissTerminate(Operations.apiSwissTerminate.Input( + path: path, + headers: headers + )) + } + /// Export TRF of a Swiss tournament + /// + /// Download a tournament in the Tournament Report File format, the FIDE standard. + /// Documentation: <https://www.fide.com/FIDE/handbook/C04Annex2_TRF16.pdf> + /// Example: <https://lichess.org/swiss/j8rtJ5GL.trf> + /// + /// + /// - Remark: HTTP `GET /swiss/{id}.trf`. + /// - Remark: Generated from `#/paths//swiss/{id}.trf/get(swissTrf)`. + internal func swissTrf( + path: Operations.swissTrf.Input.Path, + headers: Operations.swissTrf.Input.Headers = .init() + ) async throws -> Operations.swissTrf.Output { + try await swissTrf(Operations.swissTrf.Input( + path: path, + headers: headers + )) + } + /// Export games of a Swiss tournament + /// + /// Download games of a swiss tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (last round first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/games`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/games/get(gamesBySwiss)`. + internal func gamesBySwiss( + path: Operations.gamesBySwiss.Input.Path, + query: Operations.gamesBySwiss.Input.Query = .init(), + headers: Operations.gamesBySwiss.Input.Headers = .init() + ) async throws -> Operations.gamesBySwiss.Output { + try await gamesBySwiss(Operations.gamesBySwiss.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get results of a swiss tournament + /// + /// Players of a swiss tournament, with their score and performance, sorted by rank (best first). + /// Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/results`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/results/get(resultsBySwiss)`. + internal func resultsBySwiss( + path: Operations.resultsBySwiss.Input.Path, + query: Operations.resultsBySwiss.Input.Query = .init(), + headers: Operations.resultsBySwiss.Input.Headers = .init() + ) async throws -> Operations.resultsBySwiss.Output { + try await resultsBySwiss(Operations.resultsBySwiss.Input( + path: path, + query: query, + headers: headers + )) + } + /// Get team swiss tournaments + /// + /// Get all swiss tournaments of a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/swiss`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/swiss/get(apiTeamSwiss)`. + internal func apiTeamSwiss( + path: Operations.apiTeamSwiss.Input.Path, + query: Operations.apiTeamSwiss.Input.Query = .init(), + headers: Operations.apiTeamSwiss.Input.Headers = .init() + ) async throws -> Operations.apiTeamSwiss.Output { + try await apiTeamSwiss(Operations.apiTeamSwiss.Input( + path: path, + query: query, + headers: headers + )) + } + /// Export one study chapter + /// + /// Download one study chapter in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}/{chapterId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}.pgn/get(studyChapterPgn)`. + internal func studyChapterPgn( + path: Operations.studyChapterPgn.Input.Path, + query: Operations.studyChapterPgn.Input.Query = .init(), + headers: Operations.studyChapterPgn.Input.Headers = .init() + ) async throws -> Operations.studyChapterPgn.Output { + try await studyChapterPgn(Operations.studyChapterPgn.Input( + path: path, + query: query, + headers: headers + )) + } + /// Export all chapters + /// + /// Download all chapters of a study in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/get(studyAllChaptersPgn)`. + internal func studyAllChaptersPgn( + path: Operations.studyAllChaptersPgn.Input.Path, + query: Operations.studyAllChaptersPgn.Input.Query = .init(), + headers: Operations.studyAllChaptersPgn.Input.Headers = .init() + ) async throws -> Operations.studyAllChaptersPgn.Output { + try await studyAllChaptersPgn(Operations.studyAllChaptersPgn.Input( + path: path, + query: query, + headers: headers + )) + } + /// Study metadata + /// + /// Only get the study headers, including `Last-Modified`. + /// + /// + /// - Remark: HTTP `HEAD /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/head(studyAllChaptersHead)`. + internal func studyAllChaptersHead(path: Operations.studyAllChaptersHead.Input.Path) async throws -> Operations.studyAllChaptersHead.Output { + try await studyAllChaptersHead(Operations.studyAllChaptersHead.Input(path: path)) + } + /// Import PGN into a study + /// + /// Imports arbitrary PGN into an existing [study](https://lichess.org/study). Creates a new chapter in the study. + /// If the PGN contains multiple games (separated by 2 or more newlines) + /// then multiple chapters will be created within the study. + /// Note that a study can contain at most 64 chapters. + /// + /// + /// - Remark: HTTP `POST /api/study/{studyId}/import-pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)`. + internal func apiStudyImportPGN( + path: Operations.apiStudyImportPGN.Input.Path, + headers: Operations.apiStudyImportPGN.Input.Headers = .init(), + body: Operations.apiStudyImportPGN.Input.Body + ) async throws -> Operations.apiStudyImportPGN.Output { + try await apiStudyImportPGN(Operations.apiStudyImportPGN.Input( + path: path, + headers: headers, + body: body + )) + } + /// Export all studies of a user + /// + /// Download all chapters of all studies of a user in PGN format. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// + /// + /// - Remark: HTTP `GET /study/by/{username}/export.pgn`. + /// - Remark: Generated from `#/paths//study/by/{username}/export.pgn/get(studyExportAllPgn)`. + internal func studyExportAllPgn( + path: Operations.studyExportAllPgn.Input.Path, + query: Operations.studyExportAllPgn.Input.Query = .init(), + headers: Operations.studyExportAllPgn.Input.Headers = .init() + ) async throws -> Operations.studyExportAllPgn.Output { + try await studyExportAllPgn(Operations.studyExportAllPgn.Input( + path: path, + query: query, + headers: headers + )) + } + /// List studies of a user + /// + /// Get metadata (name and dates) of all studies of a user. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// Studies are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/study/by/{username}`. + /// - Remark: Generated from `#/paths//api/study/by/{username}/get(studyListMetadata)`. + internal func studyListMetadata( + path: Operations.studyListMetadata.Input.Path, + headers: Operations.studyListMetadata.Input.Headers = .init() + ) async throws -> Operations.studyListMetadata.Output { + try await studyListMetadata(Operations.studyListMetadata.Input( + path: path, + headers: headers + )) + } + /// Delete a study chapter + /// + /// Delete a chapter of a study you own. This is definitive. + /// A study must have at least one chapter; so if you delete the last chapter, + /// an empty one will be automatically created to replace it. + /// + /// + /// - Remark: HTTP `DELETE /api/study/{studyId}/{chapterId}`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}/delete(apiStudyStudyIdChapterIdDelete)`. + internal func apiStudyStudyIdChapterIdDelete(path: Operations.apiStudyStudyIdChapterIdDelete.Input.Path) async throws -> Operations.apiStudyStudyIdChapterIdDelete.Output { + try await apiStudyStudyIdChapterIdDelete(Operations.apiStudyStudyIdChapterIdDelete.Input(path: path)) + } + /// Get official broadcasts + /// + /// Get all incoming, ongoing, and finished official broadcasts. + /// The broadcasts are sorted by start date, most recent first. + /// Broadcasts are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/broadcast`. + /// - Remark: Generated from `#/paths//api/broadcast/get(broadcastIndex)`. + internal func broadcastIndex( + query: Operations.broadcastIndex.Input.Query = .init(), + headers: Operations.broadcastIndex.Input.Headers = .init() + ) async throws -> Operations.broadcastIndex.Output { + try await broadcastIndex(Operations.broadcastIndex.Input( + query: query, + headers: headers + )) + } + /// Create a broadcast tournament + /// + /// Create a new broadcast tournament to relay external games. + /// This endpoint accepts the same form data as the [web form](https://lichess.org/broadcast/new). + /// + /// + /// - Remark: HTTP `POST /broadcast/new`. + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)`. + internal func broadcastTourCreate( + headers: Operations.broadcastTourCreate.Input.Headers = .init(), + body: Operations.broadcastTourCreate.Input.Body + ) async throws -> Operations.broadcastTourCreate.Output { + try await broadcastTourCreate(Operations.broadcastTourCreate.Input( + headers: headers, + body: body + )) + } + /// Get a broadcast tournament + /// + /// Get information about a broadcast tournament. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}/get(broadcastTourGet)`. + internal func broadcastTourGet( + path: Operations.broadcastTourGet.Input.Path, + headers: Operations.broadcastTourGet.Input.Headers = .init() + ) async throws -> Operations.broadcastTourGet.Output { + try await broadcastTourGet(Operations.broadcastTourGet.Input( + path: path, + headers: headers + )) + } + /// Get a broadcast leaderboard + /// + /// Get the leaderboard of a broadcast tournament, if available. + /// + /// + /// - Remark: HTTP `GET /broadcast/{broadcastTournamentId}/leaderboard`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/leaderboard/get(broadcastLeaderboardGet)`. + internal func broadcastLeaderboardGet( + path: Operations.broadcastLeaderboardGet.Input.Path, + headers: Operations.broadcastLeaderboardGet.Input.Headers = .init() + ) async throws -> Operations.broadcastLeaderboardGet.Output { + try await broadcastLeaderboardGet(Operations.broadcastLeaderboardGet.Input( + path: path, + headers: headers + )) + } + /// Update your broadcast tournament + /// + /// Update information about a broadcast tournament that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)`. + internal func broadcastTourUpdate( + path: Operations.broadcastTourUpdate.Input.Path, + headers: Operations.broadcastTourUpdate.Input.Headers = .init(), + body: Operations.broadcastTourUpdate.Input.Body + ) async throws -> Operations.broadcastTourUpdate.Output { + try await broadcastTourUpdate(Operations.broadcastTourUpdate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Create a broadcast round + /// + /// Create a new broadcast round to relay external games. + /// This endpoint accepts the same form data as the web form. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/new`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)`. + internal func broadcastRoundCreate( + path: Operations.broadcastRoundCreate.Input.Path, + headers: Operations.broadcastRoundCreate.Input.Headers = .init(), + body: Operations.broadcastRoundCreate.Input.Body + ) async throws -> Operations.broadcastRoundCreate.Output { + try await broadcastRoundCreate(Operations.broadcastRoundCreate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get a broadcast round + /// + /// Get information about a broadcast round. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/get(broadcastRoundGet)`. + internal func broadcastRoundGet( + path: Operations.broadcastRoundGet.Input.Path, + headers: Operations.broadcastRoundGet.Input.Headers = .init() + ) async throws -> Operations.broadcastRoundGet.Output { + try await broadcastRoundGet(Operations.broadcastRoundGet.Input( + path: path, + headers: headers + )) + } + /// Update your broadcast round + /// + /// Update information about a broadcast round that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// For instance, if you omit `startDate`, then any pre-existing start date will be removed. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)`. + internal func broadcastRoundUpdate( + path: Operations.broadcastRoundUpdate.Input.Path, + headers: Operations.broadcastRoundUpdate.Input.Headers = .init(), + body: Operations.broadcastRoundUpdate.Input.Body + ) async throws -> Operations.broadcastRoundUpdate.Output { + try await broadcastRoundUpdate(Operations.broadcastRoundUpdate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Push PGN to your broadcast round + /// + /// Update your broadcast with new PGN. + /// Only for broadcast without a source URL. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/push`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)`. + internal func broadcastPush( + path: Operations.broadcastPush.Input.Path, + headers: Operations.broadcastPush.Input.Headers = .init(), + body: Operations.broadcastPush.Input.Body + ) async throws -> Operations.broadcastPush.Output { + try await broadcastPush(Operations.broadcastPush.Input( + path: path, + headers: headers, + body: body + )) + } + /// Stream an ongoing broadcast tournament as PGN + /// + /// This streaming endpoint first sends all games of a broadcast tournament in PGN format. + /// Then, it waits for new moves to be played. As soon as it happens, the entire PGN of the game is sent to the stream. + /// The stream will also send PGNs when games are added to the tournament. + /// This is the best way to get updates about an ongoing tournament. Streaming means no polling, + /// and no pollings means no latency, and minimum impact on the server. + /// + /// + /// - Remark: HTTP `GET /api/stream/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/stream/broadcast/round/{broadcastRoundId}.pgn/get(broadcastStreamRoundPgn)`. + internal func broadcastStreamRoundPgn( + path: Operations.broadcastStreamRoundPgn.Input.Path, + headers: Operations.broadcastStreamRoundPgn.Input.Headers = .init() + ) async throws -> Operations.broadcastStreamRoundPgn.Output { + try await broadcastStreamRoundPgn(Operations.broadcastStreamRoundPgn.Input( + path: path, + headers: headers + )) + } + /// Export one round as PGN + /// + /// Download all games of a single round of a broadcast tournament in PGN format. + /// You *could* poll this endpoint to get updates about a tournament, but it would be slow, + /// and very inefficient. + /// Instead, consider [streaming the tournament](#operation/broadcastStreamRoundPgn) to get + /// a new PGN every time a game is updated, in real-time. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/round/{broadcastRoundId}.pgn/get(broadcastRoundPgn)`. + internal func broadcastRoundPgn( + path: Operations.broadcastRoundPgn.Input.Path, + headers: Operations.broadcastRoundPgn.Input.Headers = .init() + ) async throws -> Operations.broadcastRoundPgn.Output { + try await broadcastRoundPgn(Operations.broadcastRoundPgn.Input( + path: path, + headers: headers + )) + } + /// Export all rounds as PGN + /// + /// Download all games of all rounds of a broadcast in PGN format. + /// If a `study:read` [OAuth token](#tag/OAuth) is provided, + /// the private rounds where the user is a contributor will be available. + /// You may want to [download only the games of a single round](#operation/broadcastRoundPgn) instead. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}.pgn/get(broadcastAllRoundsPgn)`. + internal func broadcastAllRoundsPgn( + path: Operations.broadcastAllRoundsPgn.Input.Path, + headers: Operations.broadcastAllRoundsPgn.Input.Headers = .init() + ) async throws -> Operations.broadcastAllRoundsPgn.Output { + try await broadcastAllRoundsPgn(Operations.broadcastAllRoundsPgn.Input( + path: path, + headers: headers + )) + } + /// Get your broadcast rounds + /// + /// Stream all broadcast rounds you are a member of. + /// Also includes broadcasts rounds you did not create, but were invited to. + /// Also includes broadcasts rounds where you're a non-writing member. See the `writeable` flag in the response. + /// Rounds are ordered by rank, which is roughly chronological, most recent first, slightly pondered with popularity. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/my-rounds`. + /// - Remark: Generated from `#/paths//api/broadcast/my-rounds/get(broadcastMyRoundsGet)`. + internal func broadcastMyRoundsGet( + query: Operations.broadcastMyRoundsGet.Input.Query = .init(), + headers: Operations.broadcastMyRoundsGet.Input.Headers = .init() + ) async throws -> Operations.broadcastMyRoundsGet.Output { + try await broadcastMyRoundsGet(Operations.broadcastMyRoundsGet.Input( + query: query, + headers: headers + )) + } + /// Get current simuls + /// + /// Get recently created, started, finished, simuls. + /// Created and finished simul lists are not exhaustives, only those with + /// strong enough host will be listed, the same filter is used to display simuls on https://lichess.org/simul. + /// When [authenticated with OAuth2](#section/Introduction/Authentication), the pending list will be populated with your created, but unstarted simuls. + /// + /// + /// - Remark: HTTP `GET /api/simul`. + /// - Remark: Generated from `#/paths//api/simul/get(apiSimul)`. + internal func apiSimul(headers: Operations.apiSimul.Input.Headers = .init()) async throws -> Operations.apiSimul.Output { + try await apiSimul(Operations.apiSimul.Input(headers: headers)) + } + /// Get a single team + /// + /// Public info about a team. Includes the list of publicly visible leaders. + /// + /// - Remark: HTTP `GET /api/team/{teamId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/get(teamShow)`. + internal func teamShow( + path: Operations.teamShow.Input.Path, + headers: Operations.teamShow.Input.Headers = .init() + ) async throws -> Operations.teamShow.Output { + try await teamShow(Operations.teamShow.Input( + path: path, + headers: headers + )) + } + /// Get popular teams + /// + /// Paginator of the most popular teams. + /// + /// + /// - Remark: HTTP `GET /api/team/all`. + /// - Remark: Generated from `#/paths//api/team/all/get(teamAll)`. + internal func teamAll( + query: Operations.teamAll.Input.Query = .init(), + headers: Operations.teamAll.Input.Headers = .init() + ) async throws -> Operations.teamAll.Output { + try await teamAll(Operations.teamAll.Input( + query: query, + headers: headers + )) + } + /// Teams of a player + /// + /// All the teams a player is a member of. + /// + /// + /// - Remark: HTTP `GET /api/team/of/{username}`. + /// - Remark: Generated from `#/paths//api/team/of/{username}/get(teamOfUsername)`. + internal func teamOfUsername( + path: Operations.teamOfUsername.Input.Path, + headers: Operations.teamOfUsername.Input.Headers = .init() + ) async throws -> Operations.teamOfUsername.Output { + try await teamOfUsername(Operations.teamOfUsername.Input( + path: path, + headers: headers + )) + } + /// Search teams + /// + /// Paginator of team search results for a keyword. + /// + /// + /// - Remark: HTTP `GET /api/team/search`. + /// - Remark: Generated from `#/paths//api/team/search/get(teamSearch)`. + internal func teamSearch( + query: Operations.teamSearch.Input.Query = .init(), + headers: Operations.teamSearch.Input.Headers = .init() + ) async throws -> Operations.teamSearch.Output { + try await teamSearch(Operations.teamSearch.Input( + query: query, + headers: headers + )) + } + /// Get members of a team + /// + /// Members are sorted by reverse chronological order of joining the team (most recent first). + /// OAuth is only required if the list of members is private. + /// Members are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/users`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/users/get(teamIdUsers)`. + internal func teamIdUsers( + path: Operations.teamIdUsers.Input.Path, + headers: Operations.teamIdUsers.Input.Headers = .init() + ) async throws -> Operations.teamIdUsers.Output { + try await teamIdUsers(Operations.teamIdUsers.Input( + path: path, + headers: headers + )) + } + /// Get team Arena tournaments + /// + /// Get all Arena tournaments relevant to a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/arena`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/arena/get(apiTeamArena)`. + internal func apiTeamArena( + path: Operations.apiTeamArena.Input.Path, + query: Operations.apiTeamArena.Input.Query = .init(), + headers: Operations.apiTeamArena.Input.Headers = .init() + ) async throws -> Operations.apiTeamArena.Output { + try await apiTeamArena(Operations.apiTeamArena.Input( + path: path, + query: query, + headers: headers + )) + } + /// Join a team + /// + /// Join a team. + /// If the team requires a password but the `password` field is incorrect, + /// then the call fails with `403 Forbidden`. + /// Similarly, if the team join policy requires a confirmation but the + /// `message` parameter is not given, then the call fails with + /// `403 Forbidden`. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/join`. + /// - Remark: Generated from `#/paths//team/{teamId}/join/post(teamIdJoin)`. + internal func teamIdJoin( + path: Operations.teamIdJoin.Input.Path, + headers: Operations.teamIdJoin.Input.Headers = .init(), + body: Operations.teamIdJoin.Input.Body + ) async throws -> Operations.teamIdJoin.Output { + try await teamIdJoin(Operations.teamIdJoin.Input( + path: path, + headers: headers, + body: body + )) + } + /// Leave a team + /// + /// Leave a team. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/quit`. + /// - Remark: Generated from `#/paths//team/{teamId}/quit/post(teamIdQuit)`. + internal func teamIdQuit( + path: Operations.teamIdQuit.Input.Path, + headers: Operations.teamIdQuit.Input.Headers = .init() + ) async throws -> Operations.teamIdQuit.Output { + try await teamIdQuit(Operations.teamIdQuit.Input( + path: path, + headers: headers + )) + } + /// Get join requests + /// + /// Get pending join requests of your team + /// + /// - Remark: HTTP `GET /api/team/{teamId}/requests`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/requests/get(teamRequests)`. + internal func teamRequests( + path: Operations.teamRequests.Input.Path, + query: Operations.teamRequests.Input.Query = .init(), + headers: Operations.teamRequests.Input.Headers = .init() + ) async throws -> Operations.teamRequests.Output { + try await teamRequests(Operations.teamRequests.Input( + path: path, + query: query, + headers: headers + )) + } + /// Accept join request + /// + /// Accept someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/accept`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/accept/post(teamRequestAccept)`. + internal func teamRequestAccept( + path: Operations.teamRequestAccept.Input.Path, + headers: Operations.teamRequestAccept.Input.Headers = .init() + ) async throws -> Operations.teamRequestAccept.Output { + try await teamRequestAccept(Operations.teamRequestAccept.Input( + path: path, + headers: headers + )) + } + /// Decline join request + /// + /// Decline someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/decline`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/decline/post(teamRequestDecline)`. + internal func teamRequestDecline( + path: Operations.teamRequestDecline.Input.Path, + headers: Operations.teamRequestDecline.Input.Headers = .init() + ) async throws -> Operations.teamRequestDecline.Output { + try await teamRequestDecline(Operations.teamRequestDecline.Input( + path: path, + headers: headers + )) + } + /// Kick a user from your team + /// + /// Kick a member out of one of your teams. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /api/team/{teamId}/kick/{userId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/kick/{userId}/post(teamIdKickUserId)`. + internal func teamIdKickUserId( + path: Operations.teamIdKickUserId.Input.Path, + headers: Operations.teamIdKickUserId.Input.Headers = .init() + ) async throws -> Operations.teamIdKickUserId.Output { + try await teamIdKickUserId(Operations.teamIdKickUserId.Input( + path: path, + headers: headers + )) + } + /// Message all members + /// + /// Send a private message to all members of a team. + /// You must be a team leader with the "Messages" permission. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/pm-all`. + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)`. + internal func teamIdPmAll( + path: Operations.teamIdPmAll.Input.Path, + headers: Operations.teamIdPmAll.Input.Headers = .init(), + body: Operations.teamIdPmAll.Input.Body + ) async throws -> Operations.teamIdPmAll.Output { + try await teamIdPmAll(Operations.teamIdPmAll.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get live streamers + /// + /// Get basic info about currently streaming users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// + /// + /// - Remark: HTTP `GET /api/streamer/live`. + /// - Remark: Generated from `#/paths//api/streamer/live/get(streamerLive)`. + internal func streamerLive(headers: Operations.streamerLive.Input.Headers = .init()) async throws -> Operations.streamerLive.Output { + try await streamerLive(Operations.streamerLive.Input(headers: headers)) + } + /// Get crosstable + /// + /// Get total number of games, and current score, of any two users. + /// If the `matchup` flag is provided, and the users are currently playing, also gets the current match game number and scores. + /// + /// + /// - Remark: HTTP `GET /api/crosstable/{user1}/{user2}`. + /// - Remark: Generated from `#/paths//api/crosstable/{user1}/{user2}/get(apiCrosstable)`. + internal func apiCrosstable( + path: Operations.apiCrosstable.Input.Path, + query: Operations.apiCrosstable.Input.Query = .init(), + headers: Operations.apiCrosstable.Input.Headers = .init() + ) async throws -> Operations.apiCrosstable.Output { + try await apiCrosstable(Operations.apiCrosstable.Input( + path: path, + query: query, + headers: headers + )) + } + /// Autocomplete usernames + /// + /// Provides autocompletion options for an incomplete username. + /// + /// + /// - Remark: HTTP `GET /api/player/autocomplete`. + /// - Remark: Generated from `#/paths//api/player/autocomplete/get(apiPlayerAutocomplete)`. + internal func apiPlayerAutocomplete( + query: Operations.apiPlayerAutocomplete.Input.Query, + headers: Operations.apiPlayerAutocomplete.Input.Headers = .init() + ) async throws -> Operations.apiPlayerAutocomplete.Output { + try await apiPlayerAutocomplete(Operations.apiPlayerAutocomplete.Input( + query: query, + headers: headers + )) + } + /// Get notes for a user + /// + /// Get the private notes that you have added for a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/get(readNote)`. + internal func readNote( + path: Operations.readNote.Input.Path, + headers: Operations.readNote.Input.Headers = .init() + ) async throws -> Operations.readNote.Output { + try await readNote(Operations.readNote.Input( + path: path, + headers: headers + )) + } + /// Add a note for a user + /// + /// Add a private note available only to you about this account. + /// + /// + /// - Remark: HTTP `POST /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/post(writeNote)`. + internal func writeNote( + path: Operations.writeNote.Input.Path, + headers: Operations.writeNote.Input.Headers = .init(), + body: Operations.writeNote.Input.Body + ) async throws -> Operations.writeNote.Output { + try await writeNote(Operations.writeNote.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get users followed by the logged in user + /// + /// Users are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/rel/following`. + /// - Remark: Generated from `#/paths//api/rel/following/get(apiUserFollowing)`. + internal func apiUserFollowing(headers: Operations.apiUserFollowing.Input.Headers = .init()) async throws -> Operations.apiUserFollowing.Output { + try await apiUserFollowing(Operations.apiUserFollowing.Input(headers: headers)) + } + /// Follow a player + /// + /// Follow a player, adding them to your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/follow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/follow/{username}/post(followUser)`. + internal func followUser( + path: Operations.followUser.Input.Path, + headers: Operations.followUser.Input.Headers = .init() + ) async throws -> Operations.followUser.Output { + try await followUser(Operations.followUser.Input( + path: path, + headers: headers + )) + } + /// Unfollow a player + /// + /// Unfollow a player, removing them from your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/unfollow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/unfollow/{username}/post(unfollowUser)`. + internal func unfollowUser( + path: Operations.unfollowUser.Input.Path, + headers: Operations.unfollowUser.Input.Headers = .init() + ) async throws -> Operations.unfollowUser.Output { + try await unfollowUser(Operations.unfollowUser.Input( + path: path, + headers: headers + )) + } + /// Stream incoming events + /// + /// + /// Stream the events reaching a lichess user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// An empty line is sent every 6 seconds for keep alive purposes. + /// + /// Each non-empty line is a JSON object containing a `type` field. Possible values are: + /// - `gameStart` Start of a game + /// - `gameFinish` Completion of a game + /// - `challenge` A player sends you a challenge or you challenge someone + /// - `challengeCanceled` A player cancels their challenge to you + /// - `challengeDeclined` The opponent declines your challenge + /// + /// When the stream opens, all current challenges and games are sent. + /// + /// - Remark: HTTP `GET /api/stream/event`. + /// - Remark: Generated from `#/paths//api/stream/event/get(apiStreamEvent)`. + internal func apiStreamEvent(headers: Operations.apiStreamEvent.Input.Headers = .init()) async throws -> Operations.apiStreamEvent.Output { + try await apiStreamEvent(Operations.apiStreamEvent.Input(headers: headers)) + } + /// Create a seek + /// + /// + /// Create a public seek, to start a game with a random player. + /// + /// ### Real-time seek + /// + /// Specify the `time` and `increment` clock values. The response is streamed but doesn't contain any information. + /// + /// **Keep the connection open to keep the seek active**. + /// + /// If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. + /// When the seek is accepted, or expires, the server closes the connection. + /// + /// **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. + /// We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, + /// you won't miss the game event if the seek is accepted immediately. + /// + /// ### Correspondence seek + /// + /// Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone. + /// + /// - Remark: HTTP `POST /api/board/seek`. + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)`. + internal func apiBoardSeek( + headers: Operations.apiBoardSeek.Input.Headers = .init(), + body: Operations.apiBoardSeek.Input.Body + ) async throws -> Operations.apiBoardSeek.Output { + try await apiBoardSeek(Operations.apiBoardSeek.Input( + headers: headers, + body: body + )) + } + /// Stream Board game state + /// + /// Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, a draw is offered, or when the game ends. + /// - `chatLine` Chat message sent by a user in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// + /// The server closes the stream when the game ends, or if the game has already ended. + /// + /// - Remark: HTTP `GET /api/board/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)`. + internal func boardGameStream( + path: Operations.boardGameStream.Input.Path, + headers: Operations.boardGameStream.Input.Headers = .init() + ) async throws -> Operations.boardGameStream.Output { + try await boardGameStream(Operations.boardGameStream.Input( + path: path, + headers: headers + )) + } + /// Make a Board move + /// + /// Make a move in a game being played with the Board API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)`. + internal func boardGameMove( + path: Operations.boardGameMove.Input.Path, + query: Operations.boardGameMove.Input.Query = .init(), + headers: Operations.boardGameMove.Input.Headers = .init() + ) async throws -> Operations.boardGameMove.Output { + try await boardGameMove(Operations.boardGameMove.Input( + path: path, + query: query, + headers: headers + )) + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/get(boardGameChatGet)`. + internal func boardGameChatGet( + path: Operations.boardGameChatGet.Input.Path, + headers: Operations.boardGameChatGet.Input.Headers = .init() + ) async throws -> Operations.boardGameChatGet.Output { + try await boardGameChatGet(Operations.boardGameChatGet.Input( + path: path, + headers: headers + )) + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)`. + internal func boardGameChatPost( + path: Operations.boardGameChatPost.Input.Path, + headers: Operations.boardGameChatPost.Input.Headers = .init(), + body: Operations.boardGameChatPost.Input.Body + ) async throws -> Operations.boardGameChatPost.Output { + try await boardGameChatPost(Operations.boardGameChatPost.Input( + path: path, + headers: headers, + body: body + )) + } + /// Abort a game + /// + /// Abort a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)`. + internal func boardGameAbort( + path: Operations.boardGameAbort.Input.Path, + headers: Operations.boardGameAbort.Input.Headers = .init() + ) async throws -> Operations.boardGameAbort.Output { + try await boardGameAbort(Operations.boardGameAbort.Input( + path: path, + headers: headers + )) + } + /// Resign a game + /// + /// Resign a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)`. + internal func boardGameResign( + path: Operations.boardGameResign.Input.Path, + headers: Operations.boardGameResign.Input.Headers = .init() + ) async throws -> Operations.boardGameResign.Output { + try await boardGameResign(Operations.boardGameResign.Input( + path: path, + headers: headers + )) + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)`. + internal func boardGameDraw( + path: Operations.boardGameDraw.Input.Path, + headers: Operations.boardGameDraw.Input.Headers = .init() + ) async throws -> Operations.boardGameDraw.Output { + try await boardGameDraw(Operations.boardGameDraw.Input( + path: path, + headers: headers + )) + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)`. + internal func boardGameTakeback( + path: Operations.boardGameTakeback.Input.Path, + headers: Operations.boardGameTakeback.Input.Headers = .init() + ) async throws -> Operations.boardGameTakeback.Output { + try await boardGameTakeback(Operations.boardGameTakeback.Input( + path: path, + headers: headers + )) + } + /// Claim victory of a game + /// + /// Claim victory when the opponent has left the game for a while. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/claim-victory`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)`. + internal func boardGameClaimVictory( + path: Operations.boardGameClaimVictory.Input.Path, + headers: Operations.boardGameClaimVictory.Input.Headers = .init() + ) async throws -> Operations.boardGameClaimVictory.Output { + try await boardGameClaimVictory(Operations.boardGameClaimVictory.Input( + path: path, + headers: headers + )) + } + /// Berserk a tournament game + /// + /// Go berserk on an arena tournament game. Halves the clock time, grants an extra point upon winning. + /// Only available in arena tournaments that allow berserk, and before each player has made a move. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/berserk`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)`. + internal func boardGameBerserk( + path: Operations.boardGameBerserk.Input.Path, + headers: Operations.boardGameBerserk.Input.Headers = .init() + ) async throws -> Operations.boardGameBerserk.Output { + try await boardGameBerserk(Operations.boardGameBerserk.Input( + path: path, + headers: headers + )) + } + /// Get online bots + /// + /// Stream the [online bot users](https://lichess.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second. + /// + /// - Remark: HTTP `GET /api/bot/online`. + /// - Remark: Generated from `#/paths//api/bot/online/get(apiBotOnline)`. + internal func apiBotOnline( + query: Operations.apiBotOnline.Input.Query = .init(), + headers: Operations.apiBotOnline.Input.Headers = .init() + ) async throws -> Operations.apiBotOnline.Output { + try await apiBotOnline(Operations.apiBotOnline.Input( + query: query, + headers: headers + )) + } + /// Upgrade to Bot account + /// + /// Upgrade a lichess player account into a Bot account. Only Bot accounts can use the Bot API. + /// The account **cannot have played any game** before becoming a Bot account. The upgrade is **irreversible**. The account will only be able to play as a Bot. + /// To upgrade an account to Bot, use the [official lichess-bot client](https://github.com/lichess-bot-devs/lichess-bot), or follow these steps: + /// - Create an [API access token](https://lichess.org/account/oauth/token/create?scopes[]=bot:play) with "Play bot moves" permission. + /// - `curl -d '' https://lichess.org/api/bot/account/upgrade -H "Authorization: Bearer <yourTokenHere>"` + /// To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): + /// the `title` field should be set to `BOT`. + /// + /// + /// - Remark: HTTP `POST /api/bot/account/upgrade`. + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)`. + internal func botAccountUpgrade(headers: Operations.botAccountUpgrade.Input.Headers = .init()) async throws -> Operations.botAccountUpgrade.Output { + try await botAccountUpgrade(Operations.botAccountUpgrade.Input(headers: headers)) + } + /// Stream Bot game state + /// + /// Stream the state of a game being played with the Bot API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. + /// - `chatLine` Chat message sent by a user (or the bot itself) in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// - Remark: HTTP `GET /api/bot/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)`. + internal func botGameStream( + path: Operations.botGameStream.Input.Path, + headers: Operations.botGameStream.Input.Headers = .init() + ) async throws -> Operations.botGameStream.Output { + try await botGameStream(Operations.botGameStream.Input( + path: path, + headers: headers + )) + } + /// Make a Bot move + /// + /// Make a move in a game being played with the Bot API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)`. + internal func botGameMove( + path: Operations.botGameMove.Input.Path, + query: Operations.botGameMove.Input.Query = .init(), + headers: Operations.botGameMove.Input.Headers = .init() + ) async throws -> Operations.botGameMove.Output { + try await botGameMove(Operations.botGameMove.Input( + path: path, + query: query, + headers: headers + )) + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/get(botGameChatGet)`. + internal func botGameChatGet( + path: Operations.botGameChatGet.Input.Path, + headers: Operations.botGameChatGet.Input.Headers = .init() + ) async throws -> Operations.botGameChatGet.Output { + try await botGameChatGet(Operations.botGameChatGet.Input( + path: path, + headers: headers + )) + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)`. + internal func botGameChat( + path: Operations.botGameChat.Input.Path, + headers: Operations.botGameChat.Input.Headers = .init(), + body: Operations.botGameChat.Input.Body + ) async throws -> Operations.botGameChat.Output { + try await botGameChat(Operations.botGameChat.Input( + path: path, + headers: headers, + body: body + )) + } + /// Abort a game + /// + /// Abort a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)`. + internal func botGameAbort( + path: Operations.botGameAbort.Input.Path, + headers: Operations.botGameAbort.Input.Headers = .init() + ) async throws -> Operations.botGameAbort.Output { + try await botGameAbort(Operations.botGameAbort.Input( + path: path, + headers: headers + )) + } + /// Resign a game + /// + /// Resign a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)`. + internal func botGameResign( + path: Operations.botGameResign.Input.Path, + headers: Operations.botGameResign.Input.Headers = .init() + ) async throws -> Operations.botGameResign.Output { + try await botGameResign(Operations.botGameResign.Input( + path: path, + headers: headers + )) + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers with the Bot API. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)`. + internal func botGameDraw( + path: Operations.botGameDraw.Input.Path, + headers: Operations.botGameDraw.Input.Headers = .init() + ) async throws -> Operations.botGameDraw.Output { + try await botGameDraw(Operations.botGameDraw.Input( + path: path, + headers: headers + )) + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks with the Bot API. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)`. + internal func botGameTakeback( + path: Operations.botGameTakeback.Input.Path, + headers: Operations.botGameTakeback.Input.Headers = .init() + ) async throws -> Operations.botGameTakeback.Output { + try await botGameTakeback(Operations.botGameTakeback.Input( + path: path, + headers: headers + )) + } + /// List your challenges + /// + /// Get a list of challenges created by or targeted at you. + /// + /// + /// - Remark: HTTP `GET /api/challenge`. + /// - Remark: Generated from `#/paths//api/challenge/get(challengeList)`. + internal func challengeList(headers: Operations.challengeList.Input.Headers = .init()) async throws -> Operations.challengeList.Output { + try await challengeList(Operations.challengeList.Input(headers: headers)) + } + /// Create a challenge + /// + /// Challenge someone to play. The targeted player can choose to accept or decline. + /// If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) + /// that a new game has started. The game ID will be the same as the challenge ID. + /// Challenges for realtime games (not correspondence) expire after 20s if not accepted. + /// To prevent that, use the `keepAliveStream` flag described below. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{username}`. + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)`. + internal func challengeCreate( + path: Operations.challengeCreate.Input.Path, + headers: Operations.challengeCreate.Input.Headers = .init(), + body: Operations.challengeCreate.Input.Body + ) async throws -> Operations.challengeCreate.Output { + try await challengeCreate(Operations.challengeCreate.Input( + path: path, + headers: headers, + body: body + )) + } + /// Accept a challenge + /// + /// Accept an incoming challenge. + /// You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent). + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/accept`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)`. + internal func challengeAccept( + path: Operations.challengeAccept.Input.Path, + headers: Operations.challengeAccept.Input.Headers = .init() + ) async throws -> Operations.challengeAccept.Output { + try await challengeAccept(Operations.challengeAccept.Input( + path: path, + headers: headers + )) + } + /// Decline a challenge + /// + /// Decline an incoming challenge. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/decline`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)`. + internal func challengeDecline( + path: Operations.challengeDecline.Input.Path, + headers: Operations.challengeDecline.Input.Headers = .init(), + body: Operations.challengeDecline.Input.Body? = nil + ) async throws -> Operations.challengeDecline.Output { + try await challengeDecline(Operations.challengeDecline.Input( + path: path, + headers: headers, + body: body + )) + } + /// Cancel a challenge + /// + /// Cancel a challenge you sent, or aborts the game if the challenge was accepted, but the game was not yet played. + /// Note that the ID of a game is the same as the ID of the challenge that created it. + /// Works for user challenges and open challenges alike. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/cancel`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)`. + internal func challengeCancel( + path: Operations.challengeCancel.Input.Path, + query: Operations.challengeCancel.Input.Query = .init(), + headers: Operations.challengeCancel.Input.Headers = .init() + ) async throws -> Operations.challengeCancel.Output { + try await challengeCancel(Operations.challengeCancel.Input( + path: path, + query: query, + headers: headers + )) + } + /// Challenge the AI + /// + /// Start a game with Lichess AI. + /// You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. + /// + /// + /// - Remark: HTTP `POST /api/challenge/ai`. + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)`. + internal func challengeAi( + headers: Operations.challengeAi.Input.Headers = .init(), + body: Operations.challengeAi.Input.Body + ) async throws -> Operations.challengeAi.Output { + try await challengeAi(Operations.challengeAi.Input( + headers: headers, + body: body + )) + } + /// Open-ended challenge + /// + /// Create a challenge that any 2 players can join. + /// Share the URL of the challenge. the first 2 players to click it will be paired for a game. + /// The response body also contains `whiteUrl` and `blackUrl`. + /// You can control which color each player gets by giving them these URLs, + /// instead of the main challenge URL. + /// Open challenges expire after 24h. + /// If the challenge creation is [authenticated with OAuth2](#section/Introduction/Authentication), + /// then you can use the [challenge cancel endpoint](#operation/challengeCancel) to cancel it. + /// To directly pair 2 known players, use [this endpoint](#operation/bulkPairingList) instead. + /// + /// + /// - Remark: HTTP `POST /api/challenge/open`. + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)`. + internal func challengeOpen( + headers: Operations.challengeOpen.Input.Headers = .init(), + body: Operations.challengeOpen.Input.Body + ) async throws -> Operations.challengeOpen.Output { + try await challengeOpen(Operations.challengeOpen.Input( + headers: headers, + body: body + )) + } + /// Start clocks of a game + /// + /// Start the clocks of a game immediately, even if a player has not yet made a move. + /// Requires the OAuth tokens of both players with `challenge:write` scope. + /// If the clocks have already started, the call will have no effect. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{gameId}/start-clocks`. + /// - Remark: Generated from `#/paths//api/challenge/{gameId}/start-clocks/post(challengeStartClocks)`. + internal func challengeStartClocks( + path: Operations.challengeStartClocks.Input.Path, + query: Operations.challengeStartClocks.Input.Query = .init(), + headers: Operations.challengeStartClocks.Input.Headers = .init() + ) async throws -> Operations.challengeStartClocks.Output { + try await challengeStartClocks(Operations.challengeStartClocks.Input( + path: path, + query: query, + headers: headers + )) + } + /// View your bulk pairings + /// + /// Get a list of bulk pairings you created. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/get(bulkPairingList)`. + internal func bulkPairingList(headers: Operations.bulkPairingList.Input.Headers = .init()) async throws -> Operations.bulkPairingList.Output { + try await bulkPairingList(Operations.bulkPairingList.Input(headers: headers)) + } + /// Create a bulk pairing + /// + /// Schedule many games at once, up to 24h in advance. + /// OAuth tokens are required for all paired players, with the `challenge:write` scope. + /// You can schedule up to 500 games every 10 minutes. [Contact us](mailto:contact@lichess.org) if you need higher limits. + /// If games have a real-time clock, each player must have only one pairing. + /// For correspondence games, players can have multiple pairings within the same bulk. + /// The entire bulk is rejected if: + /// - a token is missing + /// - a token is present more than once (except in correspondence) + /// - a token lacks the `challenge:write` scope + /// - a player account is closed + /// - a player is paired more than once (except in correspondence) + /// - a bulk is already scheduled to start at the same time with the same player + /// - you have 20 scheduled bulks + /// - you have 1000 scheduled games + /// Partial bulks are never created. Either it all fails, or it all succeeds. + /// When it fails, it does so with an error message explaining the issue. + /// Failed bulks are not counted in the rate limiting, they are free. + /// Fix the issues, manually or programmatically, then retry to schedule the bulk. + /// A successful bulk creation returns a JSON bulk document. Its ID can be used for further operations. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)`. + internal func bulkPairingCreate( + headers: Operations.bulkPairingCreate.Input.Headers = .init(), + body: Operations.bulkPairingCreate.Input.Body + ) async throws -> Operations.bulkPairingCreate.Output { + try await bulkPairingCreate(Operations.bulkPairingCreate.Input( + headers: headers, + body: body + )) + } + /// Manually start clocks + /// + /// Immediately start all clocks of the games of a bulk pairing. + /// This overrides the `startClocksAt` value of an existing bulk pairing. + /// If the games have not yet been created (`bulk.pairAt` is in the future), then this does nothing. + /// If the clocks have already started (`bulk.startClocksAt` is in the past), then this does nothing. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing/{id}/start-clocks`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)`. + internal func bulkPairingStartClocks( + path: Operations.bulkPairingStartClocks.Input.Path, + headers: Operations.bulkPairingStartClocks.Input.Headers = .init() + ) async throws -> Operations.bulkPairingStartClocks.Output { + try await bulkPairingStartClocks(Operations.bulkPairingStartClocks.Input( + path: path, + headers: headers + )) + } + /// Show a bulk pairing + /// + /// Get a single bulk pairing by its ID. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)`. + internal func bulkPairingGet( + path: Operations.bulkPairingGet.Input.Path, + headers: Operations.bulkPairingGet.Input.Headers = .init() + ) async throws -> Operations.bulkPairingGet.Output { + try await bulkPairingGet(Operations.bulkPairingGet.Input( + path: path, + headers: headers + )) + } + /// Cancel a bulk pairing + /// + /// Cancel and delete a bulk pairing that is scheduled in the future. + /// If the games have already been created, then this does nothing. + /// Canceling a bulk pairing does not refund the rate limit cost of that bulk pairing. + /// + /// + /// - Remark: HTTP `DELETE /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)`. + internal func bulkPairingDelete( + path: Operations.bulkPairingDelete.Input.Path, + headers: Operations.bulkPairingDelete.Input.Headers = .init() + ) async throws -> Operations.bulkPairingDelete.Output { + try await bulkPairingDelete(Operations.bulkPairingDelete.Input( + path: path, + headers: headers + )) + } + /// Add time to the opponent clock + /// + /// Add seconds to the opponent's clock. Can be used to create games with time odds. + /// + /// + /// - Remark: HTTP `POST /api/round/{gameId}/add-time/{seconds}`. + /// - Remark: Generated from `#/paths//api/round/{gameId}/add-time/{seconds}/post(roundAddTime)`. + internal func roundAddTime( + path: Operations.roundAddTime.Input.Path, + headers: Operations.roundAddTime.Input.Headers = .init() + ) async throws -> Operations.roundAddTime.Output { + try await roundAddTime(Operations.roundAddTime.Input( + path: path, + headers: headers + )) + } + /// Admin challenge tokens + /// + /// **This endpoint can only be used by Lichess administrators. It will not work if you do not have the appropriate permissions.** Tournament organizers should instead use [OAuth](#tag/OAuth) to obtain `challenge:write` tokens from users in order to perform bulk pairing.* + /// Create and obtain `challenge:write` tokens for multiple users. + /// If a similar token already exists for a user, it is reused. This endpoint is idempotent. + /// + /// + /// - Remark: HTTP `POST /api/token/admin-challenge`. + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)`. + internal func adminChallengeTokens( + headers: Operations.adminChallengeTokens.Input.Headers = .init(), + body: Operations.adminChallengeTokens.Input.Body + ) async throws -> Operations.adminChallengeTokens.Output { + try await adminChallengeTokens(Operations.adminChallengeTokens.Input( + headers: headers, + body: body + )) + } + /// Send a private message + /// + /// Send a private message to another player. + /// + /// + /// - Remark: HTTP `POST /inbox/{username}`. + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)`. + internal func inboxUsername( + path: Operations.inboxUsername.Input.Path, + headers: Operations.inboxUsername.Input.Headers = .init(), + body: Operations.inboxUsername.Input.Body + ) async throws -> Operations.inboxUsername.Output { + try await inboxUsername(Operations.inboxUsername.Input( + path: path, + headers: headers, + body: body + )) + } + /// Get cloud evaluation of a position. + /// + /// Get the cached evaluation of a position, if available. + /// Opening positions have more chances of being available. There are about 15 million positions in the database. + /// Up to 5 variations may be available. Variants are supported. + /// Use this endpoint to fetch a few positions here and there. + /// If you want to download a lot of positions, [get the full list](https://database.lichess.org/#evals) from our exported database. + /// + /// + /// - Remark: HTTP `GET /api/cloud-eval`. + /// - Remark: Generated from `#/paths//api/cloud-eval/get(apiCloudEval)`. + internal func apiCloudEval( + query: Operations.apiCloudEval.Input.Query, + headers: Operations.apiCloudEval.Input.Headers = .init() + ) async throws -> Operations.apiCloudEval.Output { + try await apiCloudEval(Operations.apiCloudEval.Input( + query: query, + headers: headers + )) + } + /// List external engines + /// + /// Lists all external engines that have been registered for the user, + /// and the credentials required to use them. + /// + /// + /// - Remark: HTTP `GET /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/get(apiExternalEngineList)`. + internal func apiExternalEngineList(headers: Operations.apiExternalEngineList.Input.Headers = .init()) async throws -> Operations.apiExternalEngineList.Output { + try await apiExternalEngineList(Operations.apiExternalEngineList.Input(headers: headers)) + } + /// Create external engine + /// + /// Registers a new external engine for the user. It can then be selected + /// and used on the analysis board. + /// After registering, the provider should start waiting for analyis requests. + /// + /// + /// - Remark: HTTP `POST /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/post(apiExternalEngineCreate)`. + internal func apiExternalEngineCreate( + headers: Operations.apiExternalEngineCreate.Input.Headers = .init(), + body: Operations.apiExternalEngineCreate.Input.Body + ) async throws -> Operations.apiExternalEngineCreate.Output { + try await apiExternalEngineCreate(Operations.apiExternalEngineCreate.Input( + headers: headers, + body: body + )) + } + /// Get external engine + /// + /// Get properties and credentials of an external engine. + /// + /// + /// - Remark: HTTP `GET /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/get(apiExternalEngineGet)`. + internal func apiExternalEngineGet( + path: Operations.apiExternalEngineGet.Input.Path, + headers: Operations.apiExternalEngineGet.Input.Headers = .init() + ) async throws -> Operations.apiExternalEngineGet.Output { + try await apiExternalEngineGet(Operations.apiExternalEngineGet.Input( + path: path, + headers: headers + )) + } + /// Update external engine + /// + /// Updates the properties of an external engine. + /// + /// + /// - Remark: HTTP `PUT /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/put(apiExternalEnginePut)`. + internal func apiExternalEnginePut( + path: Operations.apiExternalEnginePut.Input.Path, + headers: Operations.apiExternalEnginePut.Input.Headers = .init(), + body: Operations.apiExternalEnginePut.Input.Body + ) async throws -> Operations.apiExternalEnginePut.Output { + try await apiExternalEnginePut(Operations.apiExternalEnginePut.Input( + path: path, + headers: headers, + body: body + )) + } + /// Delete external engine + /// + /// Unregisters an external engine. + /// + /// + /// - Remark: HTTP `DELETE /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/delete(apiExternalEngineDelete)`. + internal func apiExternalEngineDelete( + path: Operations.apiExternalEngineDelete.Input.Path, + headers: Operations.apiExternalEngineDelete.Input.Headers = .init() + ) async throws -> Operations.apiExternalEngineDelete.Output { + try await apiExternalEngineDelete(Operations.apiExternalEngineDelete.Input( + path: path, + headers: headers + )) + } + /// Analyse with external engine + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/{id}/analyse`** + /// Request analysis from an external engine. + /// Response content is streamed as [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). + /// The properties are based on the [UCI specification](https://backscattering.de/chess/uci/#engine). + /// Analysis stops when the client goes away, the requested limit + /// is reached, or the provider goes away. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/{id}/analyse`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/analyse/post(apiExternalEngineAnalyse)`. + internal func apiExternalEngineAnalyse( + path: Operations.apiExternalEngineAnalyse.Input.Path, + headers: Operations.apiExternalEngineAnalyse.Input.Headers = .init(), + body: Operations.apiExternalEngineAnalyse.Input.Body + ) async throws -> Operations.apiExternalEngineAnalyse.Output { + try await apiExternalEngineAnalyse(Operations.apiExternalEngineAnalyse.Input( + path: path, + headers: headers, + body: body + )) + } + /// Acquire analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work`** + /// Wait for an analysis requests to any of the external engines that + /// have been registered with the given `secret`. + /// Uses long polling. + /// After acquiring a request, the provider should immediately + /// [start streaming the results](#tag/External-engine/operation/apiExternalEngineSubmit). + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work`. + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)`. + internal func apiExternalEngineAcquire( + headers: Operations.apiExternalEngineAcquire.Input.Headers = .init(), + body: Operations.apiExternalEngineAcquire.Input.Body + ) async throws -> Operations.apiExternalEngineAcquire.Output { + try await apiExternalEngineAcquire(Operations.apiExternalEngineAcquire.Input( + headers: headers, + body: body + )) + } + /// Answer analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work/{id}`** + /// Submit a stream of analysis as [UCI output](https://backscattering.de/chess/uci/#engine-info). + /// * The engine should always be in `UCI_Chess960` mode. + /// * `UCI_AnalyseMode` enabled if available. + /// * It produces `info` with at least: + /// - `depth` + /// - `multipv` (between 1 and 5) + /// - `score` + /// - `nodes` + /// - `time` + /// - `pv` + /// The server may close the connection at any time, indicating that + /// the requester has gone away and analysis should be stopped. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/work/{id}/post(apiExternalEngineSubmit)`. + internal func apiExternalEngineSubmit( + path: Operations.apiExternalEngineSubmit.Input.Path, + body: Operations.apiExternalEngineSubmit.Input.Body + ) async throws -> Operations.apiExternalEngineSubmit.Output { + try await apiExternalEngineSubmit(Operations.apiExternalEngineSubmit.Input( + path: path, + body: body + )) + } + /// Request authorization code + /// + /// OAuth2 authorization endpoint. + /// Start the OAuth2 Authorization Code Flow with PKCE by securely + /// generating two random strings unique to each authorization + /// request: + /// * `code_verifier` + /// * `state` + /// Store these in session storage. Make sure not to reveal `code_verifier` + /// to eavesdroppers. Do not show it in URLs, do not abuse `state` to store + /// it, do not send it over insecure connections. However it is fine if + /// the user themselves can extract `code_verifier`, which will always be + /// possible for fully client-side apps. + /// Then send the user to this endpoint. They will be prompted to grant + /// authorization and then be redirected back to the given `redirect_uri`. + /// If the authorization failed, the following query string parameters will + /// be appended to the redirection: + /// * `error`, in particular with value `access_denied` if the user + /// cancelled authorization + /// * `error_description` to aid debugging + /// * `state`, exactly as passed in the `state` parameter + /// If the authorization succeeded, the following query string parameters + /// will be appended to the redirection: + /// * `code`, containing a fresh short-lived authorization code + /// * `state`, exactly as passed in the `state` parameter + /// Next, to defend against cross site request forgery, check that the + /// returned `state` matches the `state` you originally generated. + /// Finally, continue by using the authorization code to + /// [obtain an access token](#operation/apiToken). + /// + /// + /// - Remark: HTTP `GET /oauth`. + /// - Remark: Generated from `#/paths//oauth/get(oauth)`. + internal func oauth(query: Operations.oauth.Input.Query) async throws -> Operations.oauth.Output { + try await oauth(Operations.oauth.Input(query: query)) + } + /// Obtain access token + /// + /// OAuth2 token endpoint. Exchanges an authorization code for an access token. + /// + /// + /// - Remark: HTTP `POST /api/token`. + /// - Remark: Generated from `#/paths//api/token/post(apiToken)`. + internal func apiToken( + headers: Operations.apiToken.Input.Headers = .init(), + body: Operations.apiToken.Input.Body + ) async throws -> Operations.apiToken.Output { + try await apiToken(Operations.apiToken.Input( + headers: headers, + body: body + )) + } + /// Revoke access token + /// + /// Revokes the access token sent as Bearer for this request. + /// + /// - Remark: HTTP `DELETE /api/token`. + /// - Remark: Generated from `#/paths//api/token/delete(apiTokenDelete)`. + internal func apiTokenDelete() async throws -> Operations.apiTokenDelete.Output { + try await apiTokenDelete(Operations.apiTokenDelete.Input()) + } + /// Test multiple OAuth tokens + /// + /// For up to 1000 OAuth tokens, + /// returns their associated user ID and scopes, + /// or `null` if the token is invalid. + /// The method is `POST` so a longer list of tokens can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/token/test`. + /// - Remark: Generated from `#/paths//api/token/test/post(tokenTest)`. + internal func tokenTest( + headers: Operations.tokenTest.Input.Headers = .init(), + body: Operations.tokenTest.Input.Body + ) async throws -> Operations.tokenTest.Output { + try await tokenTest(Operations.tokenTest.Input( + headers: headers, + body: body + )) + } + /// Masters database + /// + /// **Endpoint: <https://explorer.lichess.ovh/masters>** + /// Example: `curl https://explorer.lichess.ovh/masters?play=d2d4,d7d5,c2c4,c7c6,c4d5` + /// + /// + /// - Remark: HTTP `GET /masters`. + /// - Remark: Generated from `#/paths//masters/get(openingExplorerMaster)`. + internal func openingExplorerMaster( + query: Operations.openingExplorerMaster.Input.Query = .init(), + headers: Operations.openingExplorerMaster.Input.Headers = .init() + ) async throws -> Operations.openingExplorerMaster.Output { + try await openingExplorerMaster(Operations.openingExplorerMaster.Input( + query: query, + headers: headers + )) + } + /// Lichess games + /// + /// **Endpoint: <https://explorer.lichess.ovh/lichess>** + /// Games sampled from all Lichess players. + /// Example: `curl https://explorer.lichess.ovh/lichess?variant=standard&speeds=blitz,rapid,classical&ratings=2200,2500&fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201` + /// + /// + /// - Remark: HTTP `GET /lichess`. + /// - Remark: Generated from `#/paths//lichess/get(openingExplorerLichess)`. + internal func openingExplorerLichess( + query: Operations.openingExplorerLichess.Input.Query = .init(), + headers: Operations.openingExplorerLichess.Input.Headers = .init() + ) async throws -> Operations.openingExplorerLichess.Output { + try await openingExplorerLichess(Operations.openingExplorerLichess.Input( + query: query, + headers: headers + )) + } + /// Player games + /// + /// **Endpoint: <https://explorer.lichess.ovh/player>** + /// Games of a Lichess player. + /// Responds with a stream of [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). Will start indexing + /// on demand, immediately respond with the current results, and stream + /// more updates until indexing is complete. The stream is throttled + /// and deduplicated. Empty lines may be sent to avoid timeouts. + /// Will index new games at most once per minute, and revisit previously + /// ongoing games at most once every day. + /// Example: `curl https://explorer.lichess.ovh/player?player=revoof&color=white&play=d2d4,d7d5&recentGames=1` + /// + /// + /// - Remark: HTTP `GET /player`. + /// - Remark: Generated from `#/paths//player/get(openingExplorerPlayer)`. + internal func openingExplorerPlayer( + query: Operations.openingExplorerPlayer.Input.Query = .init(), + headers: Operations.openingExplorerPlayer.Input.Headers = .init() + ) async throws -> Operations.openingExplorerPlayer.Output { + try await openingExplorerPlayer(Operations.openingExplorerPlayer.Input( + query: query, + headers: headers + )) + } + /// OTB master game + /// + /// **Endpoint: `https://explorer.lichess.ovh/masters/pgn/{gameId}`** + /// Example: `curl https://explorer.lichess.ovh/masters/pgn/aAbqI4ey` + /// + /// + /// - Remark: HTTP `GET /master/pgn/{gameId}`. + /// - Remark: Generated from `#/paths//master/pgn/{gameId}/get(openingExplorerMasterGame)`. + internal func openingExplorerMasterGame( + path: Operations.openingExplorerMasterGame.Input.Path, + headers: Operations.openingExplorerMasterGame.Input.Headers = .init() + ) async throws -> Operations.openingExplorerMasterGame.Output { + try await openingExplorerMasterGame(Operations.openingExplorerMasterGame.Input( + path: path, + headers: headers + )) + } + /// Tablebase lookup + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// Example: `curl http://tablebase.lichess.ovh/standard?fen=4k3/6KP/8/8/8/8/7p/8_w_-_-_0_1` + /// + /// + /// - Remark: HTTP `GET /standard`. + /// - Remark: Generated from `#/paths//standard/get(tablebaseStandard)`. + internal func tablebaseStandard( + query: Operations.tablebaseStandard.Input.Query, + headers: Operations.tablebaseStandard.Input.Headers = .init() + ) async throws -> Operations.tablebaseStandard.Output { + try await tablebaseStandard(Operations.tablebaseStandard.Input( + query: query, + headers: headers + )) + } + /// Tablebase lookup for Atomic chess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /atomic`. + /// - Remark: Generated from `#/paths//atomic/get(tablebaseAtomic)`. + internal func tablebaseAtomic(headers: Operations.tablebaseAtomic.Input.Headers = .init()) async throws -> Operations.tablebaseAtomic.Output { + try await tablebaseAtomic(Operations.tablebaseAtomic.Input(headers: headers)) + } + /// Tablebase lookup for Antichess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /antichess`. + /// - Remark: Generated from `#/paths//antichess/get(antichessAtomic)`. + internal func antichessAtomic(headers: Operations.antichessAtomic.Input.Headers = .init()) async throws -> Operations.antichessAtomic.Output { + try await antichessAtomic(Operations.antichessAtomic.Input(headers: headers)) + } +} + +/// Server URLs defined in the OpenAPI document. +internal enum Servers { + internal static func server1() throws -> Foundation.URL { + try Foundation.URL( + validatingOpenAPIServerURL: "https://lichess.org", + variables: [] + ) + } +} + +/// Types generated from the components section of the OpenAPI document. +internal enum Components { + /// Types generated from the `#/components/schemas` section of the OpenAPI document. + internal enum Schemas { + /// - Remark: Generated from `#/components/schemas/Top10s`. + internal typealias Top10s = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Leaderboard`. + internal typealias Leaderboard = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Perf`. + internal struct Perf: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Perf/games`. + internal var games: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Perf/rating`. + internal var rating: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Perf/rd`. + internal var rd: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Perf/prog`. + internal var prog: Swift.Int? + /// only appears if a user's perf rating are [provisional](https://lichess.org/faq#provisional) + /// + /// - Remark: Generated from `#/components/schemas/Perf/prov`. + internal var prov: Swift.Bool? + /// Creates a new `Perf`. + /// + /// - Parameters: + /// - games: + /// - rating: + /// - rd: + /// - prog: + /// - prov: only appears if a user's perf rating are [provisional](https://lichess.org/faq#provisional) + internal init( + games: Swift.Int? = nil, + rating: Swift.Int? = nil, + rd: Swift.Int? = nil, + prog: Swift.Int? = nil, + prov: Swift.Bool? = nil + ) { + self.games = games + self.rating = rating + self.rd = rd + self.prog = prog + self.prov = prov + } + internal enum CodingKeys: String, CodingKey { + case games + case rating + case rd + case prog + case prov + } + } + /// - Remark: Generated from `#/components/schemas/PuzzleModePerf`. + internal struct PuzzleModePerf: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/PuzzleModePerf/runs`. + internal var runs: Swift.Int? + /// - Remark: Generated from `#/components/schemas/PuzzleModePerf/score`. + internal var score: Swift.Int? + /// Creates a new `PuzzleModePerf`. + /// + /// - Parameters: + /// - runs: + /// - score: + internal init( + runs: Swift.Int? = nil, + score: Swift.Int? = nil + ) { + self.runs = runs + self.score = score + } + internal enum CodingKeys: String, CodingKey { + case runs + case score + } + } + /// - Remark: Generated from `#/components/schemas/Perfs`. + internal struct Perfs: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Perfs/chess960`. + internal var chess960: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/atomic`. + internal var atomic: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/racingKings`. + internal var racingKings: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/ultraBullet`. + internal var ultraBullet: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/blitz`. + internal var blitz: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/kingOfTheHill`. + internal var kingOfTheHill: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/bullet`. + internal var bullet: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/correspondence`. + internal var correspondence: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/horde`. + internal var horde: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/puzzle`. + internal var puzzle: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/classical`. + internal var classical: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/rapid`. + internal var rapid: Components.Schemas.Perf? + /// - Remark: Generated from `#/components/schemas/Perfs/storm`. + internal var storm: Components.Schemas.PuzzleModePerf? + /// - Remark: Generated from `#/components/schemas/Perfs/racer`. + internal var racer: Components.Schemas.PuzzleModePerf? + /// - Remark: Generated from `#/components/schemas/Perfs/streak`. + internal var streak: Components.Schemas.PuzzleModePerf? + /// Creates a new `Perfs`. + /// + /// - Parameters: + /// - chess960: + /// - atomic: + /// - racingKings: + /// - ultraBullet: + /// - blitz: + /// - kingOfTheHill: + /// - bullet: + /// - correspondence: + /// - horde: + /// - puzzle: + /// - classical: + /// - rapid: + /// - storm: + /// - racer: + /// - streak: + internal init( + chess960: Components.Schemas.Perf? = nil, + atomic: Components.Schemas.Perf? = nil, + racingKings: Components.Schemas.Perf? = nil, + ultraBullet: Components.Schemas.Perf? = nil, + blitz: Components.Schemas.Perf? = nil, + kingOfTheHill: Components.Schemas.Perf? = nil, + bullet: Components.Schemas.Perf? = nil, + correspondence: Components.Schemas.Perf? = nil, + horde: Components.Schemas.Perf? = nil, + puzzle: Components.Schemas.Perf? = nil, + classical: Components.Schemas.Perf? = nil, + rapid: Components.Schemas.Perf? = nil, + storm: Components.Schemas.PuzzleModePerf? = nil, + racer: Components.Schemas.PuzzleModePerf? = nil, + streak: Components.Schemas.PuzzleModePerf? = nil + ) { + self.chess960 = chess960 + self.atomic = atomic + self.racingKings = racingKings + self.ultraBullet = ultraBullet + self.blitz = blitz + self.kingOfTheHill = kingOfTheHill + self.bullet = bullet + self.correspondence = correspondence + self.horde = horde + self.puzzle = puzzle + self.classical = classical + self.rapid = rapid + self.storm = storm + self.racer = racer + self.streak = streak + } + internal enum CodingKeys: String, CodingKey { + case chess960 + case atomic + case racingKings + case ultraBullet + case blitz + case kingOfTheHill + case bullet + case correspondence + case horde + case puzzle + case classical + case rapid + case storm + case racer + case streak + } + } + /// - Remark: Generated from `#/components/schemas/Profile`. + internal struct Profile: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Profile/country`. + internal var country: Swift.String? + /// - Remark: Generated from `#/components/schemas/Profile/location`. + internal var location: Swift.String? + /// - Remark: Generated from `#/components/schemas/Profile/bio`. + internal var bio: Swift.String? + /// - Remark: Generated from `#/components/schemas/Profile/firstName`. + internal var firstName: Swift.String? + /// - Remark: Generated from `#/components/schemas/Profile/lastName`. + internal var lastName: Swift.String? + /// only appears if a user has set them + /// + /// - Remark: Generated from `#/components/schemas/Profile/fideRating`. + internal var fideRating: Swift.Int? + /// only appears if a user has set them + /// + /// - Remark: Generated from `#/components/schemas/Profile/uscfRating`. + internal var uscfRating: Swift.Int? + /// only appears if a user has set them + /// + /// - Remark: Generated from `#/components/schemas/Profile/ecfRating`. + internal var ecfRating: Swift.Int? + /// only appears if a user has set them + /// + /// - Remark: Generated from `#/components/schemas/Profile/cfcRating`. + internal var cfcRating: Swift.Int? + /// only appears if a user has set them + /// + /// - Remark: Generated from `#/components/schemas/Profile/dsbRating`. + internal var dsbRating: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Profile/links`. + internal var links: Swift.String? + /// Creates a new `Profile`. + /// + /// - Parameters: + /// - country: + /// - location: + /// - bio: + /// - firstName: + /// - lastName: + /// - fideRating: only appears if a user has set them + /// - uscfRating: only appears if a user has set them + /// - ecfRating: only appears if a user has set them + /// - cfcRating: only appears if a user has set them + /// - dsbRating: only appears if a user has set them + /// - links: + internal init( + country: Swift.String? = nil, + location: Swift.String? = nil, + bio: Swift.String? = nil, + firstName: Swift.String? = nil, + lastName: Swift.String? = nil, + fideRating: Swift.Int? = nil, + uscfRating: Swift.Int? = nil, + ecfRating: Swift.Int? = nil, + cfcRating: Swift.Int? = nil, + dsbRating: Swift.Int? = nil, + links: Swift.String? = nil + ) { + self.country = country + self.location = location + self.bio = bio + self.firstName = firstName + self.lastName = lastName + self.fideRating = fideRating + self.uscfRating = uscfRating + self.ecfRating = ecfRating + self.cfcRating = cfcRating + self.dsbRating = dsbRating + self.links = links + } + internal enum CodingKeys: String, CodingKey { + case country + case location + case bio + case firstName + case lastName + case fideRating + case uscfRating + case ecfRating + case cfcRating + case dsbRating + case links + } + } + /// - Remark: Generated from `#/components/schemas/PlayTime`. + internal struct PlayTime: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/PlayTime/total`. + internal var total: Swift.Int? + /// - Remark: Generated from `#/components/schemas/PlayTime/tv`. + internal var tv: Swift.Int? + /// Creates a new `PlayTime`. + /// + /// - Parameters: + /// - total: + /// - tv: + internal init( + total: Swift.Int? = nil, + tv: Swift.Int? = nil + ) { + self.total = total + self.tv = tv + } + internal enum CodingKeys: String, CodingKey { + case total + case tv + } + } + /// only appears if the user is a titled player or a bot user + /// + /// - Remark: Generated from `#/components/schemas/Title`. + @frozen internal enum Title: String, Codable, Hashable, Sendable { + case GM = "GM" + case WGM = "WGM" + case IM = "IM" + case WIM = "WIM" + case FM = "FM" + case WFM = "WFM" + case NM = "NM" + case CM = "CM" + case WCM = "WCM" + case WNM = "WNM" + case LM = "LM" + case BOT = "BOT" + } + /// - Remark: Generated from `#/components/schemas/User`. + internal struct User: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/User/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/User/username`. + internal var username: Swift.String? + /// - Remark: Generated from `#/components/schemas/User/perfs`. + internal var perfs: Components.Schemas.Perfs? + /// - Remark: Generated from `#/components/schemas/User/flair`. + internal var flair: Swift.String? + /// - Remark: Generated from `#/components/schemas/User/createdAt`. + internal var createdAt: Swift.Int64? + /// only appears if a user's account is closed + /// + /// - Remark: Generated from `#/components/schemas/User/disabled`. + internal var disabled: Swift.Bool? + /// only appears if a user's account is marked for the violation of [Lichess TOS](https://lichess.org/terms-of-service) + /// + /// - Remark: Generated from `#/components/schemas/User/tosViolation`. + internal var tosViolation: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/User/profile`. + internal var profile: Components.Schemas.Profile? + /// - Remark: Generated from `#/components/schemas/User/seenAt`. + internal var seenAt: Swift.Int64? + /// - Remark: Generated from `#/components/schemas/User/patron`. + internal var patron: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/User/verified`. + internal var verified: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/User/playTime`. + internal var playTime: Components.Schemas.PlayTime? + /// - Remark: Generated from `#/components/schemas/User/title`. + internal var title: Components.Schemas.Title? + /// Creates a new `User`. + /// + /// - Parameters: + /// - id: + /// - username: + /// - perfs: + /// - flair: + /// - createdAt: + /// - disabled: only appears if a user's account is closed + /// - tosViolation: only appears if a user's account is marked for the violation of [Lichess TOS](https://lichess.org/terms-of-service) + /// - profile: + /// - seenAt: + /// - patron: + /// - verified: + /// - playTime: + /// - title: + internal init( + id: Swift.String? = nil, + username: Swift.String? = nil, + perfs: Components.Schemas.Perfs? = nil, + flair: Swift.String? = nil, + createdAt: Swift.Int64? = nil, + disabled: Swift.Bool? = nil, + tosViolation: Swift.Bool? = nil, + profile: Components.Schemas.Profile? = nil, + seenAt: Swift.Int64? = nil, + patron: Swift.Bool? = nil, + verified: Swift.Bool? = nil, + playTime: Components.Schemas.PlayTime? = nil, + title: Components.Schemas.Title? = nil + ) { + self.id = id + self.username = username + self.perfs = perfs + self.flair = flair + self.createdAt = createdAt + self.disabled = disabled + self.tosViolation = tosViolation + self.profile = profile + self.seenAt = seenAt + self.patron = patron + self.verified = verified + self.playTime = playTime + self.title = title + } + internal enum CodingKeys: String, CodingKey { + case id + case username + case perfs + case flair + case createdAt + case disabled + case tosViolation + case profile + case seenAt + case patron + case verified + case playTime + case title + } + } + /// - Remark: Generated from `#/components/schemas/Count`. + internal struct Count: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Count/all`. + internal var all: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/rated`. + internal var rated: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/ai`. + internal var ai: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/draw`. + internal var draw: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/drawH`. + internal var drawH: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/loss`. + internal var loss: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/lossH`. + internal var lossH: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/win`. + internal var win: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/winH`. + internal var winH: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/bookmark`. + internal var bookmark: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/playing`. + internal var playing: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/import`. + internal var _import: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Count/me`. + internal var me: Swift.Int? + /// Creates a new `Count`. + /// + /// - Parameters: + /// - all: + /// - rated: + /// - ai: + /// - draw: + /// - drawH: + /// - loss: + /// - lossH: + /// - win: + /// - winH: + /// - bookmark: + /// - playing: + /// - _import: + /// - me: + internal init( + all: Swift.Int? = nil, + rated: Swift.Int? = nil, + ai: Swift.Int? = nil, + draw: Swift.Int? = nil, + drawH: Swift.Int? = nil, + loss: Swift.Int? = nil, + lossH: Swift.Int? = nil, + win: Swift.Int? = nil, + winH: Swift.Int? = nil, + bookmark: Swift.Int? = nil, + playing: Swift.Int? = nil, + _import: Swift.Int? = nil, + me: Swift.Int? = nil + ) { + self.all = all + self.rated = rated + self.ai = ai + self.draw = draw + self.drawH = drawH + self.loss = loss + self.lossH = lossH + self.win = win + self.winH = winH + self.bookmark = bookmark + self.playing = playing + self._import = _import + self.me = me + } + internal enum CodingKeys: String, CodingKey { + case all + case rated + case ai + case draw + case drawH + case loss + case lossH + case win + case winH + case bookmark + case playing + case _import = "import" + case me + } + } + /// - Remark: Generated from `#/components/schemas/UserExtended`. + internal struct UserExtended: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/UserExtended/value1`. + internal var value1: Components.Schemas.User + /// - Remark: Generated from `#/components/schemas/UserExtended/value2`. + internal struct Value2Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/url`. + internal var url: Swift.String? + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/playing`. + internal var playing: Swift.String? + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/count`. + internal var count: Components.Schemas.Count? + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/streaming`. + internal var streaming: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/streamer`. + internal var streamer: OpenAPIRuntime.OpenAPIValueContainer? + /// only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/followable`. + internal var followable: Swift.Bool? + /// only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/following`. + internal var following: Swift.Bool? + /// only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/blocking`. + internal var blocking: Swift.Bool? + /// only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// + /// - Remark: Generated from `#/components/schemas/UserExtended/value2/followsYou`. + internal var followsYou: Swift.Bool? + /// Creates a new `Value2Payload`. + /// + /// - Parameters: + /// - url: + /// - playing: + /// - count: + /// - streaming: + /// - streamer: + /// - followable: only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// - following: only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// - blocking: only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + /// - followsYou: only appears if the request is [authenticated with OAuth2](#section/Introduction/Authentication) + internal init( + url: Swift.String? = nil, + playing: Swift.String? = nil, + count: Components.Schemas.Count? = nil, + streaming: Swift.Bool? = nil, + streamer: OpenAPIRuntime.OpenAPIValueContainer? = nil, + followable: Swift.Bool? = nil, + following: Swift.Bool? = nil, + blocking: Swift.Bool? = nil, + followsYou: Swift.Bool? = nil + ) { + self.url = url + self.playing = playing + self.count = count + self.streaming = streaming + self.streamer = streamer + self.followable = followable + self.following = following + self.blocking = blocking + self.followsYou = followsYou + } + internal enum CodingKeys: String, CodingKey { + case url + case playing + case count + case streaming + case streamer + case followable + case following + case blocking + case followsYou + } + } + /// - Remark: Generated from `#/components/schemas/UserExtended/value2`. + internal var value2: Components.Schemas.UserExtended.Value2Payload + /// Creates a new `UserExtended`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Components.Schemas.User, + value2: Components.Schemas.UserExtended.Value2Payload + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + value1 = try .init(from: decoder) + value2 = try .init(from: decoder) + } + internal func encode(to encoder: any Encoder) throws { + try value1.encode(to: encoder) + try value2.encode(to: encoder) + } + } + /// - Remark: Generated from `#/components/schemas/RatingHistory`. + internal typealias RatingHistory = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/PerfType`. + @frozen internal enum PerfType: String, Codable, Hashable, Sendable { + case ultraBullet = "ultraBullet" + case bullet = "bullet" + case blitz = "blitz" + case rapid = "rapid" + case classical = "classical" + case correspondence = "correspondence" + case chess960 = "chess960" + case crazyhouse = "crazyhouse" + case antichess = "antichess" + case atomic = "atomic" + case horde = "horde" + case kingOfTheHill = "kingOfTheHill" + case racingKings = "racingKings" + case threeCheck = "threeCheck" + } + /// - Remark: Generated from `#/components/schemas/PerfStat`. + internal typealias PerfStat = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/PuzzleAndGame`. + internal typealias PuzzleAndGame = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/PuzzleRoundJson`. + internal struct PuzzleRoundJson: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/PuzzleRoundJson/date`. + internal var date: Swift.Double? + /// - Remark: Generated from `#/components/schemas/PuzzleRoundJson/win`. + internal var win: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/PuzzleRoundJson/puzzle`. + internal var puzzle: OpenAPIRuntime.OpenAPIObjectContainer? + /// Creates a new `PuzzleRoundJson`. + /// + /// - Parameters: + /// - date: + /// - win: + /// - puzzle: + internal init( + date: Swift.Double? = nil, + win: Swift.Bool? = nil, + puzzle: OpenAPIRuntime.OpenAPIObjectContainer? = nil + ) { + self.date = date + self.win = win + self.puzzle = puzzle + } + internal enum CodingKeys: String, CodingKey { + case date + case win + case puzzle + } + } + /// - Remark: Generated from `#/components/schemas/PuzzleDashboardJson`. + internal typealias PuzzleDashboardJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/StormDashboardJson`. + internal typealias StormDashboardJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/PuzzleRaceJson`. + internal typealias PuzzleRaceJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/UserPreferences`. + internal struct UserPreferences: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/UserPreferences/dark`. + internal var dark: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/transp`. + internal var transp: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/bgImg`. + internal var bgImg: Swift.String? + /// - Remark: Generated from `#/components/schemas/UserPreferences/is3d`. + internal var is3d: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/theme`. + @frozen internal enum themePayload: String, Codable, Hashable, Sendable { + case blue = "blue" + case blue2 = "blue2" + case blue3 = "blue3" + case blue_hyphen_marble = "blue-marble" + case canvas = "canvas" + case wood = "wood" + case wood2 = "wood2" + case wood3 = "wood3" + case wood4 = "wood4" + case maple = "maple" + case maple2 = "maple2" + case brown = "brown" + case leather = "leather" + case green = "green" + case marble = "marble" + case green_hyphen_plastic = "green-plastic" + case grey = "grey" + case metal = "metal" + case olive = "olive" + case newspaper = "newspaper" + case purple = "purple" + case purple_hyphen_diag = "purple-diag" + case pink = "pink" + case ic = "ic" + } + /// - Remark: Generated from `#/components/schemas/UserPreferences/theme`. + internal var theme: Components.Schemas.UserPreferences.themePayload? + /// - Remark: Generated from `#/components/schemas/UserPreferences/pieceSet`. + @frozen internal enum pieceSetPayload: String, Codable, Hashable, Sendable { + case cburnett = "cburnett" + case merida = "merida" + case alpha = "alpha" + case pirouetti = "pirouetti" + case chessnut = "chessnut" + case chess7 = "chess7" + case reillycraig = "reillycraig" + case companion = "companion" + case riohacha = "riohacha" + case kosal = "kosal" + case leipzig = "leipzig" + case fantasy = "fantasy" + case spatial = "spatial" + case california = "california" + case pixel = "pixel" + case maestro = "maestro" + case fresca = "fresca" + case cardinal = "cardinal" + case gioco = "gioco" + case tatiana = "tatiana" + case staunty = "staunty" + case governor = "governor" + case dubrovny = "dubrovny" + case icpieces = "icpieces" + case shapes = "shapes" + case letter = "letter" + } + /// - Remark: Generated from `#/components/schemas/UserPreferences/pieceSet`. + internal var pieceSet: Components.Schemas.UserPreferences.pieceSetPayload? + /// - Remark: Generated from `#/components/schemas/UserPreferences/theme3d`. + @frozen internal enum theme3dPayload: String, Codable, Hashable, Sendable { + case Black_hyphen_White_hyphen_Aluminium = "Black-White-Aluminium" + case Brushed_hyphen_Aluminium = "Brushed-Aluminium" + case China_hyphen_Blue = "China-Blue" + case China_hyphen_Green = "China-Green" + case China_hyphen_Grey = "China-Grey" + case China_hyphen_Scarlet = "China-Scarlet" + case Classic_hyphen_Blue = "Classic-Blue" + case Gold_hyphen_Silver = "Gold-Silver" + case Light_hyphen_Wood = "Light-Wood" + case Power_hyphen_Coated = "Power-Coated" + case Rosewood = "Rosewood" + case Marble = "Marble" + case Wax = "Wax" + case Jade = "Jade" + case Woodi = "Woodi" + } + /// - Remark: Generated from `#/components/schemas/UserPreferences/theme3d`. + internal var theme3d: Components.Schemas.UserPreferences.theme3dPayload? + /// - Remark: Generated from `#/components/schemas/UserPreferences/pieceSet3d`. + @frozen internal enum pieceSet3dPayload: String, Codable, Hashable, Sendable { + case Basic = "Basic" + case Wood = "Wood" + case Metal = "Metal" + case RedVBlue = "RedVBlue" + case ModernJade = "ModernJade" + case ModernWood = "ModernWood" + case Glass = "Glass" + case Trimmed = "Trimmed" + case Experimental = "Experimental" + case Staunton = "Staunton" + case CubesAndPi = "CubesAndPi" + } + /// - Remark: Generated from `#/components/schemas/UserPreferences/pieceSet3d`. + internal var pieceSet3d: Components.Schemas.UserPreferences.pieceSet3dPayload? + /// - Remark: Generated from `#/components/schemas/UserPreferences/soundSet`. + @frozen internal enum soundSetPayload: String, Codable, Hashable, Sendable { + case silent = "silent" + case standard = "standard" + case piano = "piano" + case nes = "nes" + case sfx = "sfx" + case futuristic = "futuristic" + case robot = "robot" + case music = "music" + case speech = "speech" + } + /// - Remark: Generated from `#/components/schemas/UserPreferences/soundSet`. + internal var soundSet: Components.Schemas.UserPreferences.soundSetPayload? + /// - Remark: Generated from `#/components/schemas/UserPreferences/blindfold`. + internal var blindfold: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/autoQueen`. + internal var autoQueen: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/autoThreefold`. + internal var autoThreefold: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/takeback`. + internal var takeback: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/moretime`. + internal var moretime: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/clockTenths`. + internal var clockTenths: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/clockBar`. + internal var clockBar: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/clockSound`. + internal var clockSound: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/premove`. + internal var premove: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/animation`. + internal var animation: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/captured`. + internal var captured: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/follow`. + internal var follow: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/highlight`. + internal var highlight: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/destination`. + internal var destination: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/UserPreferences/coords`. + internal var coords: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/replay`. + internal var replay: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/challenge`. + internal var challenge: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/message`. + internal var message: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/coordColor`. + internal var coordColor: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/submitMove`. + internal var submitMove: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/confirmResign`. + internal var confirmResign: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/insightShare`. + internal var insightShare: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/keyboardMove`. + internal var keyboardMove: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/zen`. + internal var zen: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/moveEvent`. + internal var moveEvent: Swift.Int? + /// - Remark: Generated from `#/components/schemas/UserPreferences/rookCastle`. + internal var rookCastle: Swift.Int? + /// Creates a new `UserPreferences`. + /// + /// - Parameters: + /// - dark: + /// - transp: + /// - bgImg: + /// - is3d: + /// - theme: + /// - pieceSet: + /// - theme3d: + /// - pieceSet3d: + /// - soundSet: + /// - blindfold: + /// - autoQueen: + /// - autoThreefold: + /// - takeback: + /// - moretime: + /// - clockTenths: + /// - clockBar: + /// - clockSound: + /// - premove: + /// - animation: + /// - captured: + /// - follow: + /// - highlight: + /// - destination: + /// - coords: + /// - replay: + /// - challenge: + /// - message: + /// - coordColor: + /// - submitMove: + /// - confirmResign: + /// - insightShare: + /// - keyboardMove: + /// - zen: + /// - moveEvent: + /// - rookCastle: + internal init( + dark: Swift.Bool? = nil, + transp: Swift.Bool? = nil, + bgImg: Swift.String? = nil, + is3d: Swift.Bool? = nil, + theme: Components.Schemas.UserPreferences.themePayload? = nil, + pieceSet: Components.Schemas.UserPreferences.pieceSetPayload? = nil, + theme3d: Components.Schemas.UserPreferences.theme3dPayload? = nil, + pieceSet3d: Components.Schemas.UserPreferences.pieceSet3dPayload? = nil, + soundSet: Components.Schemas.UserPreferences.soundSetPayload? = nil, + blindfold: Swift.Int? = nil, + autoQueen: Swift.Int? = nil, + autoThreefold: Swift.Int? = nil, + takeback: Swift.Int? = nil, + moretime: Swift.Int? = nil, + clockTenths: Swift.Int? = nil, + clockBar: Swift.Bool? = nil, + clockSound: Swift.Bool? = nil, + premove: Swift.Bool? = nil, + animation: Swift.Int? = nil, + captured: Swift.Bool? = nil, + follow: Swift.Bool? = nil, + highlight: Swift.Bool? = nil, + destination: Swift.Bool? = nil, + coords: Swift.Int? = nil, + replay: Swift.Int? = nil, + challenge: Swift.Int? = nil, + message: Swift.Int? = nil, + coordColor: Swift.Int? = nil, + submitMove: Swift.Int? = nil, + confirmResign: Swift.Int? = nil, + insightShare: Swift.Int? = nil, + keyboardMove: Swift.Int? = nil, + zen: Swift.Int? = nil, + moveEvent: Swift.Int? = nil, + rookCastle: Swift.Int? = nil + ) { + self.dark = dark + self.transp = transp + self.bgImg = bgImg + self.is3d = is3d + self.theme = theme + self.pieceSet = pieceSet + self.theme3d = theme3d + self.pieceSet3d = pieceSet3d + self.soundSet = soundSet + self.blindfold = blindfold + self.autoQueen = autoQueen + self.autoThreefold = autoThreefold + self.takeback = takeback + self.moretime = moretime + self.clockTenths = clockTenths + self.clockBar = clockBar + self.clockSound = clockSound + self.premove = premove + self.animation = animation + self.captured = captured + self.follow = follow + self.highlight = highlight + self.destination = destination + self.coords = coords + self.replay = replay + self.challenge = challenge + self.message = message + self.coordColor = coordColor + self.submitMove = submitMove + self.confirmResign = confirmResign + self.insightShare = insightShare + self.keyboardMove = keyboardMove + self.zen = zen + self.moveEvent = moveEvent + self.rookCastle = rookCastle + } + internal enum CodingKeys: String, CodingKey { + case dark + case transp + case bgImg + case is3d + case theme + case pieceSet + case theme3d + case pieceSet3d + case soundSet + case blindfold + case autoQueen + case autoThreefold + case takeback + case moretime + case clockTenths + case clockBar + case clockSound + case premove + case animation + case captured + case follow + case highlight + case destination + case coords + case replay + case challenge + case message + case coordColor + case submitMove + case confirmResign + case insightShare + case keyboardMove + case zen + case moveEvent + case rookCastle + } + } + /// - Remark: Generated from `#/components/schemas/Ok`. + internal struct Ok: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Ok/ok`. + internal var ok: Swift.Bool? + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - ok: + internal init(ok: Swift.Bool? = nil) { + self.ok = ok + } + internal enum CodingKeys: String, CodingKey { + case ok + } + } + /// - Remark: Generated from `#/components/schemas/Timeline`. + internal struct Timeline: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Timeline/entries`. + internal var entries: OpenAPIRuntime.OpenAPIArrayContainer? + /// - Remark: Generated from `#/components/schemas/Timeline/users`. + internal var users: OpenAPIRuntime.OpenAPIObjectContainer? + /// Creates a new `Timeline`. + /// + /// - Parameters: + /// - entries: + /// - users: + internal init( + entries: OpenAPIRuntime.OpenAPIArrayContainer? = nil, + users: OpenAPIRuntime.OpenAPIObjectContainer? = nil + ) { + self.entries = entries + self.users = users + } + internal enum CodingKeys: String, CodingKey { + case entries + case users + } + } + /// - Remark: Generated from `#/components/schemas/GamePgn`. + internal typealias GamePgn = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/VariantKey`. + @frozen internal enum VariantKey: String, Codable, Hashable, Sendable { + case standard = "standard" + case chess960 = "chess960" + case crazyhouse = "crazyhouse" + case antichess = "antichess" + case atomic = "atomic" + case horde = "horde" + case kingOfTheHill = "kingOfTheHill" + case racingKings = "racingKings" + case threeCheck = "threeCheck" + case fromPosition = "fromPosition" + } + /// - Remark: Generated from `#/components/schemas/Speed`. + @frozen internal enum Speed: String, Codable, Hashable, Sendable { + case ultraBullet = "ultraBullet" + case bullet = "bullet" + case blitz = "blitz" + case rapid = "rapid" + case classical = "classical" + case correspondence = "correspondence" + } + /// Game status code. https://github.com/lichess-org/scalachess/blob/0a7d6f2c63b1ca06cd3c958ed3264e738af5c5f6/src/main/scala/Status.scala#L16-L28 + /// + /// - Remark: Generated from `#/components/schemas/GameStatus`. + @frozen internal enum GameStatus: String, Codable, Hashable, Sendable { + case created = "created" + case started = "started" + case aborted = "aborted" + case mate = "mate" + case resign = "resign" + case stalemate = "stalemate" + case timeout = "timeout" + case draw = "draw" + case outoftime = "outoftime" + case cheat = "cheat" + case noStart = "noStart" + case unknownFinish = "unknownFinish" + case variantEnd = "variantEnd" + } + /// - Remark: Generated from `#/components/schemas/LightUser`. + internal struct LightUser: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/LightUser/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/components/schemas/LightUser/name`. + internal var name: Swift.String + /// - Remark: Generated from `#/components/schemas/LightUser/title`. + internal var title: Components.Schemas.Title? + /// - Remark: Generated from `#/components/schemas/LightUser/patron`. + internal var patron: Swift.Bool? + /// Creates a new `LightUser`. + /// + /// - Parameters: + /// - id: + /// - name: + /// - title: + /// - patron: + internal init( + id: Swift.String, + name: Swift.String, + title: Components.Schemas.Title? = nil, + patron: Swift.Bool? = nil + ) { + self.id = id + self.name = name + self.title = title + self.patron = patron + } + internal enum CodingKeys: String, CodingKey { + case id + case name + case title + case patron + } + } + /// - Remark: Generated from `#/components/schemas/GameUser`. + internal struct GameUser: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameUser/user`. + internal var user: Components.Schemas.LightUser? + /// - Remark: Generated from `#/components/schemas/GameUser/rating`. + internal var rating: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameUser/ratingDiff`. + internal var ratingDiff: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameUser/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameUser/provisional`. + internal var provisional: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/GameUser/aiLevel`. + internal var aiLevel: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameUser/analysis`. + internal struct analysisPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameUser/analysis/inaccuracy`. + internal var inaccuracy: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameUser/analysis/mistake`. + internal var mistake: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameUser/analysis/blunder`. + internal var blunder: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameUser/analysis/acpl`. + internal var acpl: Swift.Double + /// Creates a new `analysisPayload`. + /// + /// - Parameters: + /// - inaccuracy: + /// - mistake: + /// - blunder: + /// - acpl: + internal init( + inaccuracy: Swift.Double, + mistake: Swift.Double, + blunder: Swift.Double, + acpl: Swift.Double + ) { + self.inaccuracy = inaccuracy + self.mistake = mistake + self.blunder = blunder + self.acpl = acpl + } + internal enum CodingKeys: String, CodingKey { + case inaccuracy + case mistake + case blunder + case acpl + } + } + /// - Remark: Generated from `#/components/schemas/GameUser/analysis`. + internal var analysis: Components.Schemas.GameUser.analysisPayload? + /// - Remark: Generated from `#/components/schemas/GameUser/team`. + internal var team: Swift.String? + /// Creates a new `GameUser`. + /// + /// - Parameters: + /// - user: + /// - rating: + /// - ratingDiff: + /// - name: + /// - provisional: + /// - aiLevel: + /// - analysis: + /// - team: + internal init( + user: Components.Schemas.LightUser? = nil, + rating: Swift.Double? = nil, + ratingDiff: Swift.Double? = nil, + name: Swift.String? = nil, + provisional: Swift.Bool? = nil, + aiLevel: Swift.Double? = nil, + analysis: Components.Schemas.GameUser.analysisPayload? = nil, + team: Swift.String? = nil + ) { + self.user = user + self.rating = rating + self.ratingDiff = ratingDiff + self.name = name + self.provisional = provisional + self.aiLevel = aiLevel + self.analysis = analysis + self.team = team + } + internal enum CodingKeys: String, CodingKey { + case user + case rating + case ratingDiff + case name + case provisional + case aiLevel + case analysis + case team + } + } + /// - Remark: Generated from `#/components/schemas/GameJson`. + internal struct GameJson: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameJson/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/components/schemas/GameJson/rated`. + internal var rated: Swift.Bool + /// - Remark: Generated from `#/components/schemas/GameJson/variant`. + internal var variant: Components.Schemas.VariantKey + /// - Remark: Generated from `#/components/schemas/GameJson/speed`. + internal var speed: Components.Schemas.Speed + /// - Remark: Generated from `#/components/schemas/GameJson/perf`. + internal var perf: Swift.String + /// - Remark: Generated from `#/components/schemas/GameJson/createdAt`. + internal var createdAt: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameJson/lastMoveAt`. + internal var lastMoveAt: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameJson/status`. + internal var status: Components.Schemas.GameStatus + /// - Remark: Generated from `#/components/schemas/GameJson/players`. + internal struct playersPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameJson/players/white`. + internal var white: Components.Schemas.GameUser? + /// - Remark: Generated from `#/components/schemas/GameJson/players/black`. + internal var black: Components.Schemas.GameUser? + /// Creates a new `playersPayload`. + /// + /// - Parameters: + /// - white: + /// - black: + internal init( + white: Components.Schemas.GameUser? = nil, + black: Components.Schemas.GameUser? = nil + ) { + self.white = white + self.black = black + } + internal enum CodingKeys: String, CodingKey { + case white + case black + } + } + /// - Remark: Generated from `#/components/schemas/GameJson/players`. + internal var players: Components.Schemas.GameJson.playersPayload + /// - Remark: Generated from `#/components/schemas/GameJson/initialFen`. + internal var initialFen: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/winner`. + @frozen internal enum winnerPayload: String, Codable, Hashable, Sendable { + case white = "white" + case black = "black" + } + /// - Remark: Generated from `#/components/schemas/GameJson/winner`. + internal var winner: Components.Schemas.GameJson.winnerPayload? + /// - Remark: Generated from `#/components/schemas/GameJson/opening`. + internal struct openingPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameJson/opening/eco`. + internal var eco: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/opening/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/opening/ply`. + internal var ply: Swift.Double? + /// Creates a new `openingPayload`. + /// + /// - Parameters: + /// - eco: + /// - name: + /// - ply: + internal init( + eco: Swift.String? = nil, + name: Swift.String? = nil, + ply: Swift.Double? = nil + ) { + self.eco = eco + self.name = name + self.ply = ply + } + internal enum CodingKeys: String, CodingKey { + case eco + case name + case ply + } + } + /// - Remark: Generated from `#/components/schemas/GameJson/opening`. + internal var opening: Components.Schemas.GameJson.openingPayload? + /// - Remark: Generated from `#/components/schemas/GameJson/moves`. + internal var moves: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/pgn`. + internal var pgn: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/daysPerTurn`. + internal var daysPerTurn: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload`. + internal struct analysisPayloadPayload: Codable, Hashable, Sendable { + /// Evaluation in centipawns + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/eval`. + internal var eval: Swift.Double? + /// Number of moves until forced mate + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/mate`. + internal var mate: Swift.Double? + /// Best move in UCI notation (only if played move was inaccurate) + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/best`. + internal var best: Swift.String? + /// Best variation in SAN notation (only if played move was inaccurate) + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/variation`. + internal var variation: Swift.String? + /// Judgment annotation (only if played move was inaccurate) + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/judgment`. + internal struct judgmentPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/judgment/name`. + @frozen internal enum namePayload: String, Codable, Hashable, Sendable { + case Inaccuracy = "Inaccuracy" + case Mistake = "Mistake" + case Blunder = "Blunder" + } + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/judgment/name`. + internal var name: Components.Schemas.GameJson.analysisPayloadPayload.judgmentPayload.namePayload? + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/judgment/comment`. + internal var comment: Swift.String? + /// Creates a new `judgmentPayload`. + /// + /// - Parameters: + /// - name: + /// - comment: + internal init( + name: Components.Schemas.GameJson.analysisPayloadPayload.judgmentPayload.namePayload? = nil, + comment: Swift.String? = nil + ) { + self.name = name + self.comment = comment + } + internal enum CodingKeys: String, CodingKey { + case name + case comment + } + } + /// Judgment annotation (only if played move was inaccurate) + /// + /// - Remark: Generated from `#/components/schemas/GameJson/analysisPayload/judgment`. + internal var judgment: Components.Schemas.GameJson.analysisPayloadPayload.judgmentPayload? + /// Creates a new `analysisPayloadPayload`. + /// + /// - Parameters: + /// - eval: Evaluation in centipawns + /// - mate: Number of moves until forced mate + /// - best: Best move in UCI notation (only if played move was inaccurate) + /// - variation: Best variation in SAN notation (only if played move was inaccurate) + /// - judgment: Judgment annotation (only if played move was inaccurate) + internal init( + eval: Swift.Double? = nil, + mate: Swift.Double? = nil, + best: Swift.String? = nil, + variation: Swift.String? = nil, + judgment: Components.Schemas.GameJson.analysisPayloadPayload.judgmentPayload? = nil + ) { + self.eval = eval + self.mate = mate + self.best = best + self.variation = variation + self.judgment = judgment + } + internal enum CodingKeys: String, CodingKey { + case eval + case mate + case best + case variation + case judgment + } + } + /// - Remark: Generated from `#/components/schemas/GameJson/analysis`. + internal typealias analysisPayload = [Components.Schemas.GameJson.analysisPayloadPayload] + /// - Remark: Generated from `#/components/schemas/GameJson/analysis`. + internal var analysis: Components.Schemas.GameJson.analysisPayload? + /// - Remark: Generated from `#/components/schemas/GameJson/tournament`. + internal var tournament: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/swiss`. + internal var swiss: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameJson/clock`. + internal struct clockPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameJson/clock/initial`. + internal var initial: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameJson/clock/increment`. + internal var increment: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameJson/clock/totalTime`. + internal var totalTime: Swift.Double? + /// Creates a new `clockPayload`. + /// + /// - Parameters: + /// - initial: + /// - increment: + /// - totalTime: + internal init( + initial: Swift.Double? = nil, + increment: Swift.Double? = nil, + totalTime: Swift.Double? = nil + ) { + self.initial = initial + self.increment = increment + self.totalTime = totalTime + } + internal enum CodingKeys: String, CodingKey { + case initial + case increment + case totalTime + } + } + /// - Remark: Generated from `#/components/schemas/GameJson/clock`. + internal var clock: Components.Schemas.GameJson.clockPayload? + /// - Remark: Generated from `#/components/schemas/GameJson/division`. + internal struct divisionPayload: Codable, Hashable, Sendable { + /// Ply at which the middlegame begins + /// + /// - Remark: Generated from `#/components/schemas/GameJson/division/middle`. + internal var middle: Swift.Double? + /// Ply at which the endgame begins + /// + /// - Remark: Generated from `#/components/schemas/GameJson/division/end`. + internal var end: Swift.Double? + /// Creates a new `divisionPayload`. + /// + /// - Parameters: + /// - middle: Ply at which the middlegame begins + /// - end: Ply at which the endgame begins + internal init( + middle: Swift.Double? = nil, + end: Swift.Double? = nil + ) { + self.middle = middle + self.end = end + } + internal enum CodingKeys: String, CodingKey { + case middle + case end + } + } + /// - Remark: Generated from `#/components/schemas/GameJson/division`. + internal var division: Components.Schemas.GameJson.divisionPayload? + /// Creates a new `GameJson`. + /// + /// - Parameters: + /// - id: + /// - rated: + /// - variant: + /// - speed: + /// - perf: + /// - createdAt: + /// - lastMoveAt: + /// - status: + /// - players: + /// - initialFen: + /// - winner: + /// - opening: + /// - moves: + /// - pgn: + /// - daysPerTurn: + /// - analysis: + /// - tournament: + /// - swiss: + /// - clock: + /// - division: + internal init( + id: Swift.String, + rated: Swift.Bool, + variant: Components.Schemas.VariantKey, + speed: Components.Schemas.Speed, + perf: Swift.String, + createdAt: Swift.Double, + lastMoveAt: Swift.Double, + status: Components.Schemas.GameStatus, + players: Components.Schemas.GameJson.playersPayload, + initialFen: Swift.String? = nil, + winner: Components.Schemas.GameJson.winnerPayload? = nil, + opening: Components.Schemas.GameJson.openingPayload? = nil, + moves: Swift.String? = nil, + pgn: Swift.String? = nil, + daysPerTurn: Swift.Double? = nil, + analysis: Components.Schemas.GameJson.analysisPayload? = nil, + tournament: Swift.String? = nil, + swiss: Swift.String? = nil, + clock: Components.Schemas.GameJson.clockPayload? = nil, + division: Components.Schemas.GameJson.divisionPayload? = nil + ) { + self.id = id + self.rated = rated + self.variant = variant + self.speed = speed + self.perf = perf + self.createdAt = createdAt + self.lastMoveAt = lastMoveAt + self.status = status + self.players = players + self.initialFen = initialFen + self.winner = winner + self.opening = opening + self.moves = moves + self.pgn = pgn + self.daysPerTurn = daysPerTurn + self.analysis = analysis + self.tournament = tournament + self.swiss = swiss + self.clock = clock + self.division = division + } + internal enum CodingKeys: String, CodingKey { + case id + case rated + case variant + case speed + case perf + case createdAt + case lastMoveAt + case status + case players + case initialFen + case winner + case opening + case moves + case pgn + case daysPerTurn + case analysis + case tournament + case swiss + case clock + case division + } + } + /// - Remark: Generated from `#/components/schemas/GameStream`. + internal typealias GameStream = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/MoveStream`. + internal typealias MoveStream = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/TvFeed`. + internal struct TvFeed: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/TvFeed/t`. + internal var t: Swift.String? + /// - Remark: Generated from `#/components/schemas/TvFeed/d`. + internal var d: OpenAPIRuntime.OpenAPIObjectContainer? + /// Creates a new `TvFeed`. + /// + /// - Parameters: + /// - t: + /// - d: + internal init( + t: Swift.String? = nil, + d: OpenAPIRuntime.OpenAPIObjectContainer? = nil + ) { + self.t = t + self.d = d + } + internal enum CodingKeys: String, CodingKey { + case t + case d + } + } + /// - Remark: Generated from `#/components/schemas/Clock`. + internal struct Clock: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Clock/limit`. + internal var limit: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Clock/increment`. + internal var increment: Swift.Int? + /// Creates a new `Clock`. + /// + /// - Parameters: + /// - limit: + /// - increment: + internal init( + limit: Swift.Int? = nil, + increment: Swift.Int? = nil + ) { + self.limit = limit + self.increment = increment + } + internal enum CodingKeys: String, CodingKey { + case limit + case increment + } + } + /// - Remark: Generated from `#/components/schemas/Variant`. + internal struct Variant: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Variant/key`. + internal var key: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/components/schemas/Variant/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/Variant/short`. + internal var short: Swift.String? + /// Creates a new `Variant`. + /// + /// - Parameters: + /// - key: + /// - name: + /// - short: + internal init( + key: Components.Schemas.VariantKey? = nil, + name: Swift.String? = nil, + short: Swift.String? = nil + ) { + self.key = key + self.name = name + self.short = short + } + internal enum CodingKeys: String, CodingKey { + case key + case name + case short + } + } + /// 10: created, 20: started, 30: finished + /// + /// + /// - Remark: Generated from `#/components/schemas/ArenaStatus`. + @frozen internal enum ArenaStatus: Int, Codable, Hashable, Sendable { + case _10 = 10 + case _20 = 20 + case _30 = 30 + } + /// - Remark: Generated from `#/components/schemas/ArenaPerf`. + internal struct ArenaPerf: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaPerf/key`. + internal var key: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaPerf/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaPerf/position`. + internal var position: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaPerf/icon`. + internal var icon: Swift.String? + /// Creates a new `ArenaPerf`. + /// + /// - Parameters: + /// - key: + /// - name: + /// - position: + /// - icon: + internal init( + key: Swift.String? = nil, + name: Swift.String? = nil, + position: Swift.Int? = nil, + icon: Swift.String? = nil + ) { + self.key = key + self.name = name + self.position = position + self.icon = icon + } + internal enum CodingKeys: String, CodingKey { + case key + case name + case position + case icon + } + } + /// - Remark: Generated from `#/components/schemas/ArenaRatingObj`. + internal struct ArenaRatingObj: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaRatingObj/perf`. + internal var perf: Components.Schemas.PerfType? + /// - Remark: Generated from `#/components/schemas/ArenaRatingObj/rating`. + internal var rating: Swift.Int? + /// Creates a new `ArenaRatingObj`. + /// + /// - Parameters: + /// - perf: + /// - rating: + internal init( + perf: Components.Schemas.PerfType? = nil, + rating: Swift.Int? = nil + ) { + self.perf = perf + self.rating = rating + } + internal enum CodingKeys: String, CodingKey { + case perf + case rating + } + } + /// - Remark: Generated from `#/components/schemas/ArenaPosition`. + @frozen internal enum ArenaPosition: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1`. + internal struct Case1Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1/eco`. + internal var eco: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1/fen`. + internal var fen: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1/url`. + internal var url: Swift.String? + /// Creates a new `Case1Payload`. + /// + /// - Parameters: + /// - eco: + /// - name: + /// - fen: + /// - url: + internal init( + eco: Swift.String? = nil, + name: Swift.String? = nil, + fen: Swift.String? = nil, + url: Swift.String? = nil + ) { + self.eco = eco + self.name = name + self.fen = fen + self.url = url + } + internal enum CodingKeys: String, CodingKey { + case eco + case name + case fen + case url + } + } + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case1`. + case case1(Components.Schemas.ArenaPosition.Case1Payload) + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case2`. + internal struct Case2Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case2/name`. + @frozen internal enum namePayload: String, Codable, Hashable, Sendable { + case Custom_space_position = "Custom position" + } + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case2/name`. + internal var name: Components.Schemas.ArenaPosition.Case2Payload.namePayload? + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case2/fen`. + internal var fen: Swift.String? + /// Creates a new `Case2Payload`. + /// + /// - Parameters: + /// - name: + /// - fen: + internal init( + name: Components.Schemas.ArenaPosition.Case2Payload.namePayload? = nil, + fen: Swift.String? = nil + ) { + self.name = name + self.fen = fen + } + internal enum CodingKeys: String, CodingKey { + case name + case fen + } + } + /// - Remark: Generated from `#/components/schemas/ArenaPosition/case2`. + case case2(Components.Schemas.ArenaPosition.Case2Payload) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .case1(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .case1(value): + try value.encode(to: encoder) + case let .case2(value): + try value.encode(to: encoder) + } + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament`. + internal struct ArenaTournament: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournament/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/createdBy`. + internal var createdBy: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/system`. + @frozen internal enum systemPayload: String, Codable, Hashable, Sendable { + case arena = "arena" + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament/system`. + internal var system: Components.Schemas.ArenaTournament.systemPayload? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minutes`. + internal var minutes: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/clock`. + internal var clock: Components.Schemas.Clock? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/rated`. + internal var rated: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/fullName`. + internal var fullName: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/nbPlayers`. + internal var nbPlayers: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/variant`. + internal var variant: Components.Schemas.Variant? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/startsAt`. + internal var startsAt: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/finishesAt`. + internal var finishesAt: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/status`. + internal var status: Components.Schemas.ArenaStatus? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/perf`. + internal var perf: Components.Schemas.ArenaPerf? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/secondsToStart`. + internal var secondsToStart: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/hasMaxRating`. + internal var hasMaxRating: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/maxRating`. + internal var maxRating: Components.Schemas.ArenaRatingObj? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minRating`. + internal var minRating: Components.Schemas.ArenaRatingObj? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minRatedGames`. + internal struct minRatedGamesPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minRatedGames/nb`. + internal var nb: Swift.Int? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minRatedGames/perf`. + internal var perf: Components.Schemas.PerfType? + /// Creates a new `minRatedGamesPayload`. + /// + /// - Parameters: + /// - nb: + /// - perf: + internal init( + nb: Swift.Int? = nil, + perf: Components.Schemas.PerfType? = nil + ) { + self.nb = nb + self.perf = perf + } + internal enum CodingKeys: String, CodingKey { + case nb + case perf + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament/minRatedGames`. + internal var minRatedGames: Components.Schemas.ArenaTournament.minRatedGamesPayload? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/onlyTitled`. + internal var onlyTitled: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/teamMember`. + internal var teamMember: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/private`. + internal var _private: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/position`. + internal var position: Components.Schemas.ArenaPosition? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/schedule`. + internal struct schedulePayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournament/schedule/freq`. + internal var freq: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/schedule/speed`. + internal var speed: Swift.String? + /// Creates a new `schedulePayload`. + /// + /// - Parameters: + /// - freq: + /// - speed: + internal init( + freq: Swift.String? = nil, + speed: Swift.String? = nil + ) { + self.freq = freq + self.speed = speed + } + internal enum CodingKeys: String, CodingKey { + case freq + case speed + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament/schedule`. + internal var schedule: Components.Schemas.ArenaTournament.schedulePayload? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/teamBattle`. + internal struct teamBattlePayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournament/teamBattle/teams`. + internal var teams: [Swift.String]? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/teamBattle/nbLeaders`. + internal var nbLeaders: Swift.Int? + /// Creates a new `teamBattlePayload`. + /// + /// - Parameters: + /// - teams: + /// - nbLeaders: + internal init( + teams: [Swift.String]? = nil, + nbLeaders: Swift.Int? = nil + ) { + self.teams = teams + self.nbLeaders = nbLeaders + } + internal enum CodingKeys: String, CodingKey { + case teams + case nbLeaders + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament/teamBattle`. + internal var teamBattle: Components.Schemas.ArenaTournament.teamBattlePayload? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/winner`. + internal struct winnerPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournament/winner/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/winner/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/ArenaTournament/winner/title`. + internal var title: Components.Schemas.Title? + /// Creates a new `winnerPayload`. + /// + /// - Parameters: + /// - id: + /// - name: + /// - title: + internal init( + id: Swift.String? = nil, + name: Swift.String? = nil, + title: Components.Schemas.Title? = nil + ) { + self.id = id + self.name = name + self.title = title + } + internal enum CodingKeys: String, CodingKey { + case id + case name + case title + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournament/winner`. + internal var winner: Components.Schemas.ArenaTournament.winnerPayload? + /// Creates a new `ArenaTournament`. + /// + /// - Parameters: + /// - id: + /// - createdBy: + /// - system: + /// - minutes: + /// - clock: + /// - rated: + /// - fullName: + /// - nbPlayers: + /// - variant: + /// - startsAt: + /// - finishesAt: + /// - status: + /// - perf: + /// - secondsToStart: + /// - hasMaxRating: + /// - maxRating: + /// - minRating: + /// - minRatedGames: + /// - onlyTitled: + /// - teamMember: + /// - _private: + /// - position: + /// - schedule: + /// - teamBattle: + /// - winner: + internal init( + id: Swift.String? = nil, + createdBy: Swift.String? = nil, + system: Components.Schemas.ArenaTournament.systemPayload? = nil, + minutes: Swift.Int? = nil, + clock: Components.Schemas.Clock? = nil, + rated: Swift.Bool? = nil, + fullName: Swift.String? = nil, + nbPlayers: Swift.Int? = nil, + variant: Components.Schemas.Variant? = nil, + startsAt: Swift.Int? = nil, + finishesAt: Swift.Int? = nil, + status: Components.Schemas.ArenaStatus? = nil, + perf: Components.Schemas.ArenaPerf? = nil, + secondsToStart: Swift.Int? = nil, + hasMaxRating: Swift.Bool? = nil, + maxRating: Components.Schemas.ArenaRatingObj? = nil, + minRating: Components.Schemas.ArenaRatingObj? = nil, + minRatedGames: Components.Schemas.ArenaTournament.minRatedGamesPayload? = nil, + onlyTitled: Swift.Bool? = nil, + teamMember: Swift.String? = nil, + _private: Swift.Bool? = nil, + position: Components.Schemas.ArenaPosition? = nil, + schedule: Components.Schemas.ArenaTournament.schedulePayload? = nil, + teamBattle: Components.Schemas.ArenaTournament.teamBattlePayload? = nil, + winner: Components.Schemas.ArenaTournament.winnerPayload? = nil + ) { + self.id = id + self.createdBy = createdBy + self.system = system + self.minutes = minutes + self.clock = clock + self.rated = rated + self.fullName = fullName + self.nbPlayers = nbPlayers + self.variant = variant + self.startsAt = startsAt + self.finishesAt = finishesAt + self.status = status + self.perf = perf + self.secondsToStart = secondsToStart + self.hasMaxRating = hasMaxRating + self.maxRating = maxRating + self.minRating = minRating + self.minRatedGames = minRatedGames + self.onlyTitled = onlyTitled + self.teamMember = teamMember + self._private = _private + self.position = position + self.schedule = schedule + self.teamBattle = teamBattle + self.winner = winner + } + internal enum CodingKeys: String, CodingKey { + case id + case createdBy + case system + case minutes + case clock + case rated + case fullName + case nbPlayers + case variant + case startsAt + case finishesAt + case status + case perf + case secondsToStart + case hasMaxRating + case maxRating + case minRating + case minRatedGames + case onlyTitled + case teamMember + case _private = "private" + case position + case schedule + case teamBattle + case winner + } + } + /// - Remark: Generated from `#/components/schemas/ArenaTournaments`. + internal struct ArenaTournaments: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ArenaTournaments/created`. + internal var created: [Components.Schemas.ArenaTournament]? + /// - Remark: Generated from `#/components/schemas/ArenaTournaments/started`. + internal var started: [Components.Schemas.ArenaTournament]? + /// - Remark: Generated from `#/components/schemas/ArenaTournaments/finished`. + internal var finished: [Components.Schemas.ArenaTournament]? + /// Creates a new `ArenaTournaments`. + /// + /// - Parameters: + /// - created: + /// - started: + /// - finished: + internal init( + created: [Components.Schemas.ArenaTournament]? = nil, + started: [Components.Schemas.ArenaTournament]? = nil, + finished: [Components.Schemas.ArenaTournament]? = nil + ) { + self.created = created + self.started = started + self.finished = finished + } + internal enum CodingKeys: String, CodingKey { + case created + case started + case finished + } + } + /// Custom initial position (in FEN). Variant must be standard, fromPosition, or chess960 (if a valid 960 starting position), and the game cannot be rated. + /// + /// - Remark: Generated from `#/components/schemas/FromPositionFEN`. + internal typealias FromPositionFEN = Swift.String + /// - Remark: Generated from `#/components/schemas/ArenaTournamentVariantIsKey`. + internal typealias ArenaTournamentVariantIsKey = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Error`. + internal struct _Error: Codable, Hashable, Sendable { + /// The cause of the error. + /// + /// - Remark: Generated from `#/components/schemas/Error/error`. + internal var error: Swift.String? + /// Creates a new `_Error`. + /// + /// - Parameters: + /// - error: The cause of the error. + internal init(error: Swift.String? = nil) { + self.error = error + } + internal enum CodingKeys: String, CodingKey { + case error + } + } + /// - Remark: Generated from `#/components/schemas/SwissTournament`. + internal typealias SwissTournament = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/SwissUnauthorisedEdit`. + internal struct SwissUnauthorisedEdit: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/SwissUnauthorisedEdit/error`. + internal var error: Swift.String? + /// Creates a new `SwissUnauthorisedEdit`. + /// + /// - Parameters: + /// - error: + internal init(error: Swift.String? = nil) { + self.error = error + } + internal enum CodingKeys: String, CodingKey { + case error + } + } + /// - Remark: Generated from `#/components/schemas/StudyPgn`. + internal typealias StudyPgn = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/StudyImportPgnChapters`. + internal typealias StudyImportPgnChapters = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/StudyMetadata`. + internal typealias StudyMetadata = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/BroadcastTour`. + internal typealias BroadcastTour = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/BroadcastForm`. + internal struct BroadcastForm: Codable, Hashable, Sendable { + /// Name of the broadcast tournament. Length must be between 3 and 80 characters. + /// + /// Example: `Sinquefield Cup` + /// + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/name`. + internal var name: Swift.String + /// Short description of the broadcast tournament. Length must be between 3 and 400 characters. + /// + /// Example: `An 11 round classical tournament featuring the 9 highest rated players in the world. Including Carlsen, Caruana, Ding, Aronian, Nakamura and more.` + /// + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/description`. + internal var description: Swift.String + /// Compute and display a simple leaderboard based on game results + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/autoLeaderboard`. + internal var autoLeaderboard: Swift.Bool + /// Optional long description of the broadcast. Markdown is supported. Length must be less than 20,000 characters. + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/markdown`. + internal var markdown: Swift.String? + /// Optional, for Lichess admins only, use to feature on /broadcast. + /// + /// * `3` for normal + /// * `4` for high + /// * `5` for best + /// + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/tier`. + internal var tier: Swift.Int? + /// Optional replace player names, ratings and titles. + /// + /// One line per player, formatted as such: + /// + /// `player name = FIDE ID` + /// + /// Example: + /// + /// `Magnus Carlsen = 1503014` + /// + /// Player names ignore case and punctuation, and match all possible combinations of 2 words: + /// "Jorge Rick Vito" will match "Jorge Rick", "jorge vito", "Rick, Vito", etc. + /// + /// Alternatively, you may set tags manually, like so: + /// + /// `player name / rating / title / new name` + /// + /// All values are optional. Example: + /// + /// `Magnus Carlsen / 2863 / GM` + /// `YouGotLittUp / 1890 / / Louis Litt` + /// + /// + /// - Remark: Generated from `#/components/schemas/BroadcastForm/players`. + internal var players: OpenAPIRuntime.OpenAPIValueContainer? + /// Creates a new `BroadcastForm`. + /// + /// - Parameters: + /// - name: Name of the broadcast tournament. Length must be between 3 and 80 characters. + /// - description: Short description of the broadcast tournament. Length must be between 3 and 400 characters. + /// - autoLeaderboard: Compute and display a simple leaderboard based on game results + /// - markdown: Optional long description of the broadcast. Markdown is supported. Length must be less than 20,000 characters. + /// - tier: Optional, for Lichess admins only, use to feature on /broadcast. + /// - players: Optional replace player names, ratings and titles. + internal init( + name: Swift.String, + description: Swift.String, + autoLeaderboard: Swift.Bool, + markdown: Swift.String? = nil, + tier: Swift.Int? = nil, + players: OpenAPIRuntime.OpenAPIValueContainer? = nil + ) { + self.name = name + self.description = description + self.autoLeaderboard = autoLeaderboard + self.markdown = markdown + self.tier = tier + self.players = players + } + internal enum CodingKeys: String, CodingKey { + case name + case description + case autoLeaderboard + case markdown + case tier + case players + } + } + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry`. + internal struct BroadcastLeaderboardEntry: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/score`. + internal var score: Swift.Double? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/played`. + internal var played: Swift.Int? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/rating`. + internal var rating: Swift.Int? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/title`. + internal var title: Swift.String? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/fideId`. + internal var fideId: Swift.Int? + /// - Remark: Generated from `#/components/schemas/BroadcastLeaderboardEntry/fed`. + internal var fed: Swift.String? + /// Creates a new `BroadcastLeaderboardEntry`. + /// + /// - Parameters: + /// - name: + /// - score: + /// - played: + /// - rating: + /// - title: + /// - fideId: + /// - fed: + internal init( + name: Swift.String? = nil, + score: Swift.Double? = nil, + played: Swift.Int? = nil, + rating: Swift.Int? = nil, + title: Swift.String? = nil, + fideId: Swift.Int? = nil, + fed: Swift.String? = nil + ) { + self.name = name + self.score = score + self.played = played + self.rating = rating + self.title = title + self.fideId = fideId + self.fed = fed + } + internal enum CodingKeys: String, CodingKey { + case name + case score + case played + case rating + case title + case fideId + case fed + } + } + /// - Remark: Generated from `#/components/schemas/BroadcastRound`. + internal typealias BroadcastRound = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush`. + internal struct BroadcastPgnPush: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/gamesPayload`. + internal struct gamesPayloadPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/gamesPayload/tags`. + internal var tags: OpenAPIRuntime.OpenAPIObjectContainer? + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/gamesPayload/moves`. + internal var moves: Swift.Int? + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/gamesPayload/error`. + internal var error: Swift.String? + /// Creates a new `gamesPayloadPayload`. + /// + /// - Parameters: + /// - tags: + /// - moves: + /// - error: + internal init( + tags: OpenAPIRuntime.OpenAPIObjectContainer? = nil, + moves: Swift.Int? = nil, + error: Swift.String? = nil + ) { + self.tags = tags + self.moves = moves + self.error = error + } + internal enum CodingKeys: String, CodingKey { + case tags + case moves + case error + } + } + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/games`. + internal typealias gamesPayload = [Components.Schemas.BroadcastPgnPush.gamesPayloadPayload] + /// - Remark: Generated from `#/components/schemas/BroadcastPgnPush/games`. + internal var games: Components.Schemas.BroadcastPgnPush.gamesPayload? + /// Creates a new `BroadcastPgnPush`. + /// + /// - Parameters: + /// - games: + internal init(games: Components.Schemas.BroadcastPgnPush.gamesPayload? = nil) { + self.games = games + } + internal enum CodingKeys: String, CodingKey { + case games + } + } + /// - Remark: Generated from `#/components/schemas/BroadcastMyRound`. + internal typealias BroadcastMyRound = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Simul`. + internal typealias Simul = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Team`. + internal struct Team: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Team/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/Team/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/Team/description`. + internal var description: Swift.String? + /// - Remark: Generated from `#/components/schemas/Team/open`. + internal var open: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Team/leaders`. + internal var leaders: [Components.Schemas.LightUser]? + /// - Remark: Generated from `#/components/schemas/Team/nbMembers`. + internal var nbMembers: Swift.Int? + /// Creates a new `Team`. + /// + /// - Parameters: + /// - id: + /// - name: + /// - description: + /// - open: + /// - leaders: + /// - nbMembers: + internal init( + id: Swift.String? = nil, + name: Swift.String? = nil, + description: Swift.String? = nil, + open: Swift.Bool? = nil, + leaders: [Components.Schemas.LightUser]? = nil, + nbMembers: Swift.Int? = nil + ) { + self.id = id + self.name = name + self.description = description + self.open = open + self.leaders = leaders + self.nbMembers = nbMembers + } + internal enum CodingKeys: String, CodingKey { + case id + case name + case description + case open + case leaders + case nbMembers + } + } + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson`. + internal struct TeamPaginatorJson: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/currentPage`. + internal var currentPage: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/maxPerPage`. + internal var maxPerPage: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/currentPageResults`. + internal var currentPageResults: [Components.Schemas.Team]? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/nbResults`. + internal var nbResults: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/previousPage`. + internal var previousPage: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/nextPage`. + internal var nextPage: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamPaginatorJson/nbPages`. + internal var nbPages: Swift.Double? + /// Creates a new `TeamPaginatorJson`. + /// + /// - Parameters: + /// - currentPage: + /// - maxPerPage: + /// - currentPageResults: + /// - nbResults: + /// - previousPage: + /// - nextPage: + /// - nbPages: + internal init( + currentPage: Swift.Double? = nil, + maxPerPage: Swift.Double? = nil, + currentPageResults: [Components.Schemas.Team]? = nil, + nbResults: Swift.Double? = nil, + previousPage: Swift.Double? = nil, + nextPage: Swift.Double? = nil, + nbPages: Swift.Double? = nil + ) { + self.currentPage = currentPage + self.maxPerPage = maxPerPage + self.currentPageResults = currentPageResults + self.nbResults = nbResults + self.previousPage = previousPage + self.nextPage = nextPage + self.nbPages = nbPages + } + internal enum CodingKeys: String, CodingKey { + case currentPage + case maxPerPage + case currentPageResults + case nbResults + case previousPage + case nextPage + case nbPages + } + } + /// - Remark: Generated from `#/components/schemas/TeamRequest`. + internal struct TeamRequest: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/TeamRequest/teamId`. + internal var teamId: Swift.String? + /// - Remark: Generated from `#/components/schemas/TeamRequest/userId`. + internal var userId: Swift.String? + /// - Remark: Generated from `#/components/schemas/TeamRequest/date`. + internal var date: Swift.Double? + /// - Remark: Generated from `#/components/schemas/TeamRequest/message`. + internal var message: Swift.String? + /// Creates a new `TeamRequest`. + /// + /// - Parameters: + /// - teamId: + /// - userId: + /// - date: + /// - message: + internal init( + teamId: Swift.String? = nil, + userId: Swift.String? = nil, + date: Swift.Double? = nil, + message: Swift.String? = nil + ) { + self.teamId = teamId + self.userId = userId + self.date = date + self.message = message + } + internal enum CodingKeys: String, CodingKey { + case teamId + case userId + case date + case message + } + } + /// - Remark: Generated from `#/components/schemas/TeamRequestWithUser`. + internal struct TeamRequestWithUser: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/TeamRequestWithUser/request`. + internal var request: Components.Schemas.TeamRequest? + /// - Remark: Generated from `#/components/schemas/TeamRequestWithUser/user`. + internal var user: Components.Schemas.User? + /// Creates a new `TeamRequestWithUser`. + /// + /// - Parameters: + /// - request: + /// - user: + internal init( + request: Components.Schemas.TeamRequest? = nil, + user: Components.Schemas.User? = nil + ) { + self.request = request + self.user = user + } + internal enum CodingKeys: String, CodingKey { + case request + case user + } + } + /// - Remark: Generated from `#/components/schemas/Crosstable`. + internal typealias Crosstable = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/LightUserOnline`. + internal struct LightUserOnline: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/LightUserOnline/value1`. + internal var value1: Components.Schemas.LightUser + /// - Remark: Generated from `#/components/schemas/LightUserOnline/value2`. + internal struct Value2Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/LightUserOnline/value2/online`. + internal var online: Swift.Bool? + /// Creates a new `Value2Payload`. + /// + /// - Parameters: + /// - online: + internal init(online: Swift.Bool? = nil) { + self.online = online + } + internal enum CodingKeys: String, CodingKey { + case online + } + } + /// - Remark: Generated from `#/components/schemas/LightUserOnline/value2`. + internal var value2: Components.Schemas.LightUserOnline.Value2Payload + /// Creates a new `LightUserOnline`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Components.Schemas.LightUser, + value2: Components.Schemas.LightUserOnline.Value2Payload + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + value1 = try .init(from: decoder) + value2 = try .init(from: decoder) + } + internal func encode(to encoder: any Encoder) throws { + try value1.encode(to: encoder) + try value2.encode(to: encoder) + } + } + /// - Remark: Generated from `#/components/schemas/UserNote`. + internal struct UserNote: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/UserNote/from`. + internal var from: Components.Schemas.LightUser? + /// - Remark: Generated from `#/components/schemas/UserNote/to`. + internal var to: Components.Schemas.LightUser? + /// - Remark: Generated from `#/components/schemas/UserNote/text`. + internal var text: Swift.String? + /// - Remark: Generated from `#/components/schemas/UserNote/date`. + internal var date: Swift.Int64? + /// Creates a new `UserNote`. + /// + /// - Parameters: + /// - from: + /// - to: + /// - text: + /// - date: + internal init( + from: Components.Schemas.LightUser? = nil, + to: Components.Schemas.LightUser? = nil, + text: Swift.String? = nil, + date: Swift.Int64? = nil + ) { + self.from = from + self.to = to + self.text = text + self.date = date + } + internal enum CodingKeys: String, CodingKey { + case from + case to + case text + case date + } + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo`. + internal struct GameEventInfo: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameEventInfo/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/source`. + @frozen internal enum sourcePayload: String, Codable, Hashable, Sendable { + case lobby = "lobby" + case friend = "friend" + case ai = "ai" + case api = "api" + case tournament = "tournament" + case position = "position" + case _import = "import" + case importlive = "importlive" + case simul = "simul" + case relay = "relay" + case pool = "pool" + case swiss = "swiss" + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo/source`. + internal var source: Components.Schemas.GameEventInfo.sourcePayload? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/status`. + internal struct statusPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameEventInfo/status/id`. + @frozen internal enum idPayload: Int, Codable, Hashable, Sendable { + case _10 = 10 + case _20 = 20 + case _25 = 25 + case _30 = 30 + case _31 = 31 + case _32 = 32 + case _33 = 33 + case _34 = 34 + case _35 = 35 + case _36 = 36 + case _37 = 37 + case _38 = 38 + case _60 = 60 + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo/status/id`. + internal var id: Components.Schemas.GameEventInfo.statusPayload.idPayload? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/status/name`. + internal var name: Components.Schemas.GameStatus? + /// Creates a new `statusPayload`. + /// + /// - Parameters: + /// - id: + /// - name: + internal init( + id: Components.Schemas.GameEventInfo.statusPayload.idPayload? = nil, + name: Components.Schemas.GameStatus? = nil + ) { + self.id = id + self.name = name + } + internal enum CodingKeys: String, CodingKey { + case id + case name + } + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo/status`. + internal var status: Components.Schemas.GameEventInfo.statusPayload? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/winner`. + @frozen internal enum winnerPayload: String, Codable, Hashable, Sendable { + case white = "white" + case black = "black" + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo/winner`. + internal var winner: Components.Schemas.GameEventInfo.winnerPayload? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/compat`. + internal struct compatPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameEventInfo/compat/bot`. + internal var bot: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/GameEventInfo/compat/board`. + internal var board: Swift.Bool? + /// Creates a new `compatPayload`. + /// + /// - Parameters: + /// - bot: + /// - board: + internal init( + bot: Swift.Bool? = nil, + board: Swift.Bool? = nil + ) { + self.bot = bot + self.board = board + } + internal enum CodingKeys: String, CodingKey { + case bot + case board + } + } + /// - Remark: Generated from `#/components/schemas/GameEventInfo/compat`. + internal var compat: Components.Schemas.GameEventInfo.compatPayload? + /// Creates a new `GameEventInfo`. + /// + /// - Parameters: + /// - id: + /// - source: + /// - status: + /// - winner: + /// - compat: + internal init( + id: Swift.String? = nil, + source: Components.Schemas.GameEventInfo.sourcePayload? = nil, + status: Components.Schemas.GameEventInfo.statusPayload? = nil, + winner: Components.Schemas.GameEventInfo.winnerPayload? = nil, + compat: Components.Schemas.GameEventInfo.compatPayload? = nil + ) { + self.id = id + self.source = source + self.status = status + self.winner = winner + self.compat = compat + } + internal enum CodingKeys: String, CodingKey { + case id + case source + case status + case winner + case compat + } + } + /// - Remark: Generated from `#/components/schemas/GameStartEvent`. + internal struct GameStartEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameStartEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case gameStart = "gameStart" + } + /// - Remark: Generated from `#/components/schemas/GameStartEvent/type`. + internal var _type: Components.Schemas.GameStartEvent._typePayload? + /// - Remark: Generated from `#/components/schemas/GameStartEvent/game`. + internal var game: Components.Schemas.GameEventInfo? + /// Creates a new `GameStartEvent`. + /// + /// - Parameters: + /// - _type: + /// - game: + internal init( + _type: Components.Schemas.GameStartEvent._typePayload? = nil, + game: Components.Schemas.GameEventInfo? = nil + ) { + self._type = _type + self.game = game + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case game + } + } + /// - Remark: Generated from `#/components/schemas/GameFinishEvent`. + internal struct GameFinishEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameFinishEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case gameFinish = "gameFinish" + } + /// - Remark: Generated from `#/components/schemas/GameFinishEvent/type`. + internal var _type: Components.Schemas.GameFinishEvent._typePayload? + /// - Remark: Generated from `#/components/schemas/GameFinishEvent/game`. + internal var game: Components.Schemas.GameEventInfo? + /// Creates a new `GameFinishEvent`. + /// + /// - Parameters: + /// - _type: + /// - game: + internal init( + _type: Components.Schemas.GameFinishEvent._typePayload? = nil, + game: Components.Schemas.GameEventInfo? = nil + ) { + self._type = _type + self.game = game + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case game + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeUser`. + internal struct ChallengeUser: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeUser/value1`. + internal var value1: Components.Schemas.LightUser + /// Creates a new `ChallengeUser`. + /// + /// - Parameters: + /// - value1: + internal init(value1: Components.Schemas.LightUser) { + self.value1 = value1 + } + internal init(from decoder: any Decoder) throws { + value1 = try .init(from: decoder) + } + internal func encode(to encoder: any Encoder) throws { + try value1.encode(to: encoder) + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson`. + internal struct ChallengeJson: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/components/schemas/ChallengeJson/url`. + internal var url: Swift.String + /// - Remark: Generated from `#/components/schemas/ChallengeJson/status`. + @frozen internal enum statusPayload: String, Codable, Hashable, Sendable { + case created = "created" + case offline = "offline" + case canceled = "canceled" + case declined = "declined" + case accepted = "accepted" + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/status`. + internal var status: Components.Schemas.ChallengeJson.statusPayload + /// - Remark: Generated from `#/components/schemas/ChallengeJson/challenger`. + internal var challenger: Components.Schemas.ChallengeUser + /// - Remark: Generated from `#/components/schemas/ChallengeJson/destUser`. + @frozen internal enum destUserPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/destUser/case1`. + case ChallengeUser(Components.Schemas.ChallengeUser) + /// - Remark: Generated from `#/components/schemas/ChallengeJson/destUser/case2`. + case case2(OpenAPIRuntime.OpenAPIValueContainer) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .ChallengeUser(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .ChallengeUser(value): + try value.encode(to: encoder) + case let .case2(value): + try value.encode(to: encoder) + } + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/destUser`. + internal var destUser: Components.Schemas.ChallengeJson.destUserPayload + /// - Remark: Generated from `#/components/schemas/ChallengeJson/variant`. + internal var variant: Components.Schemas.Variant + /// - Remark: Generated from `#/components/schemas/ChallengeJson/rated`. + internal var rated: Swift.Bool + /// - Remark: Generated from `#/components/schemas/ChallengeJson/speed`. + internal var speed: Components.Schemas.Speed + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl`. + @frozen internal enum timeControlPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1`. + internal struct Case1Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1/type`. + internal var _type: Swift.String? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1/limit`. + internal var limit: Swift.Double? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1/increment`. + internal var increment: Swift.Double? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1/show`. + internal var show: Swift.String? + /// Creates a new `Case1Payload`. + /// + /// - Parameters: + /// - _type: + /// - limit: + /// - increment: + /// - show: + internal init( + _type: Swift.String? = nil, + limit: Swift.Double? = nil, + increment: Swift.Double? = nil, + show: Swift.String? = nil + ) { + self._type = _type + self.limit = limit + self.increment = increment + self.show = show + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case limit + case increment + case show + } + internal init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + _type = try container.decodeIfPresent( + Swift.String.self, + forKey: ._type + ) + limit = try container.decodeIfPresent( + Swift.Double.self, + forKey: .limit + ) + increment = try container.decodeIfPresent( + Swift.Double.self, + forKey: .increment + ) + show = try container.decodeIfPresent( + Swift.String.self, + forKey: .show + ) + try decoder.ensureNoAdditionalProperties(knownKeys: [ + "type", + "limit", + "increment", + "show" + ]) + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case1`. + case case1(Components.Schemas.ChallengeJson.timeControlPayload.Case1Payload) + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case2`. + internal struct Case2Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case2/type`. + internal var _type: Swift.String? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case2/daysPerTurn`. + internal var daysPerTurn: Swift.Double? + /// Creates a new `Case2Payload`. + /// + /// - Parameters: + /// - _type: + /// - daysPerTurn: + internal init( + _type: Swift.String? = nil, + daysPerTurn: Swift.Double? = nil + ) { + self._type = _type + self.daysPerTurn = daysPerTurn + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case daysPerTurn + } + internal init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + _type = try container.decodeIfPresent( + Swift.String.self, + forKey: ._type + ) + daysPerTurn = try container.decodeIfPresent( + Swift.Double.self, + forKey: .daysPerTurn + ) + try decoder.ensureNoAdditionalProperties(knownKeys: [ + "type", + "daysPerTurn" + ]) + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case2`. + case case2(Components.Schemas.ChallengeJson.timeControlPayload.Case2Payload) + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case3`. + internal struct Case3Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case3/type`. + internal var _type: Swift.String? + /// Creates a new `Case3Payload`. + /// + /// - Parameters: + /// - _type: + internal init(_type: Swift.String? = nil) { + self._type = _type + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + } + internal init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + _type = try container.decodeIfPresent( + Swift.String.self, + forKey: ._type + ) + try decoder.ensureNoAdditionalProperties(knownKeys: [ + "type" + ]) + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl/case3`. + case case3(Components.Schemas.ChallengeJson.timeControlPayload.Case3Payload) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .case1(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case3(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .case1(value): + try value.encode(to: encoder) + case let .case2(value): + try value.encode(to: encoder) + case let .case3(value): + try value.encode(to: encoder) + } + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/timeControl`. + internal var timeControl: Components.Schemas.ChallengeJson.timeControlPayload + /// - Remark: Generated from `#/components/schemas/ChallengeJson/color`. + @frozen internal enum colorPayload: String, Codable, Hashable, Sendable { + case white = "white" + case black = "black" + case random = "random" + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/color`. + internal var color: Components.Schemas.ChallengeJson.colorPayload + /// - Remark: Generated from `#/components/schemas/ChallengeJson/perf`. + internal struct perfPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeJson/perf/icon`. + internal var icon: Swift.String? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/perf/name`. + internal var name: Swift.String? + /// Creates a new `perfPayload`. + /// + /// - Parameters: + /// - icon: + /// - name: + internal init( + icon: Swift.String? = nil, + name: Swift.String? = nil + ) { + self.icon = icon + self.name = name + } + internal enum CodingKeys: String, CodingKey { + case icon + case name + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/perf`. + internal var perf: Components.Schemas.ChallengeJson.perfPayload + /// - Remark: Generated from `#/components/schemas/ChallengeJson/direction`. + @frozen internal enum directionPayload: String, Codable, Hashable, Sendable { + case _in = "in" + case out = "out" + } + /// - Remark: Generated from `#/components/schemas/ChallengeJson/direction`. + internal var direction: Components.Schemas.ChallengeJson.directionPayload? + /// - Remark: Generated from `#/components/schemas/ChallengeJson/initialFen`. + internal var initialFen: Swift.String? + /// Human readable, possibly translated reason why the challenge was declined. + /// + /// - Remark: Generated from `#/components/schemas/ChallengeJson/declineReason`. + internal var declineReason: Swift.String? + /// Untranslated, computer-matchable reason why the challenge was declined. + /// + /// - Remark: Generated from `#/components/schemas/ChallengeJson/declineReasonKey`. + internal var declineReasonKey: Swift.String? + /// Creates a new `ChallengeJson`. + /// + /// - Parameters: + /// - id: + /// - url: + /// - status: + /// - challenger: + /// - destUser: + /// - variant: + /// - rated: + /// - speed: + /// - timeControl: + /// - color: + /// - perf: + /// - direction: + /// - initialFen: + /// - declineReason: Human readable, possibly translated reason why the challenge was declined. + /// - declineReasonKey: Untranslated, computer-matchable reason why the challenge was declined. + internal init( + id: Swift.String, + url: Swift.String, + status: Components.Schemas.ChallengeJson.statusPayload, + challenger: Components.Schemas.ChallengeUser, + destUser: Components.Schemas.ChallengeJson.destUserPayload, + variant: Components.Schemas.Variant, + rated: Swift.Bool, + speed: Components.Schemas.Speed, + timeControl: Components.Schemas.ChallengeJson.timeControlPayload, + color: Components.Schemas.ChallengeJson.colorPayload, + perf: Components.Schemas.ChallengeJson.perfPayload, + direction: Components.Schemas.ChallengeJson.directionPayload? = nil, + initialFen: Swift.String? = nil, + declineReason: Swift.String? = nil, + declineReasonKey: Swift.String? = nil + ) { + self.id = id + self.url = url + self.status = status + self.challenger = challenger + self.destUser = destUser + self.variant = variant + self.rated = rated + self.speed = speed + self.timeControl = timeControl + self.color = color + self.perf = perf + self.direction = direction + self.initialFen = initialFen + self.declineReason = declineReason + self.declineReasonKey = declineReasonKey + } + internal enum CodingKeys: String, CodingKey { + case id + case url + case status + case challenger + case destUser + case variant + case rated + case speed + case timeControl + case color + case perf + case direction + case initialFen + case declineReason + case declineReasonKey + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeEvent`. + internal struct ChallengeEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case challenge = "challenge" + } + /// - Remark: Generated from `#/components/schemas/ChallengeEvent/type`. + internal var _type: Components.Schemas.ChallengeEvent._typePayload? + /// - Remark: Generated from `#/components/schemas/ChallengeEvent/challenge`. + internal var challenge: Components.Schemas.ChallengeJson? + /// Creates a new `ChallengeEvent`. + /// + /// - Parameters: + /// - _type: + /// - challenge: + internal init( + _type: Components.Schemas.ChallengeEvent._typePayload? = nil, + challenge: Components.Schemas.ChallengeJson? = nil + ) { + self._type = _type + self.challenge = challenge + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case challenge + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledEvent`. + internal struct ChallengeCanceledEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case challengeCanceled = "challengeCanceled" + } + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledEvent/type`. + internal var _type: Components.Schemas.ChallengeCanceledEvent._typePayload? + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledEvent/challenge`. + internal var challenge: Components.Schemas.ChallengeJson? + /// Creates a new `ChallengeCanceledEvent`. + /// + /// - Parameters: + /// - _type: + /// - challenge: + internal init( + _type: Components.Schemas.ChallengeCanceledEvent._typePayload? = nil, + challenge: Components.Schemas.ChallengeJson? = nil + ) { + self._type = _type + self.challenge = challenge + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case challenge + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledJson`. + internal struct ChallengeCanceledJson: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeCanceledJson/id`. + internal var id: Swift.String? + /// Creates a new `ChallengeCanceledJson`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String? = nil) { + self.id = id + } + internal enum CodingKeys: String, CodingKey { + case id + } + } + /// - Remark: Generated from `#/components/schemas/ChallengeDeclinedEvent`. + internal struct ChallengeDeclinedEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChallengeDeclinedEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case challengeDeclined = "challengeDeclined" + } + /// - Remark: Generated from `#/components/schemas/ChallengeDeclinedEvent/type`. + internal var _type: Components.Schemas.ChallengeDeclinedEvent._typePayload? + /// - Remark: Generated from `#/components/schemas/ChallengeDeclinedEvent/challenge`. + internal var challenge: Components.Schemas.ChallengeCanceledJson? + /// Creates a new `ChallengeDeclinedEvent`. + /// + /// - Parameters: + /// - _type: + /// - challenge: + internal init( + _type: Components.Schemas.ChallengeDeclinedEvent._typePayload? = nil, + challenge: Components.Schemas.ChallengeCanceledJson? = nil + ) { + self._type = _type + self.challenge = challenge + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case challenge + } + } + /// - Remark: Generated from `#/components/schemas/GameEventPlayer`. + internal struct GameEventPlayer: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/aiLevel`. + internal var aiLevel: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/id`. + internal var id: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/name`. + internal var name: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/title`. + internal var title: Swift.String? + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/rating`. + internal var rating: Swift.Double? + /// - Remark: Generated from `#/components/schemas/GameEventPlayer/provisional`. + internal var provisional: Swift.Bool? + /// Creates a new `GameEventPlayer`. + /// + /// - Parameters: + /// - aiLevel: + /// - id: + /// - name: + /// - title: + /// - rating: + /// - provisional: + internal init( + aiLevel: Swift.Double? = nil, + id: Swift.String? = nil, + name: Swift.String? = nil, + title: Swift.String? = nil, + rating: Swift.Double? = nil, + provisional: Swift.Bool? = nil + ) { + self.aiLevel = aiLevel + self.id = id + self.name = name + self.title = title + self.rating = rating + self.provisional = provisional + } + internal enum CodingKeys: String, CodingKey { + case aiLevel + case id + case name + case title + case rating + case provisional + } + } + /// - Remark: Generated from `#/components/schemas/GameStateEvent`. + internal struct GameStateEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameStateEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case gameState = "gameState" + } + /// - Remark: Generated from `#/components/schemas/GameStateEvent/type`. + internal var _type: Components.Schemas.GameStateEvent._typePayload + /// Current moves in UCI format + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/moves`. + internal var moves: Swift.String + /// Integer of milliseconds White has left on the clock + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/wtime`. + internal var wtime: Swift.Int + /// Integer of milliseconds Black has left on the clock + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/btime`. + internal var btime: Swift.Int + /// Integer of White Fisher increment. + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/winc`. + internal var winc: Swift.Int + /// Integer of Black Fisher increment. + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/binc`. + internal var binc: Swift.Int + /// - Remark: Generated from `#/components/schemas/GameStateEvent/status`. + internal var status: Components.Schemas.GameStatus + /// Color of the winner, if any + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/winner`. + internal var winner: Swift.String? + /// true if white is offering draw, else omitted + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/wdraw`. + internal var wdraw: Swift.Bool? + /// true if black is offering draw, else omitted + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/bdraw`. + internal var bdraw: Swift.Bool? + /// true if white is proposing takeback, else omitted + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/wtakeback`. + internal var wtakeback: Swift.Bool? + /// true if black is proposing takeback, else omitted + /// + /// - Remark: Generated from `#/components/schemas/GameStateEvent/btakeback`. + internal var btakeback: Swift.Bool? + /// Creates a new `GameStateEvent`. + /// + /// - Parameters: + /// - _type: + /// - moves: Current moves in UCI format + /// - wtime: Integer of milliseconds White has left on the clock + /// - btime: Integer of milliseconds Black has left on the clock + /// - winc: Integer of White Fisher increment. + /// - binc: Integer of Black Fisher increment. + /// - status: + /// - winner: Color of the winner, if any + /// - wdraw: true if white is offering draw, else omitted + /// - bdraw: true if black is offering draw, else omitted + /// - wtakeback: true if white is proposing takeback, else omitted + /// - btakeback: true if black is proposing takeback, else omitted + internal init( + _type: Components.Schemas.GameStateEvent._typePayload, + moves: Swift.String, + wtime: Swift.Int, + btime: Swift.Int, + winc: Swift.Int, + binc: Swift.Int, + status: Components.Schemas.GameStatus, + winner: Swift.String? = nil, + wdraw: Swift.Bool? = nil, + bdraw: Swift.Bool? = nil, + wtakeback: Swift.Bool? = nil, + btakeback: Swift.Bool? = nil + ) { + self._type = _type + self.moves = moves + self.wtime = wtime + self.btime = btime + self.winc = winc + self.binc = binc + self.status = status + self.winner = winner + self.wdraw = wdraw + self.bdraw = bdraw + self.wtakeback = wtakeback + self.btakeback = btakeback + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case moves + case wtime + case btime + case winc + case binc + case status + case winner + case wdraw + case bdraw + case wtakeback + case btakeback + } + } + /// - Remark: Generated from `#/components/schemas/GameFullEvent`. + internal struct GameFullEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameFullEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case gameFull = "gameFull" + } + /// - Remark: Generated from `#/components/schemas/GameFullEvent/type`. + internal var _type: Components.Schemas.GameFullEvent._typePayload + /// - Remark: Generated from `#/components/schemas/GameFullEvent/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/components/schemas/GameFullEvent/variant`. + internal var variant: Components.Schemas.Variant + /// - Remark: Generated from `#/components/schemas/GameFullEvent/clock`. + @frozen internal enum clockPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/GameFullEvent/clock/case1`. + case Clock(Components.Schemas.Clock) + /// - Remark: Generated from `#/components/schemas/GameFullEvent/clock/case2`. + case case2(OpenAPIRuntime.OpenAPIValueContainer) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .Clock(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .Clock(value): + try value.encode(to: encoder) + case let .case2(value): + try value.encode(to: encoder) + } + } + } + /// - Remark: Generated from `#/components/schemas/GameFullEvent/clock`. + internal var clock: Components.Schemas.GameFullEvent.clockPayload + /// - Remark: Generated from `#/components/schemas/GameFullEvent/speed`. + internal var speed: Components.Schemas.Speed + /// - Remark: Generated from `#/components/schemas/GameFullEvent/perf`. + internal struct perfPayload: Codable, Hashable, Sendable { + /// Translated perf name (e.g. "Classical" or "Blitz") + /// + /// - Remark: Generated from `#/components/schemas/GameFullEvent/perf/name`. + internal var name: Swift.String? + /// Creates a new `perfPayload`. + /// + /// - Parameters: + /// - name: Translated perf name (e.g. "Classical" or "Blitz") + internal init(name: Swift.String? = nil) { + self.name = name + } + internal enum CodingKeys: String, CodingKey { + case name + } + } + /// - Remark: Generated from `#/components/schemas/GameFullEvent/perf`. + internal var perf: Components.Schemas.GameFullEvent.perfPayload + /// - Remark: Generated from `#/components/schemas/GameFullEvent/rated`. + internal var rated: Swift.Bool + /// - Remark: Generated from `#/components/schemas/GameFullEvent/createdAt`. + internal var createdAt: Swift.Double + /// - Remark: Generated from `#/components/schemas/GameFullEvent/white`. + internal var white: Components.Schemas.GameEventPlayer + /// - Remark: Generated from `#/components/schemas/GameFullEvent/black`. + internal var black: Components.Schemas.GameEventPlayer + /// - Remark: Generated from `#/components/schemas/GameFullEvent/initialFen`. + internal var initialFen: Swift.String + /// - Remark: Generated from `#/components/schemas/GameFullEvent/state`. + internal var state: Components.Schemas.GameStateEvent + /// - Remark: Generated from `#/components/schemas/GameFullEvent/tournamentId`. + internal var tournamentId: Swift.String? + /// Creates a new `GameFullEvent`. + /// + /// - Parameters: + /// - _type: + /// - id: + /// - variant: + /// - clock: + /// - speed: + /// - perf: + /// - rated: + /// - createdAt: + /// - white: + /// - black: + /// - initialFen: + /// - state: + /// - tournamentId: + internal init( + _type: Components.Schemas.GameFullEvent._typePayload, + id: Swift.String, + variant: Components.Schemas.Variant, + clock: Components.Schemas.GameFullEvent.clockPayload, + speed: Components.Schemas.Speed, + perf: Components.Schemas.GameFullEvent.perfPayload, + rated: Swift.Bool, + createdAt: Swift.Double, + white: Components.Schemas.GameEventPlayer, + black: Components.Schemas.GameEventPlayer, + initialFen: Swift.String, + state: Components.Schemas.GameStateEvent, + tournamentId: Swift.String? = nil + ) { + self._type = _type + self.id = id + self.variant = variant + self.clock = clock + self.speed = speed + self.perf = perf + self.rated = rated + self.createdAt = createdAt + self.white = white + self.black = black + self.initialFen = initialFen + self.state = state + self.tournamentId = tournamentId + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case id + case variant + case clock + case speed + case perf + case rated + case createdAt + case white + case black + case initialFen + case state + case tournamentId + } + } + /// - Remark: Generated from `#/components/schemas/ChatLineEvent`. + internal struct ChatLineEvent: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case chatLine = "chatLine" + } + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/type`. + internal var _type: Components.Schemas.ChatLineEvent._typePayload + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/room`. + @frozen internal enum roomPayload: String, Codable, Hashable, Sendable { + case player = "player" + case spectator = "spectator" + } + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/room`. + internal var room: Components.Schemas.ChatLineEvent.roomPayload + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/username`. + internal var username: Swift.String + /// - Remark: Generated from `#/components/schemas/ChatLineEvent/text`. + internal var text: Swift.String + /// Creates a new `ChatLineEvent`. + /// + /// - Parameters: + /// - _type: + /// - room: + /// - username: + /// - text: + internal init( + _type: Components.Schemas.ChatLineEvent._typePayload, + room: Components.Schemas.ChatLineEvent.roomPayload, + username: Swift.String, + text: Swift.String + ) { + self._type = _type + self.room = room + self.username = username + self.text = text + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case room + case username + case text + } + } + /// - Remark: Generated from `#/components/schemas/OpponentGone`. + internal struct OpponentGone: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/OpponentGone/type`. + @frozen internal enum _typePayload: String, Codable, Hashable, Sendable { + case opponentGone = "opponentGone" + } + /// - Remark: Generated from `#/components/schemas/OpponentGone/type`. + internal var _type: Components.Schemas.OpponentGone._typePayload + /// - Remark: Generated from `#/components/schemas/OpponentGone/gone`. + internal var gone: Swift.Bool + /// - Remark: Generated from `#/components/schemas/OpponentGone/claimWinInSeconds`. + internal var claimWinInSeconds: Swift.Double? + /// Creates a new `OpponentGone`. + /// + /// - Parameters: + /// - _type: + /// - gone: + /// - claimWinInSeconds: + internal init( + _type: Components.Schemas.OpponentGone._typePayload, + gone: Swift.Bool, + claimWinInSeconds: Swift.Double? = nil + ) { + self._type = _type + self.gone = gone + self.claimWinInSeconds = claimWinInSeconds + } + internal enum CodingKeys: String, CodingKey { + case _type = "type" + case gone + case claimWinInSeconds + } + } + /// - Remark: Generated from `#/components/schemas/NotFound`. + internal struct NotFound: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/NotFound/error`. + internal var error: Swift.String? + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - error: + internal init(error: Swift.String? = nil) { + self.error = error + } + internal enum CodingKeys: String, CodingKey { + case error + } + } + /// - Remark: Generated from `#/components/schemas/GameChat`. + internal typealias GameChat = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/ChallengeOpenJson`. + internal typealias ChallengeOpenJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/BulkPairing`. + internal typealias BulkPairing = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/UciVariant`. + @frozen internal enum UciVariant: String, Codable, Hashable, Sendable { + case chess = "chess" + case crazyhouse = "crazyhouse" + case antichess = "antichess" + case atomic = "atomic" + case horde = "horde" + case kingofthehill = "kingofthehill" + case racingkings = "racingkings" + case _3check = "3check" + } + /// - Remark: Generated from `#/components/schemas/ExternalEngine`. + internal struct ExternalEngine: Codable, Hashable, Sendable { + /// Unique engine registration ID. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/id`. + internal var id: Swift.String + /// Display name of the engine. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/name`. + internal var name: Swift.String + /// A secret token that can be used to + /// [*request* analysis](#tag/External-engine/operation/apiExternalEngineAnalyse) + /// from this external engine. + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/clientSecret`. + internal var clientSecret: Swift.String + /// The user this engine has been registered for. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/userId`. + internal var userId: Swift.String + /// Maximum number of available threads. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/maxThreads`. + internal var maxThreads: Swift.Int + /// Maximum available hash table size, in MiB. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/maxHash`. + internal var maxHash: Swift.Int + /// Estimated depth of normal search. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/defaultDepth`. + internal var defaultDepth: Swift.Int + /// List of supported chess variants. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/variants`. + internal var variants: [Components.Schemas.UciVariant] + /// Arbitrary data that the engine provider can use for identification + /// or bookkeeping. + /// + /// Users can read this information, but updating it requires knowing + /// or changing the `providerSecret`. + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngine/providerData`. + internal var providerData: Swift.String? + /// Creates a new `ExternalEngine`. + /// + /// - Parameters: + /// - id: Unique engine registration ID. + /// - name: Display name of the engine. + /// - clientSecret: A secret token that can be used to + /// - userId: The user this engine has been registered for. + /// - maxThreads: Maximum number of available threads. + /// - maxHash: Maximum available hash table size, in MiB. + /// - defaultDepth: Estimated depth of normal search. + /// - variants: List of supported chess variants. + /// - providerData: Arbitrary data that the engine provider can use for identification + internal init( + id: Swift.String, + name: Swift.String, + clientSecret: Swift.String, + userId: Swift.String, + maxThreads: Swift.Int, + maxHash: Swift.Int, + defaultDepth: Swift.Int, + variants: [Components.Schemas.UciVariant], + providerData: Swift.String? = nil + ) { + self.id = id + self.name = name + self.clientSecret = clientSecret + self.userId = userId + self.maxThreads = maxThreads + self.maxHash = maxHash + self.defaultDepth = defaultDepth + self.variants = variants + self.providerData = providerData + } + internal enum CodingKeys: String, CodingKey { + case id + case name + case clientSecret + case userId + case maxThreads + case maxHash + case defaultDepth + case variants + case providerData + } + } + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration`. + internal struct ExternalEngineRegistration: Codable, Hashable, Sendable { + /// Display name of the engine. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/name`. + internal var name: Swift.String + /// Maximum number of available threads. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/maxThreads`. + internal var maxThreads: Swift.Int + /// Maximum available hash table size, in MiB. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/maxHash`. + internal var maxHash: Swift.Int + /// Estimated depth of normal search. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/defaultDepth`. + internal var defaultDepth: Swift.Int + /// Optional list of supported chess variants. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/variants`. + internal var variants: [Components.Schemas.UciVariant]? + /// A random token that can be used to + /// [wait for analysis requests](#tag/External-engine/operation/apiExternalEngineAcquire) + /// and provide analysis. + /// + /// The engine provider should securely generate a random string. + /// + /// The token will not be readable again, even by the user. + /// + /// The analysis provider can register multiple engines with the same + /// token, even for different users, and wait for analysis requests + /// from any of them. In this case, the request must not be made via + /// CORS, so that the token is not revealed to any of the users. + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/providerSecret`. + internal var providerSecret: Swift.String + /// Arbitrary data that the engine provider can use for identification + /// or bookkeeping. + /// + /// Users can read this information, but updating it requires knowing + /// or changing the `providerSecret`. + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineRegistration/providerData`. + internal var providerData: Swift.String? + /// Creates a new `ExternalEngineRegistration`. + /// + /// - Parameters: + /// - name: Display name of the engine. + /// - maxThreads: Maximum number of available threads. + /// - maxHash: Maximum available hash table size, in MiB. + /// - defaultDepth: Estimated depth of normal search. + /// - variants: Optional list of supported chess variants. + /// - providerSecret: A random token that can be used to + /// - providerData: Arbitrary data that the engine provider can use for identification + internal init( + name: Swift.String, + maxThreads: Swift.Int, + maxHash: Swift.Int, + defaultDepth: Swift.Int, + variants: [Components.Schemas.UciVariant]? = nil, + providerSecret: Swift.String, + providerData: Swift.String? = nil + ) { + self.name = name + self.maxThreads = maxThreads + self.maxHash = maxHash + self.defaultDepth = defaultDepth + self.variants = variants + self.providerSecret = providerSecret + self.providerData = providerData + } + internal enum CodingKeys: String, CodingKey { + case name + case maxThreads + case maxHash + case defaultDepth + case variants + case providerSecret + case providerData + } + } + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork`. + internal struct ExternalEngineWork: Codable, Hashable, Sendable { + /// Arbitary string that identifies the analysis session. + /// Providers may wish to clear the hash table between sessions. + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/sessionId`. + internal var sessionId: Swift.String + /// Number of threads to use for analysis. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/threads`. + internal var threads: Swift.Int + /// Hash table size to use for analysis, in MiB. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/hash`. + internal var hash: Swift.Int + /// Request an infinite search (rather than roughly aiming for + /// `defaultDepth`). + /// + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/infinite`. + internal var infinite: Swift.Bool? + /// Requested number of principal variations. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/multiPv`. + internal var multiPv: Swift.Int + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/variant`. + internal var variant: Components.Schemas.UciVariant + /// Initial position of the game. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/initialFen`. + internal var initialFen: Swift.String + /// List of moves played from the initial position, in UCI notation. + /// + /// - Remark: Generated from `#/components/schemas/ExternalEngineWork/moves`. + internal var moves: [Swift.String] + /// Creates a new `ExternalEngineWork`. + /// + /// - Parameters: + /// - sessionId: Arbitary string that identifies the analysis session. + /// - threads: Number of threads to use for analysis. + /// - hash: Hash table size to use for analysis, in MiB. + /// - infinite: Request an infinite search (rather than roughly aiming for + /// - multiPv: Requested number of principal variations. + /// - variant: + /// - initialFen: Initial position of the game. + /// - moves: List of moves played from the initial position, in UCI notation. + internal init( + sessionId: Swift.String, + threads: Swift.Int, + hash: Swift.Int, + infinite: Swift.Bool? = nil, + multiPv: Swift.Int, + variant: Components.Schemas.UciVariant, + initialFen: Swift.String, + moves: [Swift.String] + ) { + self.sessionId = sessionId + self.threads = threads + self.hash = hash + self.infinite = infinite + self.multiPv = multiPv + self.variant = variant + self.initialFen = initialFen + self.moves = moves + } + internal enum CodingKeys: String, CodingKey { + case sessionId + case threads + case hash + case infinite + case multiPv + case variant + case initialFen + case moves + } + } + /// - Remark: Generated from `#/components/schemas/OAuthError`. + internal struct OAuthError: Codable, Hashable, Sendable { + /// The cause of the error. + /// + /// - Remark: Generated from `#/components/schemas/OAuthError/error`. + internal var error: Swift.String? + /// The reason why the request was rejected. + /// + /// - Remark: Generated from `#/components/schemas/OAuthError/error_description`. + internal var error_description: Swift.String? + /// Creates a new `OAuthError`. + /// + /// - Parameters: + /// - error: The cause of the error. + /// - error_description: The reason why the request was rejected. + internal init( + error: Swift.String? = nil, + error_description: Swift.String? = nil + ) { + self.error = error + self.error_description = error_description + } + internal enum CodingKeys: String, CodingKey { + case error + case error_description + } + } + /// - Remark: Generated from `#/components/schemas/OpeningExplorerJson`. + internal typealias OpeningExplorerJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/OpeningExplorerPlayerJson`. + internal typealias OpeningExplorerPlayerJson = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/MasterGamePgn`. + internal typealias MasterGamePgn = OpenAPIRuntime.OpenAPIValueContainer + /// - Remark: Generated from `#/components/schemas/Move`. + internal struct Move: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/Move/uci`. + internal var uci: Swift.String? + /// - Remark: Generated from `#/components/schemas/Move/san`. + internal var san: Swift.String? + /// - Remark: Generated from `#/components/schemas/Move/category`. + @frozen internal enum categoryPayload: String, Codable, Hashable, Sendable { + case loss = "loss" + case unknown = "unknown" + case maybe_hyphen_loss = "maybe-loss" + case blessed_hyphen_loss = "blessed-loss" + case draw = "draw" + case cursed_hyphen_win = "cursed-win" + case maybe_hyphen_win = "maybe-win" + case win = "win" + } + /// - Remark: Generated from `#/components/schemas/Move/category`. + internal var category: Components.Schemas.Move.categoryPayload? + /// DTZ50'' with rounding or null if unknown + /// + /// - Remark: Generated from `#/components/schemas/Move/dtz`. + internal var dtz: Swift.Int? + /// DTZ50'' (only if guaranteed to be not rounded) or null if unknown + /// + /// + /// - Remark: Generated from `#/components/schemas/Move/precise_dtz`. + internal var precise_dtz: Swift.Int? + /// Distance to mate (only for positions with not more than 5 pieces) + /// + /// - Remark: Generated from `#/components/schemas/Move/dtm`. + internal var dtm: Swift.Int? + /// - Remark: Generated from `#/components/schemas/Move/zeroing`. + internal var zeroing: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Move/checkmate`. + internal var checkmate: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Move/stalemate`. + internal var stalemate: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Move/variant_win`. + internal var variant_win: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Move/variant_loss`. + internal var variant_loss: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/Move/insufficient_material`. + internal var insufficient_material: Swift.Bool? + /// Creates a new `Move`. + /// + /// - Parameters: + /// - uci: + /// - san: + /// - category: + /// - dtz: DTZ50'' with rounding or null if unknown + /// - precise_dtz: DTZ50'' (only if guaranteed to be not rounded) or null if unknown + /// - dtm: Distance to mate (only for positions with not more than 5 pieces) + /// - zeroing: + /// - checkmate: + /// - stalemate: + /// - variant_win: + /// - variant_loss: + /// - insufficient_material: + internal init( + uci: Swift.String? = nil, + san: Swift.String? = nil, + category: Components.Schemas.Move.categoryPayload? = nil, + dtz: Swift.Int? = nil, + precise_dtz: Swift.Int? = nil, + dtm: Swift.Int? = nil, + zeroing: Swift.Bool? = nil, + checkmate: Swift.Bool? = nil, + stalemate: Swift.Bool? = nil, + variant_win: Swift.Bool? = nil, + variant_loss: Swift.Bool? = nil, + insufficient_material: Swift.Bool? = nil + ) { + self.uci = uci + self.san = san + self.category = category + self.dtz = dtz + self.precise_dtz = precise_dtz + self.dtm = dtm + self.zeroing = zeroing + self.checkmate = checkmate + self.stalemate = stalemate + self.variant_win = variant_win + self.variant_loss = variant_loss + self.insufficient_material = insufficient_material + } + internal enum CodingKeys: String, CodingKey { + case uci + case san + case category + case dtz + case precise_dtz + case dtm + case zeroing + case checkmate + case stalemate + case variant_win + case variant_loss + case insufficient_material + } + } + /// - Remark: Generated from `#/components/schemas/TablebaseJson`. + internal struct TablebaseJson: Codable, Hashable, Sendable { + /// `cursed-win` and `blessed-loss` means the 50-move rule prevents + /// the decisive result. + /// + /// `maybe-win` and `maybe-loss` means exact result is unknown due to + /// [DTZ rounding](https://syzygy-tables.info/metrics#dtz), i.e., the + /// win or loss could also be prevented by the 50-move rule if + /// the user has deviated from the tablebase recommendation since the + /// last pawn move or capture. + /// + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/category`. + @frozen internal enum categoryPayload: String, Codable, Hashable, Sendable { + case win = "win" + case unknown = "unknown" + case maybe_hyphen_win = "maybe-win" + case cursed_hyphen_win = "cursed-win" + case draw = "draw" + case blessed_hyphen_loss = "blessed-loss" + case maybe_hyphen_loss = "maybe-loss" + case loss = "loss" + } + /// `cursed-win` and `blessed-loss` means the 50-move rule prevents + /// the decisive result. + /// + /// `maybe-win` and `maybe-loss` means exact result is unknown due to + /// [DTZ rounding](https://syzygy-tables.info/metrics#dtz), i.e., the + /// win or loss could also be prevented by the 50-move rule if + /// the user has deviated from the tablebase recommendation since the + /// last pawn move or capture. + /// + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/category`. + internal var category: Components.Schemas.TablebaseJson.categoryPayload? + /// [DTZ50'' with rounding](https://syzygy-tables.info/metrics#dtz) or null if unknown + /// + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/dtz`. + internal var dtz: Swift.Int? + /// DTZ50'' (only if guaranteed to be not rounded) or null if unknown + /// + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/precise_dtz`. + internal var precise_dtz: Swift.Int? + /// Distance to mate (only for positions with not more than 5 pieces) + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/dtm`. + internal var dtm: Swift.Int? + /// - Remark: Generated from `#/components/schemas/TablebaseJson/checkmate`. + internal var checkmate: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/TablebaseJson/stalemate`. + internal var stalemate: Swift.Bool? + /// Only in chess variants + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/variant_win`. + internal var variant_win: Swift.Bool? + /// Only in chess variants + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/variant_loss`. + internal var variant_loss: Swift.Bool? + /// - Remark: Generated from `#/components/schemas/TablebaseJson/insufficient_material`. + internal var insufficient_material: Swift.Bool? + /// Information about legal moves, best first + /// + /// - Remark: Generated from `#/components/schemas/TablebaseJson/moves`. + internal var moves: [Components.Schemas.Move]? + /// Creates a new `TablebaseJson`. + /// + /// - Parameters: + /// - category: `cursed-win` and `blessed-loss` means the 50-move rule prevents + /// - dtz: [DTZ50'' with rounding](https://syzygy-tables.info/metrics#dtz) or null if unknown + /// - precise_dtz: DTZ50'' (only if guaranteed to be not rounded) or null if unknown + /// - dtm: Distance to mate (only for positions with not more than 5 pieces) + /// - checkmate: + /// - stalemate: + /// - variant_win: Only in chess variants + /// - variant_loss: Only in chess variants + /// - insufficient_material: + /// - moves: Information about legal moves, best first + internal init( + category: Components.Schemas.TablebaseJson.categoryPayload? = nil, + dtz: Swift.Int? = nil, + precise_dtz: Swift.Int? = nil, + dtm: Swift.Int? = nil, + checkmate: Swift.Bool? = nil, + stalemate: Swift.Bool? = nil, + variant_win: Swift.Bool? = nil, + variant_loss: Swift.Bool? = nil, + insufficient_material: Swift.Bool? = nil, + moves: [Components.Schemas.Move]? = nil + ) { + self.category = category + self.dtz = dtz + self.precise_dtz = precise_dtz + self.dtm = dtm + self.checkmate = checkmate + self.stalemate = stalemate + self.variant_win = variant_win + self.variant_loss = variant_loss + self.insufficient_material = insufficient_material + self.moves = moves + } + internal enum CodingKeys: String, CodingKey { + case category + case dtz + case precise_dtz + case dtm + case checkmate + case stalemate + case variant_win + case variant_loss + case insufficient_material + case moves + } + } + } + /// Types generated from the `#/components/parameters` section of the OpenAPI document. + internal enum Parameters {} + /// Types generated from the `#/components/requestBodies` section of the OpenAPI document. + internal enum RequestBodies {} + /// Types generated from the `#/components/responses` section of the OpenAPI document. + internal enum Responses {} + /// Types generated from the `#/components/headers` section of the OpenAPI document. + internal enum Headers {} +} + +/// API operations, with input and output types, generated from `#/paths` in the OpenAPI document. +internal enum Operations { + /// Get real-time users status + /// + /// Read the `online`, `playing` and `streaming` flags of several users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// Use it to track players and know when they're connected on lichess and playing games. + /// + /// + /// - Remark: HTTP `GET /api/users/status`. + /// - Remark: Generated from `#/paths//api/users/status/get(apiUsersStatus)`. + internal enum apiUsersStatus { + internal static let id: Swift.String = "apiUsersStatus" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/status/GET/query`. + internal struct Query: Sendable, Hashable { + /// User IDs separated by commas. Up to 100 IDs. + /// + /// - Remark: Generated from `#/paths/api/users/status/GET/query/ids`. + internal var ids: Swift.String + /// Also return the ID of the game being played, if any, for each player, in a `playingId` field. + /// Defaults to `false` to preserve server resources. + /// + /// + /// - Remark: Generated from `#/paths/api/users/status/GET/query/withGameIds`. + internal var withGameIds: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - ids: User IDs separated by commas. Up to 100 IDs. + /// - withGameIds: Also return the ID of the game being played, if any, for each player, in a `playingId` field. + internal init( + ids: Swift.String, + withGameIds: Swift.Bool? = nil + ) { + self.ids = ids + self.withGameIds = withGameIds + } + } + internal var query: Operations.apiUsersStatus.Input.Query + /// - Remark: Generated from `#/paths/api/users/status/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUsersStatus.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUsersStatus.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUsersStatus.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiUsersStatus.Input.Query, + headers: Operations.apiUsersStatus.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUsersStatus.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload`. + internal struct jsonPayloadPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/name`. + internal var name: Swift.String + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/title`. + internal var title: Swift.String? + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/online`. + internal var online: Swift.Bool? + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/playing`. + internal var playing: Swift.Bool? + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/streaming`. + internal var streaming: Swift.Bool? + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/jsonPayload/patron`. + internal var patron: Swift.Bool? + /// Creates a new `jsonPayloadPayload`. + /// + /// - Parameters: + /// - id: + /// - name: + /// - title: + /// - online: + /// - playing: + /// - streaming: + /// - patron: + internal init( + id: Swift.String, + name: Swift.String, + title: Swift.String? = nil, + online: Swift.Bool? = nil, + playing: Swift.Bool? = nil, + streaming: Swift.Bool? = nil, + patron: Swift.Bool? = nil + ) { + self.id = id + self.name = name + self.title = title + self.online = online + self.playing = playing + self.streaming = streaming + self.patron = patron + } + internal enum CodingKeys: String, CodingKey { + case id + case name + case title + case online + case playing + case streaming + case patron + } + } + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/json`. + internal typealias jsonPayload = [Operations.apiUsersStatus.Output.Ok.Body.jsonPayloadPayload] + /// - Remark: Generated from `#/paths/api/users/status/GET/responses/200/content/application\/json`. + case json(Operations.apiUsersStatus.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.apiUsersStatus.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUsersStatus.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUsersStatus.Output.Ok.Headers = .init(), + body: Operations.apiUsersStatus.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of users and their respective statuses. + /// + /// - Remark: Generated from `#/paths//api/users/status/get(apiUsersStatus)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUsersStatus.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUsersStatus.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get all top 10 + /// + /// Get the top 10 players for each speed and variant. + /// See <https://lichess.org/player>. + /// + /// + /// - Remark: HTTP `GET /api/player`. + /// - Remark: Generated from `#/paths//api/player/get(player)`. + internal enum player { + internal static let id: Swift.String = "player" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.player.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.player.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.player.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.player.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.player.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/player/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/GET/responses/200/content/application\/json`. + case json(Components.Schemas.Top10s) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Top10s { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.player.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.player.Output.Ok.Headers = .init(), + body: Operations.player.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of variants with their respective top players. + /// + /// - Remark: Generated from `#/paths//api/player/get(player)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.player.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.player.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get one leaderboard + /// + /// Get the leaderboard for a single speed or variant (a.k.a. `perfType`). + /// There is no leaderboard for correspondence or puzzles. + /// See <https://lichess.org/player/top/200/bullet>. + /// + /// + /// - Remark: HTTP `GET /api/player/top/{nb}/{perfType}`. + /// - Remark: Generated from `#/paths//api/player/top/{nb}/{perfType}/get(playerTopNbPerfType)`. + internal enum playerTopNbPerfType { + internal static let id: Swift.String = "playerTopNbPerfType" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/path`. + internal struct Path: Sendable, Hashable { + /// How many users to fetch + /// + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/path/nb`. + internal var nb: Swift.Int + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/path/perfType`. + @frozen internal enum perfTypePayload: String, Codable, Hashable, Sendable { + case ultraBullet = "ultraBullet" + case bullet = "bullet" + case blitz = "blitz" + case rapid = "rapid" + case classical = "classical" + case chess960 = "chess960" + case crazyhouse = "crazyhouse" + case antichess = "antichess" + case atomic = "atomic" + case horde = "horde" + case kingOfTheHill = "kingOfTheHill" + case racingKings = "racingKings" + case threeCheck = "threeCheck" + } + /// The speed or variant + /// + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/path/perfType`. + internal var perfType: Operations.playerTopNbPerfType.Input.Path.perfTypePayload + /// Creates a new `Path`. + /// + /// - Parameters: + /// - nb: How many users to fetch + /// - perfType: The speed or variant + internal init( + nb: Swift.Int, + perfType: Operations.playerTopNbPerfType.Input.Path.perfTypePayload + ) { + self.nb = nb + self.perfType = perfType + } + } + internal var path: Operations.playerTopNbPerfType.Input.Path + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.playerTopNbPerfType.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.playerTopNbPerfType.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.playerTopNbPerfType.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.playerTopNbPerfType.Input.Path, + headers: Operations.playerTopNbPerfType.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.playerTopNbPerfType.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/top/{nb}/{perfType}/GET/responses/200/content/application\/vnd.lichess.v3+json`. + case application_vnd_period_lichess_period_v3_plus_json(Components.Schemas.Leaderboard) + /// The associated value of the enum case if `self` is `.application_vnd_period_lichess_period_v3_plus_json`. + /// + /// - Throws: An error if `self` is not `.application_vnd_period_lichess_period_v3_plus_json`. + /// - SeeAlso: `.application_vnd_period_lichess_period_v3_plus_json`. + internal var application_vnd_period_lichess_period_v3_plus_json: Components.Schemas.Leaderboard { + get throws { + switch self { + case let .application_vnd_period_lichess_period_v3_plus_json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.playerTopNbPerfType.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.playerTopNbPerfType.Output.Ok.Headers = .init(), + body: Operations.playerTopNbPerfType.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of top players for the variant. + /// + /// - Remark: Generated from `#/paths//api/player/top/{nb}/{perfType}/get(playerTopNbPerfType)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.playerTopNbPerfType.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.playerTopNbPerfType.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_vnd_period_lichess_period_v3_plus_json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/vnd.lichess.v3+json": + self = .application_vnd_period_lichess_period_v3_plus_json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_vnd_period_lichess_period_v3_plus_json: + return "application/vnd.lichess.v3+json" + } + } + internal static var allCases: [Self] { + [ + .application_vnd_period_lichess_period_v3_plus_json + ] + } + } + } + /// Get user public data + /// + /// Read public data of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}`. + /// - Remark: Generated from `#/paths//api/user/{username}/get(apiUser)`. + internal enum apiUser { + internal static let id: Swift.String = "apiUser" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiUser.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include user trophies + /// + /// - Remark: Generated from `#/paths/api/user/{username}/GET/query/trophies`. + internal var trophies: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - trophies: Include user trophies + internal init(trophies: Swift.Bool? = nil) { + self.trophies = trophies + } + } + internal var query: Operations.apiUser.Input.Query + /// - Remark: Generated from `#/paths/api/user/{username}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUser.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUser.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiUser.Input.Path, + query: Operations.apiUser.Input.Query = .init(), + headers: Operations.apiUser.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUser.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.UserExtended) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.UserExtended { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUser.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUser.Output.Ok.Headers = .init(), + body: Operations.apiUser.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The information of the user. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/get(apiUser)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUser.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUser.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get rating history of a user + /// + /// Read rating history of a user, for all perf types. + /// There is at most one entry per day. + /// Format of an entry is `[year, month, day, rating]`. + /// `month` starts at zero (January). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/rating-history`. + /// - Remark: Generated from `#/paths//api/user/{username}/rating-history/get(apiUserRatingHistory)`. + internal enum apiUserRatingHistory { + internal static let id: Swift.String = "apiUserRatingHistory" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiUserRatingHistory.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserRatingHistory.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserRatingHistory.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserRatingHistory.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiUserRatingHistory.Input.Path, + headers: Operations.apiUserRatingHistory.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserRatingHistory.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/rating-history/GET/responses/200/content/application\/json`. + case json(Components.Schemas.RatingHistory) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.RatingHistory { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserRatingHistory.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserRatingHistory.Output.Ok.Headers = .init(), + body: Operations.apiUserRatingHistory.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The rating history of the user. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/rating-history/get(apiUserRatingHistory)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserRatingHistory.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserRatingHistory.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get performance statistics of a user + /// + /// Read performance statistics of a user, for a single performance. + /// Similar to the [performance pages on the website](https://lichess.org/@/thibault/perf/bullet). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/perf/{perf}`. + /// - Remark: Generated from `#/paths//api/user/{username}/perf/{perf}/get(apiUserPerf)`. + internal enum apiUserPerf { + internal static let id: Swift.String = "apiUserPerf" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/path/username`. + internal var username: Swift.String + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/path/perf`. + internal var perf: Components.Schemas.PerfType + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + /// - perf: + internal init( + username: Swift.String, + perf: Components.Schemas.PerfType + ) { + self.username = username + self.perf = perf + } + } + internal var path: Operations.apiUserPerf.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserPerf.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserPerf.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserPerf.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiUserPerf.Input.Path, + headers: Operations.apiUserPerf.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserPerf.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/perf/{perf}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.PerfStat) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.PerfStat { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserPerf.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserPerf.Output.Ok.Headers = .init(), + body: Operations.apiUserPerf.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The performance statistics of the user + /// + /// - Remark: Generated from `#/paths//api/user/{username}/perf/{perf}/get(apiUserPerf)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserPerf.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserPerf.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get user activity + /// + /// Read data to generate the activity feed of a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/activity`. + /// - Remark: Generated from `#/paths//api/user/{username}/activity/get(apiUserActivity)`. + internal enum apiUserActivity { + internal static let id: Swift.String = "apiUserActivity" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiUserActivity.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserActivity.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserActivity.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserActivity.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiUserActivity.Input.Path, + headers: Operations.apiUserActivity.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserActivity.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/activity/GET/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserActivity.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserActivity.Output.Ok.Headers = .init(), + body: Operations.apiUserActivity.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The activity feed of the user. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/activity/get(apiUserActivity)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserActivity.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserActivity.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get the daily puzzle + /// + /// Get the daily Lichess puzzle in JSON format. + /// Alternatively, you can [post it in your slack workspace](https://lichess.org/daily-puzzle-slack). + /// + /// + /// - Remark: HTTP `GET /api/puzzle/daily`. + /// - Remark: Generated from `#/paths//api/puzzle/daily/get(apiPuzzleDaily)`. + internal enum apiPuzzleDaily { + internal static let id: Swift.String = "apiPuzzleDaily" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/daily/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleDaily.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleDaily.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiPuzzleDaily.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiPuzzleDaily.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/daily/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/daily/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiPuzzleDaily.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/puzzle/daily/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/daily/GET/responses/200/content/application\/json`. + case json(Components.Schemas.PuzzleAndGame) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.PuzzleAndGame { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiPuzzleDaily.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiPuzzleDaily.Output.Ok.Headers = .init(), + body: Operations.apiPuzzleDaily.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The daily puzzle. + /// + /// - Remark: Generated from `#/paths//api/puzzle/daily/get(apiPuzzleDaily)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiPuzzleDaily.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiPuzzleDaily.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get a puzzle by its ID + /// + /// Get a single Lichess puzzle in JSON format. + /// + /// - Remark: HTTP `GET /api/puzzle/{id}`. + /// - Remark: Generated from `#/paths//api/puzzle/{id}/get(apiPuzzleId)`. + internal enum apiPuzzleId { + internal static let id: Swift.String = "apiPuzzleId" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The puzzle ID + /// + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The puzzle ID + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiPuzzleId.Input.Path + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleId.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleId.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiPuzzleId.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiPuzzleId.Input.Path, + headers: Operations.apiPuzzleId.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiPuzzleId.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/{id}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.PuzzleAndGame) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.PuzzleAndGame { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiPuzzleId.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiPuzzleId.Output.Ok.Headers = .init(), + body: Operations.apiPuzzleId.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The requested puzzle. + /// + /// - Remark: Generated from `#/paths//api/puzzle/{id}/get(apiPuzzleId)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiPuzzleId.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiPuzzleId.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get your puzzle activity + /// + /// Download your puzzle activity in [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Puzzle activity is sorted by reverse chronological order (most recent first) + /// We recommend streaming the response, for it can be very long. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/activity`. + /// - Remark: Generated from `#/paths//api/puzzle/activity/get(apiPuzzleActivity)`. + internal enum apiPuzzleActivity { + internal static let id: Swift.String = "apiPuzzleActivity" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many entries to download. Leave empty to download all activity. + /// + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/query/max`. + internal var max: Swift.Int? + /// Download entries before this timestamp. Defaults to now. Use `before` and `max` for pagination. + /// + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/query/before`. + internal var before: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - max: How many entries to download. Leave empty to download all activity. + /// - before: Download entries before this timestamp. Defaults to now. Use `before` and `max` for pagination. + internal init( + max: Swift.Int? = nil, + before: Swift.Int? = nil + ) { + self.max = max + self.before = before + } + } + internal var query: Operations.apiPuzzleActivity.Input.Query + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleActivity.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleActivity.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiPuzzleActivity.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiPuzzleActivity.Input.Query = .init(), + headers: Operations.apiPuzzleActivity.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiPuzzleActivity.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/activity/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiPuzzleActivity.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiPuzzleActivity.Output.Ok.Headers = .init(), + body: Operations.apiPuzzleActivity.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The puzzle activity of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/puzzle/activity/get(apiPuzzleActivity)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiPuzzleActivity.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiPuzzleActivity.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Get your puzzle dashboard + /// + /// Download your [puzzle dashboard](https://lichess.org/training/dashboard/30/dashboard) as JSON. + /// Also includes all puzzle themes played, with aggregated results. + /// Allows re-creating the [improvement/strengths](https://lichess.org/training/dashboard/30/improvementAreas) interfaces. + /// + /// + /// - Remark: HTTP `GET /api/puzzle/dashboard/{days}`. + /// - Remark: Generated from `#/paths//api/puzzle/dashboard/{days}/get(apiPuzzleDashboard)`. + internal enum apiPuzzleDashboard { + internal static let id: Swift.String = "apiPuzzleDashboard" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/path`. + internal struct Path: Sendable, Hashable { + /// How many days to look back when aggregating puzzle results. 30 is sensible. + /// + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/path/days`. + internal var days: Swift.Int + /// Creates a new `Path`. + /// + /// - Parameters: + /// - days: How many days to look back when aggregating puzzle results. 30 is sensible. + internal init(days: Swift.Int) { + self.days = days + } + } + internal var path: Operations.apiPuzzleDashboard.Input.Path + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleDashboard.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPuzzleDashboard.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiPuzzleDashboard.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiPuzzleDashboard.Input.Path, + headers: Operations.apiPuzzleDashboard.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiPuzzleDashboard.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/puzzle/dashboard/{days}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.PuzzleDashboardJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.PuzzleDashboardJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiPuzzleDashboard.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiPuzzleDashboard.Output.Ok.Headers = .init(), + body: Operations.apiPuzzleDashboard.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The puzzle dashboard of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/puzzle/dashboard/{days}/get(apiPuzzleDashboard)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiPuzzleDashboard.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiPuzzleDashboard.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get the storm dashboard of a player + /// + /// Download the [storm dashboard](https://lichess.org/storm/dashboard/mrbasso) of any player as JSON. + /// Contains the aggregated highscores, and the history of storm runs aggregated by days. + /// Use `?days=0` if you only care about the highscores. + /// + /// + /// - Remark: HTTP `GET /api/storm/dashboard/{username}`. + /// - Remark: Generated from `#/paths//api/storm/dashboard/{username}/get(apiStormDashboard)`. + internal enum apiStormDashboard { + internal static let id: Swift.String = "apiStormDashboard" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/path`. + internal struct Path: Sendable, Hashable { + /// Username of the player + /// + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: Username of the player + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiStormDashboard.Input.Path + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many days of history to return + /// + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/query/days`. + internal var days: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - days: How many days of history to return + internal init(days: Swift.Int? = nil) { + self.days = days + } + } + internal var query: Operations.apiStormDashboard.Input.Query + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStormDashboard.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStormDashboard.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiStormDashboard.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiStormDashboard.Input.Path, + query: Operations.apiStormDashboard.Input.Query = .init(), + headers: Operations.apiStormDashboard.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiStormDashboard.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/storm/dashboard/{username}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.StormDashboardJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.StormDashboardJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiStormDashboard.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiStormDashboard.Output.Ok.Headers = .init(), + body: Operations.apiStormDashboard.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The storm dashboard of a player. + /// + /// - Remark: Generated from `#/paths//api/storm/dashboard/{username}/get(apiStormDashboard)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiStormDashboard.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiStormDashboard.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create and join a puzzle race + /// + /// Create a new private [puzzle race](https://lichess.org/racer). + /// The Lichess user who creates the race must join the race page, + /// and manually start the race when enough players have joined. + /// - <https://lichess.org/racer> + /// + /// + /// - Remark: HTTP `POST /api/racer`. + /// - Remark: Generated from `#/paths//api/racer/post(racerPost)`. + internal enum racerPost { + internal static let id: Swift.String = "racerPost" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/racer/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.racerPost.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.racerPost.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.racerPost.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.racerPost.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/racer/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/racer/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.racerPost.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/racer/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/racer/POST/responses/200/content/application\/json`. + case json(Components.Schemas.PuzzleRaceJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.PuzzleRaceJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.racerPost.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.racerPost.Output.Ok.Headers = .init(), + body: Operations.racerPost.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The new puzzle race. + /// + /// - Remark: Generated from `#/paths//api/racer/post(racerPost)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.racerPost.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.racerPost.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get users by ID + /// + /// Get up to 300 users by their IDs. Users are returned in the same order as the IDs. + /// The method is `POST` to allow a longer list of IDs to be sent in the request body. + /// Please do not try to download all the Lichess users with this endpoint, or any other endpoint. + /// An API is not a way to fully export a website. We do not provide a full download of the Lichess users. + /// This endpoint is limited to 8,000 users every 10 minutes, and 120,000 every day. + /// + /// + /// - Remark: HTTP `POST /api/users`. + /// - Remark: Generated from `#/paths//api/users/post(apiUsers)`. + internal enum apiUsers { + internal static let id: Swift.String = "apiUsers" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUsers.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUsers.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUsers.Input.Headers + /// - Remark: Generated from `#/paths/api/users/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.apiUsers.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiUsers.Input.Headers = .init(), + body: Operations.apiUsers.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUsers.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/users/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/users/POST/responses/200/content/application\/json`. + case json([Components.Schemas.User]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.User] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUsers.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUsers.Output.Ok.Headers = .init(), + body: Operations.apiUsers.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of users. + /// + /// - Remark: Generated from `#/paths//api/users/post(apiUsers)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUsers.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUsers.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my profile + /// + /// Public information about the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account`. + /// - Remark: Generated from `#/paths//api/account/get(accountMe)`. + internal enum accountMe { + internal static let id: Swift.String = "accountMe" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountMe.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountMe.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.accountMe.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.accountMe.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.accountMe.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/GET/responses/200/content/application\/json`. + case json(Components.Schemas.UserExtended) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.UserExtended { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.accountMe.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.accountMe.Output.Ok.Headers = .init(), + body: Operations.accountMe.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The public information about the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/get(accountMe)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.accountMe.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.accountMe.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my email address + /// + /// Read the email address of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/account/email`. + /// - Remark: Generated from `#/paths//api/account/email/get(accountEmail)`. + internal enum accountEmail { + internal static let id: Swift.String = "accountEmail" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/email/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountEmail.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountEmail.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.accountEmail.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.accountEmail.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.accountEmail.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/content/json/email`. + internal var email: Swift.String? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - email: + internal init(email: Swift.String? = nil) { + self.email = email + } + internal enum CodingKeys: String, CodingKey { + case email + } + } + /// - Remark: Generated from `#/paths/api/account/email/GET/responses/200/content/application\/json`. + case json(Operations.accountEmail.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.accountEmail.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.accountEmail.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.accountEmail.Output.Ok.Headers = .init(), + body: Operations.accountEmail.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The email address of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/email/get(accountEmail)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.accountEmail.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.accountEmail.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my preferences + /// + /// Read the preferences of the logged in user. + /// - <https://lichess.org/account/preferences/game-display> + /// - <https://github.com/ornicar/lila/blob/master/modules/pref/src/main/Pref.scala> + /// + /// + /// - Remark: HTTP `GET /api/account/preferences`. + /// - Remark: Generated from `#/paths//api/account/preferences/get(account)`. + internal enum account { + internal static let id: Swift.String = "account" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/preferences/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.account.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.account.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.account.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.account.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.account.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/content/json/prefs`. + internal var prefs: Components.Schemas.UserPreferences? + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/content/json/language`. + internal var language: Swift.String? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - prefs: + /// - language: + internal init( + prefs: Components.Schemas.UserPreferences? = nil, + language: Swift.String? = nil + ) { + self.prefs = prefs + self.language = language + } + internal enum CodingKeys: String, CodingKey { + case prefs + case language + } + } + /// - Remark: Generated from `#/paths/api/account/preferences/GET/responses/200/content/application\/json`. + case json(Operations.account.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.account.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.account.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.account.Output.Ok.Headers = .init(), + body: Operations.account.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The preferences of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/preferences/get(account)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.account.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.account.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my kid mode status + /// + /// Read the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `GET /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/get(accountKid)`. + internal enum accountKid { + internal static let id: Swift.String = "accountKid" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountKid.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountKid.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.accountKid.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.accountKid.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.accountKid.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/content/json/kid`. + internal var kid: Swift.Bool? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - kid: + internal init(kid: Swift.Bool? = nil) { + self.kid = kid + } + internal enum CodingKeys: String, CodingKey { + case kid + } + } + /// - Remark: Generated from `#/paths/api/account/kid/GET/responses/200/content/application\/json`. + case json(Operations.accountKid.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.accountKid.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.accountKid.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.accountKid.Output.Ok.Headers = .init(), + body: Operations.accountKid.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The kid mode status of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/kid/get(accountKid)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.accountKid.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.accountKid.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Set my kid mode status + /// + /// Set the kid mode status of the logged in user. + /// - <https://lichess.org/account/kid> + /// + /// + /// - Remark: HTTP `POST /api/account/kid`. + /// - Remark: Generated from `#/paths//api/account/kid/post(accountKidPost)`. + internal enum accountKidPost { + internal static let id: Swift.String = "accountKidPost" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/POST/query`. + internal struct Query: Sendable, Hashable { + /// Kid mode status + /// + /// - Remark: Generated from `#/paths/api/account/kid/POST/query/v`. + internal var v: Swift.Bool + /// Creates a new `Query`. + /// + /// - Parameters: + /// - v: Kid mode status + internal init(v: Swift.Bool) { + self.v = v + } + } + internal var query: Operations.accountKidPost.Input.Query + /// - Remark: Generated from `#/paths/api/account/kid/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountKidPost.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.accountKidPost.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.accountKidPost.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.accountKidPost.Input.Query, + headers: Operations.accountKidPost.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.accountKidPost.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/kid/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/kid/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.accountKidPost.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.accountKidPost.Output.Ok.Headers = .init(), + body: Operations.accountKidPost.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The kid mode status was set successfully for the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/kid/post(accountKidPost)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.accountKidPost.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.accountKidPost.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my timeline + /// + /// Get the timeline events of the logged in user. + /// + /// + /// - Remark: HTTP `GET /api/timeline`. + /// - Remark: Generated from `#/paths//api/timeline/get(timeline)`. + internal enum timeline { + internal static let id: Swift.String = "timeline" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/timeline/GET/query`. + internal struct Query: Sendable, Hashable { + /// Show events since this timestamp. + /// + /// - Remark: Generated from `#/paths/api/timeline/GET/query/since`. + internal var since: Swift.Int? + /// Max number of events to fetch. + /// + /// - Remark: Generated from `#/paths/api/timeline/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - since: Show events since this timestamp. + /// - nb: Max number of events to fetch. + internal init( + since: Swift.Int? = nil, + nb: Swift.Int? = nil + ) { + self.since = since + self.nb = nb + } + } + internal var query: Operations.timeline.Input.Query + /// - Remark: Generated from `#/paths/api/timeline/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.timeline.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.timeline.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.timeline.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.timeline.Input.Query = .init(), + headers: Operations.timeline.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/timeline/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/timeline/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.timeline.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/timeline/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/timeline/GET/responses/200/content/application\/json`. + case json(Components.Schemas.Timeline) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Timeline { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.timeline.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.timeline.Output.Ok.Headers = .init(), + body: Operations.timeline.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The events in the timeline of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/timeline/get(timeline)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.timeline.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.timeline.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Export one game + /// + /// Download one game in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /game/export/{gameId}`. + /// - Remark: Generated from `#/paths//game/export/{gameId}/get(gamePgn)`. + internal enum gamePgn { + internal static let id: Swift.String = "gamePgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The game ID (8 characters). + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: The game ID (8 characters). + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.gamePgn.Input.Path + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/division`. + internal var division: Swift.Bool? + /// Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// Example: `5... g4? { (-0.98 → 0.60) Mistake. Best move was h6. } (5... h6 6. d4 Ne7 7. g3 d5 8. exd5 fxg3 9. hxg3 c6 10. dxc6)` + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/literate`. + internal var literate: Swift.Bool? + /// URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + /// Example: <https://gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt> + /// + /// + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/query/players`. + internal var players: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + /// - literate: Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// - players: URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + internal init( + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil, + literate: Swift.Bool? = nil, + players: Swift.String? = nil + ) { + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + self.literate = literate + self.players = players + } + } + internal var query: Operations.gamePgn.Input.Query + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamePgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamePgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamePgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.gamePgn.Input.Path, + query: Operations.gamePgn.Input.Query = .init(), + headers: Operations.gamePgn.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamePgn.Output.Ok.Headers + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/game/export/{gameId}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.GameJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.GameJson { + get throws { + switch self { + case let .json(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/json", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamePgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamePgn.Output.Ok.Headers = .init(), + body: Operations.gamePgn.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game representation. + /// + /// - Remark: Generated from `#/paths//game/export/{gameId}/get(gamePgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamePgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamePgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .json + ] + } + } + } + /// Export ongoing game of a user + /// + /// Download the ongoing game, or the last game played, of a user. + /// Available in either PGN or JSON format. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/current-game`. + /// - Remark: Generated from `#/paths//api/user/{username}/current-game/get(apiUserCurrentGame)`. + internal enum apiUserCurrentGame { + internal static let id: Swift.String = "apiUserCurrentGame" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiUserCurrentGame.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/division`. + internal var division: Swift.Bool? + /// Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// Example: `5... g4? { (-0.98 → 0.60) Mistake. Best move was h6. } (5... h6 6. d4 Ne7 7. g3 d5 8. exd5 fxg3 9. hxg3 c6 10. dxc6)` + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/literate`. + internal var literate: Swift.Bool? + /// URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + /// Example: <https://gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt> + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/query/players`. + internal var players: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + /// - literate: Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// - players: URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + internal init( + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil, + literate: Swift.Bool? = nil, + players: Swift.String? = nil + ) { + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + self.literate = literate + self.players = players + } + } + internal var query: Operations.apiUserCurrentGame.Input.Query + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserCurrentGame.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserCurrentGame.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserCurrentGame.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiUserCurrentGame.Input.Path, + query: Operations.apiUserCurrentGame.Input.Query = .init(), + headers: Operations.apiUserCurrentGame.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserCurrentGame.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/user/{username}/current-game/GET/responses/200/content/application\/json`. + case json(Components.Schemas.GameJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.GameJson { + get throws { + switch self { + case let .json(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/json", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserCurrentGame.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserCurrentGame.Output.Ok.Headers = .init(), + body: Operations.apiUserCurrentGame.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The ongoing (or last) game of a user. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/current-game/get(apiUserCurrentGame)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserCurrentGame.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserCurrentGame.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .json + ] + } + } + } + /// Export games of a user + /// + /// Download all games of any user in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// We recommend streaming the response, for it can be very long. + /// <https://lichess.org/@/german11> for instance has more than 500,000 games. + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// - Authenticated, downloading your own games: 60 games per second + /// + /// + /// - Remark: HTTP `GET /api/games/user/{username}`. + /// - Remark: Generated from `#/paths//api/games/user/{username}/get(apiGamesUser)`. + internal enum apiGamesUser { + internal static let id: Swift.String = "apiGamesUser" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The user name. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: The user name. + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiGamesUser.Input.Path + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Download games played since this timestamp. Defaults to account creation date. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/since`. + internal var since: Swift.Int? + /// Download games played until this timestamp. Defaults to now. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/until`. + internal var until: Swift.Int? + /// How many games to download. Leave empty to download all games. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/max`. + internal var max: Swift.Int? + /// [Filter] Only games played against this opponent + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/vs`. + internal var vs: Swift.String? + /// [Filter] Only rated (`true`) or casual (`false`) games + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/rated`. + internal var rated: Swift.Bool? + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/perfType`. + internal struct perfTypePayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/perfType/value1`. + internal var value1: Components.Schemas.PerfType + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/perfType/value2`. + internal var value2: OpenAPIRuntime.OpenAPIValueContainer + /// Creates a new `perfTypePayload`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Components.Schemas.PerfType, + value2: OpenAPIRuntime.OpenAPIValueContainer + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + value1 = try decoder.decodeFromSingleValueContainer() + value2 = try .init(from: decoder) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeToSingleValueContainer(value1) + } + } + /// [Filter] Only games in these speeds or variants. + /// + /// Multiple perf types can be specified, separated by a comma. + /// + /// Example: blitz,rapid,classical + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/perfType`. + internal var perfType: Operations.apiGamesUser.Input.Query.perfTypePayload? + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/color`. + @frozen internal enum colorPayload: String, Codable, Hashable, Sendable { + case white = "white" + case black = "black" + } + /// [Filter] Only games played as this color. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/color`. + internal var color: Operations.apiGamesUser.Input.Query.colorPayload? + /// [Filter] Only games with or without a computer analysis available + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/analysed`. + internal var analysed: Swift.Bool? + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. The response type must be set to `application/x-ndjson` by the request `Accept` header. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/division`. + internal var division: Swift.Bool? + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/ongoing`. + internal var ongoing: Swift.Bool? + /// Include finished games. Set to `false` to only get ongoing games. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/finished`. + internal var finished: Swift.Bool? + /// Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// Example: `5... g4? { (-0.98 → 0.60) Mistake. Best move was h6. } (5... h6 6. d4 Ne7 7. g3 d5 8. exd5 fxg3 9. hxg3 c6 10. dxc6)` + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/literate`. + internal var literate: Swift.Bool? + /// Include the FEN notation of the last position of the game. + /// The response type must be set to `application/x-ndjson` by the request `Accept` header. + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/lastFen`. + internal var lastFen: Swift.Bool? + /// URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + /// Example: <https://gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt> + /// + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/players`. + internal var players: Swift.String? + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/sort`. + @frozen internal enum sortPayload: String, Codable, Hashable, Sendable { + case dateAsc = "dateAsc" + case dateDesc = "dateDesc" + } + /// Sort order of the games. + /// + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/query/sort`. + internal var sort: Operations.apiGamesUser.Input.Query.sortPayload? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - since: Download games played since this timestamp. Defaults to account creation date. + /// - until: Download games played until this timestamp. Defaults to now. + /// - max: How many games to download. Leave empty to download all games. + /// - vs: [Filter] Only games played against this opponent + /// - rated: [Filter] Only rated (`true`) or casual (`false`) games + /// - perfType: [Filter] Only games in these speeds or variants. + /// - color: [Filter] Only games played as this color. + /// - analysed: [Filter] Only games with or without a computer analysis available + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. The response type must be set to `application/x-ndjson` by the request `Accept` header. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + /// - ongoing: Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// - finished: Include finished games. Set to `false` to only get ongoing games. + /// - literate: Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// - lastFen: Include the FEN notation of the last position of the game. + /// - players: URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + /// - sort: Sort order of the games. + internal init( + since: Swift.Int? = nil, + until: Swift.Int? = nil, + max: Swift.Int? = nil, + vs: Swift.String? = nil, + rated: Swift.Bool? = nil, + perfType: Operations.apiGamesUser.Input.Query.perfTypePayload? = nil, + color: Operations.apiGamesUser.Input.Query.colorPayload? = nil, + analysed: Swift.Bool? = nil, + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil, + ongoing: Swift.Bool? = nil, + finished: Swift.Bool? = nil, + literate: Swift.Bool? = nil, + lastFen: Swift.Bool? = nil, + players: Swift.String? = nil, + sort: Operations.apiGamesUser.Input.Query.sortPayload? = nil + ) { + self.since = since + self.until = until + self.max = max + self.vs = vs + self.rated = rated + self.perfType = perfType + self.color = color + self.analysed = analysed + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + self.ongoing = ongoing + self.finished = finished + self.literate = literate + self.lastFen = lastFen + self.players = players + self.sort = sort + } + } + internal var query: Operations.apiGamesUser.Input.Query + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiGamesUser.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiGamesUser.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiGamesUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiGamesUser.Input.Path, + query: Operations.apiGamesUser.Input.Query = .init(), + headers: Operations.apiGamesUser.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiGamesUser.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/games/user/{username}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-ndjson", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiGamesUser.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiGamesUser.Output.Ok.Headers = .init(), + body: Operations.apiGamesUser.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The games of the user. + /// + /// - Remark: Generated from `#/paths//api/games/user/{username}/get(apiGamesUser)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiGamesUser.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiGamesUser.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .application_x_hyphen_ndjson + ] + } + } + } + /// Export games by IDs + /// + /// Download games by IDs in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// Games are sorted by reverse chronological order (most recent first) + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// 300 IDs can be submitted. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// + /// + /// - Remark: HTTP `POST /api/games/export/_ids`. + /// - Remark: Generated from `#/paths//api/games/export/_ids/post(gamesExportIds)`. + internal enum gamesExportIds { + internal static let id: Swift.String = "gamesExportIds" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query`. + internal struct Query: Sendable, Hashable { + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/division`. + internal var division: Swift.Bool? + /// Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// Example: `5... g4? { (-0.98 → 0.60) Mistake. Best move was h6. } (5... h6 6. d4 Ne7 7. g3 d5 8. exd5 fxg3 9. hxg3 c6 10. dxc6)` + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/literate`. + internal var literate: Swift.Bool? + /// URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + /// Example: <https://gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt> + /// + /// + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/query/players`. + internal var players: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + /// - literate: Insert textual annotations in the PGN about the opening, analysis variations, mistakes, and game termination. + /// - players: URL of a text file containing real names and ratings, to replace Lichess usernames and ratings in the PGN. + internal init( + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil, + literate: Swift.Bool? = nil, + players: Swift.String? = nil + ) { + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + self.literate = literate + self.players = players + } + } + internal var query: Operations.gamesExportIds.Input.Query + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesExportIds.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesExportIds.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesExportIds.Input.Headers + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.gamesExportIds.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + /// - body: + internal init( + query: Operations.gamesExportIds.Input.Query = .init(), + headers: Operations.gamesExportIds.Input.Headers = .init(), + body: Operations.gamesExportIds.Input.Body + ) { + self.query = query + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesExportIds.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/games/export/_ids/POST/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-ndjson", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesExportIds.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesExportIds.Output.Ok.Headers = .init(), + body: Operations.gamesExportIds.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The representation of the games. + /// + /// - Remark: Generated from `#/paths//api/games/export/_ids/post(gamesExportIds)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesExportIds.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesExportIds.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .application_x_hyphen_ndjson + ] + } + } + } + /// Stream games of users + /// + /// Stream the games played between a list of users, in real time. + /// Only games where **both players** are part of the list are included. + /// The stream emits an event each time a game is started or finished. + /// To also get all current ongoing games at the beginning of the stream, use the `withCurrentGames` flag. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of users: 300. + /// The method is `POST` so a longer list of IDs can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/stream/games-by-users`. + /// - Remark: Generated from `#/paths//api/stream/games-by-users/post(gamesByUsers)`. + internal enum gamesByUsers { + internal static let id: Swift.String = "gamesByUsers" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/query`. + internal struct Query: Sendable, Hashable { + /// Include the already started games at the beginning of the stream. + /// + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/query/withCurrentGames`. + internal var withCurrentGames: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - withCurrentGames: Include the already started games at the beginning of the stream. + internal init(withCurrentGames: Swift.Bool? = nil) { + self.withCurrentGames = withCurrentGames + } + } + internal var query: Operations.gamesByUsers.Input.Query + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByUsers.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByUsers.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesByUsers.Input.Headers + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.gamesByUsers.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + /// - body: + internal init( + query: Operations.gamesByUsers.Input.Query = .init(), + headers: Operations.gamesByUsers.Input.Headers = .init(), + body: Operations.gamesByUsers.Input.Body + ) { + self.query = query + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesByUsers.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games-by-users/POST/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesByUsers.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesByUsers.Output.Ok.Headers = .init(), + body: Operations.gamesByUsers.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The stream of the games played between the users. + /// + /// - Remark: Generated from `#/paths//api/stream/games-by-users/post(gamesByUsers)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesByUsers.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesByUsers.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Stream games by IDs + /// + /// Creates a stream of games from an arbitrary streamId, and a list of game IDs. + /// The stream first outputs the games that already exists, then emits an event each time a game is started or finished. + /// Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// Maximum number of games: 500 for anonymous requests, or 1000 for [OAuth2 authenticated](#section/Introduction/Authentication) requests. + /// While the stream is open, it is possible to [add new game IDs to watch](#operation/gamesByIdsAdd). + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/post(gamesByIds)`. + internal enum gamesByIds { + internal static let id: Swift.String = "gamesByIds" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/path/streamId`. + internal var streamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - streamId: + internal init(streamId: Swift.String) { + self.streamId = streamId + } + } + internal var path: Operations.gamesByIds.Input.Path + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByIds.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByIds.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesByIds.Input.Headers + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.gamesByIds.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.gamesByIds.Input.Path, + headers: Operations.gamesByIds.Input.Headers = .init(), + body: Operations.gamesByIds.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesByIds.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/POST/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesByIds.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesByIds.Output.Ok.Headers = .init(), + body: Operations.gamesByIds.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The stream of the games matching the requested IDs. + /// + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/post(gamesByIds)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesByIds.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesByIds.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Add game IDs to stream + /// + /// Add new game IDs for [an existing stream](#operation/gamesByIds) to watch. + /// The stream will immediately outputs the games that already exists, then emit an event each time a game is started or finished. + /// + /// + /// - Remark: HTTP `POST /api/stream/games/{streamId}/add`. + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/add/post(gamesByIdsAdd)`. + internal enum gamesByIdsAdd { + internal static let id: Swift.String = "gamesByIdsAdd" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/path/streamId`. + internal var streamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - streamId: + internal init(streamId: Swift.String) { + self.streamId = streamId + } + } + internal var path: Operations.gamesByIdsAdd.Input.Path + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByIdsAdd.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByIdsAdd.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesByIdsAdd.Input.Headers + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.gamesByIdsAdd.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.gamesByIdsAdd.Input.Path, + headers: Operations.gamesByIdsAdd.Input.Headers = .init(), + body: Operations.gamesByIdsAdd.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesByIdsAdd.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/games/{streamId}/add/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesByIdsAdd.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesByIdsAdd.Output.Ok.Headers = .init(), + body: Operations.gamesByIdsAdd.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game IDs have been added to the stream. + /// + /// - Remark: Generated from `#/paths//api/stream/games/{streamId}/add/post(gamesByIdsAdd)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesByIdsAdd.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesByIdsAdd.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get my ongoing games + /// + /// Get the ongoing games of the current user. + /// Real-time and correspondence games are included. + /// The most urgent games are listed first. + /// + /// + /// - Remark: HTTP `GET /api/account/playing`. + /// - Remark: Generated from `#/paths//api/account/playing/get(apiAccountPlaying)`. + internal enum apiAccountPlaying { + internal static let id: Swift.String = "apiAccountPlaying" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/playing/GET/query`. + internal struct Query: Sendable, Hashable { + /// Max number of games to fetch + /// + /// - Remark: Generated from `#/paths/api/account/playing/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: Max number of games to fetch + internal init(nb: Swift.Int? = nil) { + self.nb = nb + } + } + internal var query: Operations.apiAccountPlaying.Input.Query + /// - Remark: Generated from `#/paths/api/account/playing/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiAccountPlaying.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiAccountPlaying.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiAccountPlaying.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiAccountPlaying.Input.Query = .init(), + headers: Operations.apiAccountPlaying.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/playing/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/playing/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiAccountPlaying.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/account/playing/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/account/playing/GET/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiAccountPlaying.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiAccountPlaying.Output.Ok.Headers = .init(), + body: Operations.apiAccountPlaying.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The ongoing games of the logged in user. + /// + /// - Remark: Generated from `#/paths//api/account/playing/get(apiAccountPlaying)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiAccountPlaying.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiAccountPlaying.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Stream moves of a game + /// + /// Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A description of the game is sent as a first message. + /// Then a message is sent each time a move is played. + /// Finally a description of the game is sent when it finishes, and the stream is closed. + /// Ongoing games are delayed by a few seconds ranging from 3 to 60 depending on the time control, as to prevent cheat bots from using this API. + /// No more than 8 game streams can be opened at the same time from the same IP address. + /// + /// + /// - Remark: HTTP `GET /api/stream/game/{id}`. + /// - Remark: Generated from `#/paths//api/stream/game/{id}/get(streamGame)`. + internal enum streamGame { + internal static let id: Swift.String = "streamGame" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/game/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/game/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.streamGame.Input.Path + /// - Remark: Generated from `#/paths/api/stream/game/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.streamGame.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.streamGame.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.streamGame.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.streamGame.Input.Path, + headers: Operations.streamGame.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/game/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/game/{id}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.streamGame.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.streamGame.Output.Ok.Body) { + self.body = body + } + } + /// The stream of the game moves. + /// + /// - Remark: Generated from `#/paths//api/stream/game/{id}/get(streamGame)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.streamGame.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.streamGame.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Import one game + /// + /// Import a game from PGN. See <https://lichess.org/paste>. + /// Rate limiting: 200 games per hour for OAuth requests, 100 games per hour for anonymous requests. + /// To broadcast ongoing games, consider [pushing to a broadcast instead](#operation/broadcastPush). + /// To analyse a position or a line, just construct an analysis board URL: + /// [https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+](https://lichess.org/analysis/pgn/e4_e5_Nf3_Nc6_Bc4_Bc5_Bxf7+) + /// + /// + /// - Remark: HTTP `POST /api/import`. + /// - Remark: Generated from `#/paths//api/import/post(gameImport)`. + internal enum gameImport { + internal static let id: Swift.String = "gameImport" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/import/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gameImport.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gameImport.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gameImport.Input.Headers + /// - Remark: Generated from `#/paths/api/import/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/import/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The PGN. It can contain only one game. Most standard tags are supported. + /// + /// - Remark: Generated from `#/paths/api/import/POST/requestBody/urlEncodedForm/pgn`. + internal var pgn: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - pgn: The PGN. It can contain only one game. Most standard tags are supported. + internal init(pgn: Swift.String? = nil) { + self.pgn = pgn + } + internal enum CodingKeys: String, CodingKey { + case pgn + } + } + /// - Remark: Generated from `#/paths/api/import/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.gameImport.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.gameImport.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.gameImport.Input.Headers = .init(), + body: Operations.gameImport.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/import/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/import/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gameImport.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/import/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/import/POST/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gameImport.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gameImport.Output.Ok.Headers = .init(), + body: Operations.gameImport.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game was successfully imported. + /// + /// - Remark: Generated from `#/paths//api/import/post(gameImport)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gameImport.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gameImport.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Export your imported games + /// + /// Download all games imported by you. Games are exported in PGN format. + /// + /// - Remark: HTTP `GET /api/games/export/imports`. + /// - Remark: Generated from `#/paths//api/games/export/imports/get(apiImportedGamesUser)`. + internal enum apiImportedGamesUser { + internal static let id: Swift.String = "apiImportedGamesUser" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/imports/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiImportedGamesUser.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiImportedGamesUser.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiImportedGamesUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiImportedGamesUser.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/imports/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/imports/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiImportedGamesUser.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/games/export/imports/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/games/export/imports/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiImportedGamesUser.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiImportedGamesUser.Output.Ok.Headers = .init(), + body: Operations.apiImportedGamesUser.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Imported games in PGN format + /// + /// - Remark: Generated from `#/paths//api/games/export/imports/get(apiImportedGamesUser)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiImportedGamesUser.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiImportedGamesUser.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Get current TV games + /// + /// Get basic info about the best games being played for each speed and variant, + /// but also computer games and bot games. + /// See [lichess.org/tv](https://lichess.org/tv). + /// + /// + /// - Remark: HTTP `GET /api/tv/channels`. + /// - Remark: Generated from `#/paths//api/tv/channels/get(tvChannels)`. + internal enum tvChannels { + internal static let id: Swift.String = "tvChannels" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/channels/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannels.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannels.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tvChannels.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.tvChannels.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/channels/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/channels/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.tvChannels.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tv/channels/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/channels/GET/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tvChannels.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.tvChannels.Output.Ok.Headers = .init(), + body: Operations.tvChannels.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of games being played for each speed and variant. + /// + /// - Remark: Generated from `#/paths//api/tv/channels/get(tvChannels)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tvChannels.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tvChannels.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Stream current TV game + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/feed`. + /// - Remark: Generated from `#/paths//api/tv/feed/get(tvFeed)`. + internal enum tvFeed { + internal static let id: Swift.String = "tvFeed" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/feed/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvFeed.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvFeed.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tvFeed.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.tvFeed.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/feed/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/feed/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tvFeed.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.tvFeed.Output.Ok.Body) { + self.body = body + } + } + /// The stream of the current TV game. + /// + /// - Remark: Generated from `#/paths//api/tv/feed/get(tvFeed)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tvFeed.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tvFeed.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Stream current TV game of a TV channel + /// + /// Stream positions and moves of the current [TV game](https://lichess.org/tv) of a TV channel in [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// A summary of the game is sent as a first message, and when the featured game changes. + /// Try it with `curl https://lichess.org/api/tv/rapid/feed`. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}/feed`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/feed/get(tvChannelFeed)`. + internal enum tvChannelFeed { + internal static let id: Swift.String = "tvChannelFeed" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/feed/GET/path`. + internal struct Path: Sendable, Hashable { + /// The name of the channel in camel case. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/feed/GET/path/channel`. + internal var channel: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - channel: The name of the channel in camel case. + internal init(channel: Swift.String) { + self.channel = channel + } + } + internal var path: Operations.tvChannelFeed.Input.Path + /// - Remark: Generated from `#/paths/api/tv/{channel}/feed/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannelFeed.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannelFeed.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tvChannelFeed.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.tvChannelFeed.Input.Path, + headers: Operations.tvChannelFeed.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/feed/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/feed/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tvChannelFeed.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.tvChannelFeed.Output.Ok.Body) { + self.body = body + } + } + /// The stream of the current TV game of a TV channel. + /// + /// - Remark: Generated from `#/paths//api/tv/{channel}/feed/get(tvChannelFeed)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tvChannelFeed.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tvChannelFeed.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Get best ongoing games of a TV channel + /// + /// Get a list of ongoing games for a given TV channel. Similar to [lichess.org/games](https://lichess.org/games). + /// Available in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format, depending on the request `Accept` header. + /// + /// + /// - Remark: HTTP `GET /api/tv/{channel}`. + /// - Remark: Generated from `#/paths//api/tv/{channel}/get(tvChannelGames)`. + internal enum tvChannelGames { + internal static let id: Swift.String = "tvChannelGames" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The name of the channel in camel case. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/path/channel`. + internal var channel: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - channel: The name of the channel in camel case. + internal init(channel: Swift.String) { + self.channel = channel + } + } + internal var path: Operations.tvChannelGames.Input.Path + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Number of games to fetch. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/nb`. + internal var nb: Swift.Double? + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/query/opening`. + internal var opening: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: Number of games to fetch. + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - opening: Include the opening name. + internal init( + nb: Swift.Double? = nil, + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + opening: Swift.Bool? = nil + ) { + self.nb = nb + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.opening = opening + } + } + internal var query: Operations.tvChannelGames.Input.Query + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannelGames.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tvChannelGames.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tvChannelGames.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.tvChannelGames.Input.Path, + query: Operations.tvChannelGames.Input.Query = .init(), + headers: Operations.tvChannelGames.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/tv/{channel}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-ndjson", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tvChannelGames.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.tvChannelGames.Output.Ok.Body) { + self.body = body + } + } + /// The representation of the games. + /// + /// - Remark: Generated from `#/paths//api/tv/{channel}/get(tvChannelGames)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tvChannelGames.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tvChannelGames.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .application_x_hyphen_ndjson + ] + } + } + } + /// Get current tournaments + /// + /// Get recently finished, ongoing, and upcoming tournaments. + /// This API is used to display the [Lichess tournament schedule](https://lichess.org/tournament). + /// + /// + /// - Remark: HTTP `GET /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/get(apiTournament)`. + internal enum apiTournament { + internal static let id: Swift.String = "apiTournament" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournament.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournament.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournament.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiTournament.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournament.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/GET/responses/200/content/application\/json`. + case json(Components.Schemas.ArenaTournaments) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ArenaTournaments { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournament.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournament.Output.Ok.Headers = .init(), + body: Operations.apiTournament.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of current tournaments. + /// + /// - Remark: Generated from `#/paths//api/tournament/get(apiTournament)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournament.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournament.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create a new Arena tournament + /// + /// Create a public or private Arena tournament. + /// This endpoint mirrors the form on <https://lichess.org/tournament/new>. + /// You can create up to 12 public tournaments per day, or 24 private tournaments. + /// A team battle can be created by specifying the `teamBattleByTeam` argument. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament`. + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)`. + internal enum apiTournamentPost { + internal static let id: Swift.String = "apiTournamentPost" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentPost.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentPost.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentPost.Input.Headers + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament name. Leave empty to get a random Grandmaster name + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String? + /// Clock initial time in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/clockTime`. + internal var clockTime: Swift.Double + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/clockIncrement`. + @frozen internal enum clockIncrementPayload: Int, Codable, Hashable, Sendable { + case _0 = 0 + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _4 = 4 + case _5 = 5 + case _6 = 6 + case _7 = 7 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _25 = 25 + case _30 = 30 + case _40 = 40 + case _50 = 50 + case _60 = 60 + } + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/clockIncrement`. + internal var clockIncrement: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.clockIncrementPayload + /// How long the tournament lasts, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/minutes`. + @frozen internal enum minutesPayload: Int, Codable, Hashable, Sendable { + case _20 = 20 + case _25 = 25 + case _30 = 30 + case _35 = 35 + case _40 = 40 + case _45 = 45 + case _50 = 50 + case _55 = 55 + case _60 = 60 + case _70 = 70 + case _80 = 80 + case _90 = 90 + case _100 = 100 + case _110 = 110 + case _120 = 120 + case _150 = 150 + case _180 = 180 + case _210 = 210 + case _240 = 240 + case _270 = 270 + case _300 = 300 + case _330 = 330 + case _360 = 360 + case _420 = 420 + case _480 = 480 + case _540 = 540 + case _600 = 600 + case _720 = 720 + } + /// How long the tournament lasts, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/minutes`. + internal var minutes: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.minutesPayload + /// How long to wait before starting the tournament, from now, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/waitMinutes`. + @frozen internal enum waitMinutesPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _30 = 30 + case _45 = 45 + case _60 = 60 + } + /// How long to wait before starting the tournament, from now, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/waitMinutes`. + internal var waitMinutes: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.waitMinutesPayload? + /// Timestamp (in milliseconds) to start the tournament at a given date and time. Overrides the `waitMinutes` setting + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/startDate`. + internal var startDate: Swift.Int? + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// Games are rated and impact players ratings + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/position`. + internal var position: Components.Schemas.FromPositionFEN? + /// Whether the players can use berserk. Only allowed if clockIncrement <= clockTime * 2 + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/berserkable`. + internal var berserkable: Swift.Bool? + /// After 2 wins, consecutive wins grant 4 points instead of 2. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/streakable`. + internal var streakable: Swift.Bool? + /// Whether the players can discuss in a chat + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/hasChat`. + internal var hasChat: Swift.Bool? + /// Anything you want to tell players about the tournament + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/description`. + internal var description: Swift.String? + /// Make the tournament private, and restrict access with a password. + /// You can also [generate user-specific entry codes](https://github.com/lichess-org/api/tree/master/example/tournament-entry-code) + /// based on this password. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Set the ID of a team you lead to create a team battle. + /// The other teams can be added using the [team battle edit endpoint](#operation/apiTournamentTeamBattlePost). + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/teamBattleByTeam`. + internal var teamBattleByTeam: Swift.String? + /// Restrict entry to members of a team. + /// The teamId is the last part of a team URL, e.g. `https://lichess.org/team/coders` has teamId = `coders`. + /// Leave empty to let everyone join the tournament. + /// Do not use this to create team battles, use `teamBattleByTeam` instead. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.teamMember.teamId`. + internal var conditions_period_teamMember_period_teamId: Swift.String? + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + @frozen internal enum conditions_period_minRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _1000 = 1000 + case _1100 = 1100 + case _1200 = 1200 + case _1300 = 1300 + case _1400 = 1400 + case _1500 = 1500 + case _1600 = 1600 + case _1700 = 1700 + case _1800 = 1800 + case _1900 = 1900 + case _2000 = 2000 + case _2100 = 2100 + case _2200 = 2200 + case _2300 = 2300 + case _2400 = 2400 + case _2500 = 2500 + case _2600 = 2600 + } + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + internal var conditions_period_minRating_period_rating: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + @frozen internal enum conditions_period_maxRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _2200 = 2200 + case _2100 = 2100 + case _2000 = 2000 + case _1900 = 1900 + case _1800 = 1800 + case _1700 = 1700 + case _1600 = 1600 + case _1500 = 1500 + case _1400 = 1400 + case _1300 = 1300 + case _1200 = 1200 + case _1100 = 1100 + case _1000 = 1000 + case _900 = 900 + case _800 = 800 + } + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + internal var conditions_period_maxRating_period_rating: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + @frozen internal enum conditions_period_nbRatedGame_period_nbPayload: Int, Codable, Hashable, Sendable { + case _0 = 0 + case _5 = 5 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _30 = 30 + case _40 = 40 + case _50 = 50 + case _75 = 75 + case _100 = 100 + case _150 = 150 + case _200 = 200 + } + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + internal var conditions_period_nbRatedGame_period_nb: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_nbRatedGame_period_nbPayload? + /// Predefined list of usernames that are allowed to join, separated by commas. + /// If this list is non-empty, then usernames absent from this list will be forbidden to join. + /// Adding `%titled` to the list additionally allows any titled player to join. + /// Example: `thibault,german11,%titled` + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/urlEncodedForm/conditions.allowList`. + internal var conditions_period_allowList: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: The tournament name. Leave empty to get a random Grandmaster name + /// - clockTime: Clock initial time in minutes + /// - clockIncrement: Clock increment in seconds + /// - minutes: How long the tournament lasts, in minutes + /// - waitMinutes: How long to wait before starting the tournament, from now, in minutes + /// - startDate: Timestamp (in milliseconds) to start the tournament at a given date and time. Overrides the `waitMinutes` setting + /// - variant: + /// - rated: Games are rated and impact players ratings + /// - position: + /// - berserkable: Whether the players can use berserk. Only allowed if clockIncrement <= clockTime * 2 + /// - streakable: After 2 wins, consecutive wins grant 4 points instead of 2. + /// - hasChat: Whether the players can discuss in a chat + /// - description: Anything you want to tell players about the tournament + /// - password: Make the tournament private, and restrict access with a password. + /// - teamBattleByTeam: Set the ID of a team you lead to create a team battle. + /// - conditions_period_teamMember_period_teamId: Restrict entry to members of a team. + /// - conditions_period_minRating_period_rating: Minimum rating to join. Leave empty to let everyone join the tournament. + /// - conditions_period_maxRating_period_rating: Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// - conditions_period_nbRatedGame_period_nb: Minimum number of rated games required to join. + /// - conditions_period_allowList: Predefined list of usernames that are allowed to join, separated by commas. + internal init( + name: Swift.String? = nil, + clockTime: Swift.Double, + clockIncrement: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.clockIncrementPayload, + minutes: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.minutesPayload, + waitMinutes: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.waitMinutesPayload? = nil, + startDate: Swift.Int? = nil, + variant: Components.Schemas.VariantKey? = nil, + rated: Swift.Bool? = nil, + position: Components.Schemas.FromPositionFEN? = nil, + berserkable: Swift.Bool? = nil, + streakable: Swift.Bool? = nil, + hasChat: Swift.Bool? = nil, + description: Swift.String? = nil, + password: Swift.String? = nil, + teamBattleByTeam: Swift.String? = nil, + conditions_period_teamMember_period_teamId: Swift.String? = nil, + conditions_period_minRating_period_rating: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? = nil, + conditions_period_maxRating_period_rating: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? = nil, + conditions_period_nbRatedGame_period_nb: Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload.conditions_period_nbRatedGame_period_nbPayload? = nil, + conditions_period_allowList: Swift.String? = nil + ) { + self.name = name + self.clockTime = clockTime + self.clockIncrement = clockIncrement + self.minutes = minutes + self.waitMinutes = waitMinutes + self.startDate = startDate + self.variant = variant + self.rated = rated + self.position = position + self.berserkable = berserkable + self.streakable = streakable + self.hasChat = hasChat + self.description = description + self.password = password + self.teamBattleByTeam = teamBattleByTeam + self.conditions_period_teamMember_period_teamId = conditions_period_teamMember_period_teamId + self.conditions_period_minRating_period_rating = conditions_period_minRating_period_rating + self.conditions_period_maxRating_period_rating = conditions_period_maxRating_period_rating + self.conditions_period_nbRatedGame_period_nb = conditions_period_nbRatedGame_period_nb + self.conditions_period_allowList = conditions_period_allowList + } + internal enum CodingKeys: String, CodingKey { + case name + case clockTime + case clockIncrement + case minutes + case waitMinutes + case startDate + case variant + case rated + case position + case berserkable + case streakable + case hasChat + case description + case password + case teamBattleByTeam + case conditions_period_teamMember_period_teamId = "conditions.teamMember.teamId" + case conditions_period_minRating_period_rating = "conditions.minRating.rating" + case conditions_period_maxRating_period_rating = "conditions.maxRating.rating" + case conditions_period_nbRatedGame_period_nb = "conditions.nbRatedGame.nb" + case conditions_period_allowList = "conditions.allowList" + } + } + /// - Remark: Generated from `#/paths/api/tournament/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiTournamentPost.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiTournamentPost.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiTournamentPost.Input.Headers = .init(), + body: Operations.apiTournamentPost.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentPost.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/200/content/application\/json`. + case json(Components.Schemas.ArenaTournamentVariantIsKey) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ArenaTournamentVariantIsKey { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentPost.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentPost.Output.Ok.Headers = .init(), + body: Operations.apiTournamentPost.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The Arena tournament has been successfully created. + /// + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentPost.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentPost.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentPost.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentPost.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the Arena tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/post(apiTournamentPost)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentPost.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentPost.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get info about an Arena tournament + /// + /// Get detailed info about recently finished, current, or upcoming tournament's duels, player standings, and other info. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/get(tournament)`. + internal enum tournament { + internal static let id: Swift.String = "tournament" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.tournament.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Specify which page of player standings to view. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/query/page`. + internal var page: Swift.Double? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - page: Specify which page of player standings to view. + internal init(page: Swift.Double? = nil) { + self.page = page + } + } + internal var query: Operations.tournament.Input.Query + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tournament.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tournament.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tournament.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.tournament.Input.Path, + query: Operations.tournament.Input.Query = .init(), + headers: Operations.tournament.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.tournament.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.ArenaTournamentVariantIsKey) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ArenaTournamentVariantIsKey { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tournament.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.tournament.Output.Ok.Headers = .init(), + body: Operations.tournament.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The information of the Arena tournament. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/get(tournament)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tournament.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tournament.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update an Arena tournament + /// + /// Update an Arena tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Can be used to update a team battle. + /// Additional restrictions: + /// - clockTime + clockIncrement > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// - Clock time in comparison to tournament length must be reasonable: 3 <= (minutes * 60) / (96 * clockTime + 48 * clockIncrement + 15) <= 150 + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)`. + internal enum apiTournamentUpdate { + internal static let id: Swift.String = "apiTournamentUpdate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiTournamentUpdate.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentUpdate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentUpdate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentUpdate.Input.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament name. Leave empty to get a random Grandmaster name + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String? + /// Clock initial time in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/clockTime`. + internal var clockTime: Swift.Double + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/clockIncrement`. + @frozen internal enum clockIncrementPayload: Int, Codable, Hashable, Sendable { + case _0 = 0 + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _4 = 4 + case _5 = 5 + case _6 = 6 + case _7 = 7 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _25 = 25 + case _30 = 30 + case _40 = 40 + case _50 = 50 + case _60 = 60 + } + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/clockIncrement`. + internal var clockIncrement: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.clockIncrementPayload + /// How long the tournament lasts, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/minutes`. + @frozen internal enum minutesPayload: Int, Codable, Hashable, Sendable { + case _20 = 20 + case _25 = 25 + case _30 = 30 + case _35 = 35 + case _40 = 40 + case _45 = 45 + case _50 = 50 + case _55 = 55 + case _60 = 60 + case _70 = 70 + case _80 = 80 + case _90 = 90 + case _100 = 100 + case _110 = 110 + case _120 = 120 + case _150 = 150 + case _180 = 180 + case _210 = 210 + case _240 = 240 + case _270 = 270 + case _300 = 300 + case _330 = 330 + case _360 = 360 + case _420 = 420 + case _480 = 480 + case _540 = 540 + case _600 = 600 + case _720 = 720 + } + /// How long the tournament lasts, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/minutes`. + internal var minutes: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.minutesPayload + /// How long to wait before starting the tournament, from now, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/waitMinutes`. + @frozen internal enum waitMinutesPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _30 = 30 + case _45 = 45 + case _60 = 60 + } + /// How long to wait before starting the tournament, from now, in minutes + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/waitMinutes`. + internal var waitMinutes: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.waitMinutesPayload? + /// Timestamp (in milliseconds) to start the tournament at a given date and time. Overrides the `waitMinutes` setting + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/startDate`. + internal var startDate: Swift.Int? + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// Games are rated and impact players ratings + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/position`. + internal var position: Components.Schemas.FromPositionFEN? + /// Whether the players can use berserk. Only allowed if clockIncrement <= clockTime * 2 + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/berserkable`. + internal var berserkable: Swift.Bool? + /// After 2 wins, consecutive wins grant 4 points instead of 2. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/streakable`. + internal var streakable: Swift.Bool? + /// Whether the players can discuss in a chat + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/hasChat`. + internal var hasChat: Swift.Bool? + /// Anything you want to tell players about the tournament + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/description`. + internal var description: Swift.String? + /// Make the tournament private, and restrict access with a password + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + @frozen internal enum conditions_period_minRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _1000 = 1000 + case _1100 = 1100 + case _1200 = 1200 + case _1300 = 1300 + case _1400 = 1400 + case _1500 = 1500 + case _1600 = 1600 + case _1700 = 1700 + case _1800 = 1800 + case _1900 = 1900 + case _2000 = 2000 + case _2100 = 2100 + case _2200 = 2200 + case _2300 = 2300 + case _2400 = 2400 + case _2500 = 2500 + case _2600 = 2600 + } + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + internal var conditions_period_minRating_period_rating: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + @frozen internal enum conditions_period_maxRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _2200 = 2200 + case _2100 = 2100 + case _2000 = 2000 + case _1900 = 1900 + case _1800 = 1800 + case _1700 = 1700 + case _1600 = 1600 + case _1500 = 1500 + case _1400 = 1400 + case _1300 = 1300 + case _1200 = 1200 + case _1100 = 1100 + case _1000 = 1000 + case _900 = 900 + case _800 = 800 + } + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + internal var conditions_period_maxRating_period_rating: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + @frozen internal enum conditions_period_nbRatedGame_period_nbPayload: Int, Codable, Hashable, Sendable { + case _0 = 0 + case _5 = 5 + case _10 = 10 + case _15 = 15 + case _20 = 20 + case _30 = 30 + case _40 = 40 + case _50 = 50 + case _75 = 75 + case _100 = 100 + case _150 = 150 + case _200 = 200 + } + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + internal var conditions_period_nbRatedGame_period_nb: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_nbRatedGame_period_nbPayload? + /// Predefined list of usernames that are allowed to join, separated by commas. + /// If this list is non-empty, then usernames absent from this list will be forbidden to join. + /// Adding `%titled` to the list additionally allows any titled player to join. + /// Example: `thibault,german11,%titled` + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/urlEncodedForm/conditions.allowList`. + internal var conditions_period_allowList: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: The tournament name. Leave empty to get a random Grandmaster name + /// - clockTime: Clock initial time in minutes + /// - clockIncrement: Clock increment in seconds + /// - minutes: How long the tournament lasts, in minutes + /// - waitMinutes: How long to wait before starting the tournament, from now, in minutes + /// - startDate: Timestamp (in milliseconds) to start the tournament at a given date and time. Overrides the `waitMinutes` setting + /// - variant: + /// - rated: Games are rated and impact players ratings + /// - position: + /// - berserkable: Whether the players can use berserk. Only allowed if clockIncrement <= clockTime * 2 + /// - streakable: After 2 wins, consecutive wins grant 4 points instead of 2. + /// - hasChat: Whether the players can discuss in a chat + /// - description: Anything you want to tell players about the tournament + /// - password: Make the tournament private, and restrict access with a password + /// - conditions_period_minRating_period_rating: Minimum rating to join. Leave empty to let everyone join the tournament. + /// - conditions_period_maxRating_period_rating: Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// - conditions_period_nbRatedGame_period_nb: Minimum number of rated games required to join. + /// - conditions_period_allowList: Predefined list of usernames that are allowed to join, separated by commas. + internal init( + name: Swift.String? = nil, + clockTime: Swift.Double, + clockIncrement: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.clockIncrementPayload, + minutes: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.minutesPayload, + waitMinutes: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.waitMinutesPayload? = nil, + startDate: Swift.Int? = nil, + variant: Components.Schemas.VariantKey? = nil, + rated: Swift.Bool? = nil, + position: Components.Schemas.FromPositionFEN? = nil, + berserkable: Swift.Bool? = nil, + streakable: Swift.Bool? = nil, + hasChat: Swift.Bool? = nil, + description: Swift.String? = nil, + password: Swift.String? = nil, + conditions_period_minRating_period_rating: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? = nil, + conditions_period_maxRating_period_rating: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? = nil, + conditions_period_nbRatedGame_period_nb: Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload.conditions_period_nbRatedGame_period_nbPayload? = nil, + conditions_period_allowList: Swift.String? = nil + ) { + self.name = name + self.clockTime = clockTime + self.clockIncrement = clockIncrement + self.minutes = minutes + self.waitMinutes = waitMinutes + self.startDate = startDate + self.variant = variant + self.rated = rated + self.position = position + self.berserkable = berserkable + self.streakable = streakable + self.hasChat = hasChat + self.description = description + self.password = password + self.conditions_period_minRating_period_rating = conditions_period_minRating_period_rating + self.conditions_period_maxRating_period_rating = conditions_period_maxRating_period_rating + self.conditions_period_nbRatedGame_period_nb = conditions_period_nbRatedGame_period_nb + self.conditions_period_allowList = conditions_period_allowList + } + internal enum CodingKeys: String, CodingKey { + case name + case clockTime + case clockIncrement + case minutes + case waitMinutes + case startDate + case variant + case rated + case position + case berserkable + case streakable + case hasChat + case description + case password + case conditions_period_minRating_period_rating = "conditions.minRating.rating" + case conditions_period_maxRating_period_rating = "conditions.maxRating.rating" + case conditions_period_nbRatedGame_period_nb = "conditions.nbRatedGame.nb" + case conditions_period_allowList = "conditions.allowList" + } + } + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiTournamentUpdate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiTournamentUpdate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiTournamentUpdate.Input.Path, + headers: Operations.apiTournamentUpdate.Input.Headers = .init(), + body: Operations.apiTournamentUpdate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentUpdate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.ArenaTournamentVariantIsKey) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ArenaTournamentVariantIsKey { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentUpdate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentUpdate.Output.Ok.Headers = .init(), + body: Operations.apiTournamentUpdate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The Arena tournament was successfully updated. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentUpdate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentUpdate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentUpdate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentUpdate.Output.BadRequest.Body) { + self.body = body + } + } + /// The update of the Arena tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/post(apiTournamentUpdate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentUpdate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentUpdate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Join an Arena tournament + /// + /// Join an Arena tournament, possibly with a password and/or a team. + /// Also unpauses if you had previously [paused](#operation/apiTournamentWithdraw) the tournament. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/join`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)`. + internal enum apiTournamentJoin { + internal static let id: Swift.String = "apiTournamentJoin" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiTournamentJoin.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentJoin.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentJoin.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentJoin.Input.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament password, if one is required. + /// Can also be a [user-specific entry code](https://github.com/lichess-org/api/tree/master/example/tournament-entry-code) + /// generated and shared by the organizer. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// The team to join the tournament with, for team battle tournaments + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody/urlEncodedForm/team`. + internal var team: Swift.String? + /// If the tournament is started, attempt to pair the user, + /// even if they are not connected to the tournament page. + /// This expires after one minute, to avoid pairing a user who is long gone. + /// You may call "join" again to extend the waiting. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody/urlEncodedForm/pairMeAsap`. + internal var pairMeAsap: Swift.Bool? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - password: The tournament password, if one is required. + /// - team: The team to join the tournament with, for team battle tournaments + /// - pairMeAsap: If the tournament is started, attempt to pair the user, + internal init( + password: Swift.String? = nil, + team: Swift.String? = nil, + pairMeAsap: Swift.Bool? = nil + ) { + self.password = password + self.team = team + self.pairMeAsap = pairMeAsap + } + internal enum CodingKeys: String, CodingKey { + case password + case team + case pairMeAsap + } + } + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiTournamentJoin.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiTournamentJoin.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiTournamentJoin.Input.Path, + headers: Operations.apiTournamentJoin.Input.Headers = .init(), + body: Operations.apiTournamentJoin.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentJoin.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentJoin.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentJoin.Output.Ok.Headers = .init(), + body: Operations.apiTournamentJoin.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tournament was successfully joined. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentJoin.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentJoin.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/join/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentJoin.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentJoin.Output.BadRequest.Body) { + self.body = body + } + } + /// Joining the tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/join/post(apiTournamentJoin)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentJoin.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentJoin.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Pause or leave an Arena tournament + /// + /// Leave a future Arena tournament, or take a break on an ongoing Arena tournament. + /// It's possible to join again later. Points and streaks are preserved. + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)`. + internal enum apiTournamentWithdraw { + internal static let id: Swift.String = "apiTournamentWithdraw" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiTournamentWithdraw.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentWithdraw.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentWithdraw.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentWithdraw.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiTournamentWithdraw.Input.Path, + headers: Operations.apiTournamentWithdraw.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentWithdraw.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentWithdraw.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentWithdraw.Output.Ok.Headers = .init(), + body: Operations.apiTournamentWithdraw.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tournament was successfully paused or left. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentWithdraw.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentWithdraw.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/withdraw/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentWithdraw.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentWithdraw.Output.BadRequest.Body) { + self.body = body + } + } + /// Pausing/leaving the tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/withdraw/post(apiTournamentWithdraw)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentWithdraw.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentWithdraw.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Terminate an Arena tournament + /// + /// Terminate an Arena tournament + /// + /// + /// - Remark: HTTP `POST /api/tournament/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)`. + internal enum apiTournamentTerminate { + internal static let id: Swift.String = "apiTournamentTerminate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiTournamentTerminate.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentTerminate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentTerminate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentTerminate.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiTournamentTerminate.Input.Path, + headers: Operations.apiTournamentTerminate.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentTerminate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentTerminate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentTerminate.Output.Ok.Headers = .init(), + body: Operations.apiTournamentTerminate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tournament was successfully terminated. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentTerminate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentTerminate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/terminate/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentTerminate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentTerminate.Output.BadRequest.Body) { + self.body = body + } + } + /// Terminating the tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/terminate/post(apiTournamentTerminate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentTerminate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentTerminate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update a team battle + /// + /// Set the teams and number of leaders of a team battle. + /// To update the other attributes of a team battle, use the [tournament update endpoint](#operation/apiTournamentUpdate). + /// + /// + /// - Remark: HTTP `POST /api/tournament/team-battle/{id}`. + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)`. + internal enum apiTournamentTeamBattlePost { + internal static let id: Swift.String = "apiTournamentTeamBattlePost" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID (8 characters).. + /// + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID (8 characters).. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiTournamentTeamBattlePost.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentTeamBattlePost.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTournamentTeamBattlePost.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTournamentTeamBattlePost.Input.Headers + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// All team IDs of the team battle, separated by commas. + /// Make sure to always send the full list. + /// Teams that are not in the list will be removed from the team battle. + /// Example: `coders,zhigalko_sergei-fan-club,hhSwTKZv` + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/requestBody/urlEncodedForm/teams`. + internal var teams: Swift.String + /// Number team leaders per team. + /// + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/requestBody/urlEncodedForm/nbLeaders`. + internal var nbLeaders: Swift.Int + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - teams: All team IDs of the team battle, separated by commas. + /// - nbLeaders: Number team leaders per team. + internal init( + teams: Swift.String, + nbLeaders: Swift.Int + ) { + self.teams = teams + self.nbLeaders = nbLeaders + } + internal enum CodingKeys: String, CodingKey { + case teams + case nbLeaders + } + } + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiTournamentTeamBattlePost.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiTournamentTeamBattlePost.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiTournamentTeamBattlePost.Input.Path, + headers: Operations.apiTournamentTeamBattlePost.Input.Headers = .init(), + body: Operations.apiTournamentTeamBattlePost.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTournamentTeamBattlePost.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.ArenaTournamentVariantIsKey) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ArenaTournamentVariantIsKey { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentTeamBattlePost.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTournamentTeamBattlePost.Output.Ok.Headers = .init(), + body: Operations.apiTournamentTeamBattlePost.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The team battle tournament was successfully updated. + /// + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTournamentTeamBattlePost.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTournamentTeamBattlePost.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/team-battle/{id}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTournamentTeamBattlePost.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiTournamentTeamBattlePost.Output.BadRequest.Body) { + self.body = body + } + } + /// The update of the team battle tournament failed. + /// + /// - Remark: Generated from `#/paths//api/tournament/team-battle/{id}/post(apiTournamentTeamBattlePost)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiTournamentTeamBattlePost.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiTournamentTeamBattlePost.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Export games of an Arena tournament + /// + /// Download games of a tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (most recent first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/games`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/games/get(gamesByTournament)`. + internal enum gamesByTournament { + internal static let id: Swift.String = "gamesByTournament" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.gamesByTournament.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query`. + internal struct Query: Sendable, Hashable { + /// Only games of a particular player. Leave empty to fetch games of all players. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/player`. + internal var player: Swift.String? + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/query/division`. + internal var division: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - player: Only games of a particular player. Leave empty to fetch games of all players. + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + internal init( + player: Swift.String? = nil, + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil + ) { + self.player = player + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + } + } + internal var query: Operations.gamesByTournament.Input.Query + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByTournament.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesByTournament.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesByTournament.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.gamesByTournament.Input.Path, + query: Operations.gamesByTournament.Input.Query = .init(), + headers: Operations.gamesByTournament.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesByTournament.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/tournament/{id}/games/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-ndjson", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesByTournament.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesByTournament.Output.Ok.Headers = .init(), + body: Operations.gamesByTournament.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of games of an Arena tournament. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/games/get(gamesByTournament)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesByTournament.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesByTournament.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .application_x_hyphen_ndjson + ] + } + } + } + /// Get results of an Arena tournament + /// + /// Players of an Arena tournament, with their score and performance, sorted by rank (best first). + /// **Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON)**, i.e. one JSON object per line. + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/results`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/results/get(resultsByTournament)`. + internal enum resultsByTournament { + internal static let id: Swift.String = "resultsByTournament" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.resultsByTournament.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/query`. + internal struct Query: Sendable, Hashable { + /// Max number of players to fetch + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/query/nb`. + internal var nb: Swift.Int? + /// Add a `sheet` field to the player document. + /// It's an expensive server computation that slows down the stream. + /// + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/query/sheet`. + internal var sheet: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: Max number of players to fetch + /// - sheet: Add a `sheet` field to the player document. + internal init( + nb: Swift.Int? = nil, + sheet: Swift.Bool? = nil + ) { + self.nb = nb + self.sheet = sheet + } + } + internal var query: Operations.resultsByTournament.Input.Query + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.resultsByTournament.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.resultsByTournament.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.resultsByTournament.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.resultsByTournament.Input.Path, + query: Operations.resultsByTournament.Input.Query = .init(), + headers: Operations.resultsByTournament.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.resultsByTournament.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/results/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.resultsByTournament.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.resultsByTournament.Output.Ok.Headers = .init(), + body: Operations.resultsByTournament.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The results of the Arena tournament. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/results/get(resultsByTournament)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.resultsByTournament.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.resultsByTournament.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Get team standing of a team battle + /// + /// Teams of a team battle tournament, with top players, sorted by rank (best first). + /// + /// + /// - Remark: HTTP `GET /api/tournament/{id}/teams`. + /// - Remark: Generated from `#/paths//api/tournament/{id}/teams/get(teamsByTournament)`. + internal enum teamsByTournament { + internal static let id: Swift.String = "teamsByTournament" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.teamsByTournament.Input.Path + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamsByTournament.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamsByTournament.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamsByTournament.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamsByTournament.Input.Path, + headers: Operations.teamsByTournament.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamsByTournament.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/tournament/{id}/teams/GET/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamsByTournament.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamsByTournament.Output.Ok.Headers = .init(), + body: Operations.teamsByTournament.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of teams of a team battle tournament, with their respective top players. + /// + /// - Remark: Generated from `#/paths//api/tournament/{id}/teams/get(teamsByTournament)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamsByTournament.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamsByTournament.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get tournaments created by a user + /// + /// Get all tournaments created by a given user. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/tournament/created`. + /// - Remark: Generated from `#/paths//api/user/{username}/tournament/created/get(apiUserNameTournamentCreated)`. + internal enum apiUserNameTournamentCreated { + internal static let id: Swift.String = "apiUserNameTournamentCreated" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/path`. + internal struct Path: Sendable, Hashable { + /// The user whose created tournaments to fetch + /// + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: The user whose created tournaments to fetch + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.apiUserNameTournamentCreated.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/query`. + internal struct Query: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/query/status`. + @frozen internal enum statusPayload: Int, Codable, Hashable, Sendable { + case _10 = 10 + case _20 = 20 + case _30 = 30 + } + /// Include tournaments in the given status: "Created" (10), "Started" (20), "Finished" (30) + /// You can add this parameter more than once to include tournaments in different statuses. + /// Example: `?status=10&status=20` + /// + /// + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/query/status`. + internal var status: Operations.apiUserNameTournamentCreated.Input.Query.statusPayload? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - status: Include tournaments in the given status: "Created" (10), "Started" (20), "Finished" (30) + internal init(status: Operations.apiUserNameTournamentCreated.Input.Query.statusPayload? = nil) { + self.status = status + } + } + internal var query: Operations.apiUserNameTournamentCreated.Input.Query + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserNameTournamentCreated.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserNameTournamentCreated.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserNameTournamentCreated.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiUserNameTournamentCreated.Input.Path, + query: Operations.apiUserNameTournamentCreated.Input.Query = .init(), + headers: Operations.apiUserNameTournamentCreated.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserNameTournamentCreated.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/tournament/created/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserNameTournamentCreated.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserNameTournamentCreated.Output.Ok.Headers = .init(), + body: Operations.apiUserNameTournamentCreated.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of tournaments created by the user. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/tournament/created/get(apiUserNameTournamentCreated)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserNameTournamentCreated.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserNameTournamentCreated.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Create a new Swiss tournament + /// + /// Create a Swiss tournament for your team. + /// This endpoint mirrors the Swiss tournament form from your team pagee. + /// You can create up to 12 tournaments per day. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/new/{teamId}`. + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)`. + internal enum apiSwissNew { + internal static let id: Swift.String = "apiSwissNew" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/path`. + internal struct Path: Sendable, Hashable { + /// ID of the team + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: ID of the team + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.apiSwissNew.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissNew.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissNew.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissNew.Input.Headers + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament name. Leave empty to get a random Grandmaster name + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String? + /// Clock initial time in seconds + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int + /// Maximum number of rounds to play + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/nbRounds`. + internal var nbRounds: Swift.Int + /// Timestamp in milliseconds to start the tournament at a given date and time. By default, it starts 10 minutes after creation. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/startsAt`. + internal var startsAt: Swift.Int? + /// How long to wait between each round, in seconds. + /// Set to 99999999 to manually schedule each round from the tournament UI. + /// If empty or -1, a sensible value is picked automatically. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/roundInterval`. + @frozen internal enum roundIntervalPayload: Int, Codable, Hashable, Sendable { + case _n1 = -1 + case _5 = 5 + case _10 = 10 + case _20 = 20 + case _30 = 30 + case _45 = 45 + case _60 = 60 + case _120 = 120 + case _180 = 180 + case _300 = 300 + case _600 = 600 + case _900 = 900 + case _1200 = 1200 + case _1800 = 1800 + case _2700 = 2700 + case _3600 = 3600 + case _86400 = 86400 + case _172800 = 172800 + case _604800 = 604800 + case _99999999 = 99999999 + } + /// How long to wait between each round, in seconds. + /// Set to 99999999 to manually schedule each round from the tournament UI. + /// If empty or -1, a sensible value is picked automatically. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/roundInterval`. + internal var roundInterval: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.roundIntervalPayload? + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/position`. + internal var position: Components.Schemas.FromPositionFEN? + /// Anything you want to tell players about the tournament + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/description`. + internal var description: Swift.String? + /// Games are rated and impact players ratings + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// Make the tournament private and restrict access with a password. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Usernames of players that must not play together. + /// Two usernames per line, separated by a space. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/forbiddenPairings`. + internal var forbiddenPairings: Swift.String? + /// Manual pairings for the next round. + /// Two usernames per line, separated by a space. Example: + /// ``` + /// PlayerA PlayerB + /// PlayerC PlayerD + /// ``` + /// To give a bye (1 point) to a player instead of a pairing, add a line like so: + /// ``` + /// PlayerE 1 + /// ``` + /// Missing players will be considered absent and get zero points. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/manualPairings`. + internal var manualPairings: Swift.String? + /// Who can read and write in the chat. + /// - 0 = No-one + /// - 10 = Only team leaders + /// - 20 = Only team members + /// - 30 = All Lichess players + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/chatFor`. + internal var chatFor: Swift.Double? + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + @frozen internal enum conditions_period_minRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _1000 = 1000 + case _1100 = 1100 + case _1200 = 1200 + case _1300 = 1300 + case _1400 = 1400 + case _1500 = 1500 + case _1600 = 1600 + case _1700 = 1700 + case _1800 = 1800 + case _1900 = 1900 + case _2000 = 2000 + case _2100 = 2100 + case _2200 = 2200 + case _2300 = 2300 + case _2400 = 2400 + case _2500 = 2500 + case _2600 = 2600 + } + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + internal var conditions_period_minRating_period_rating: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + @frozen internal enum conditions_period_maxRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _2200 = 2200 + case _2100 = 2100 + case _2000 = 2000 + case _1900 = 1900 + case _1800 = 1800 + case _1700 = 1700 + case _1600 = 1600 + case _1500 = 1500 + case _1400 = 1400 + case _1300 = 1300 + case _1200 = 1200 + case _1100 = 1100 + case _1000 = 1000 + case _900 = 900 + case _800 = 800 + } + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + internal var conditions_period_maxRating_period_rating: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + internal var conditions_period_nbRatedGame_period_nb: Swift.Int? + /// Only let players join if they have played their last swiss game. + /// If they failed to show up in a recent swiss event, they won't be able to enter yours. + /// This results in a better swiss experience for the players who actually show up. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.playYourGames`. + internal var conditions_period_playYourGames: Swift.Bool? + /// Predefined list of usernames that are allowed to join, separated by commas. + /// If this list is non-empty, then usernames absent from this list will be forbidden to join. + /// Adding `%titled` to the list additionally allows any titled player to join. + /// Example: `thibault,german11,%titled` + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/urlEncodedForm/conditions.allowList`. + internal var conditions_period_allowList: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: The tournament name. Leave empty to get a random Grandmaster name + /// - clock_period_limit: Clock initial time in seconds + /// - clock_period_increment: Clock increment in seconds + /// - nbRounds: Maximum number of rounds to play + /// - startsAt: Timestamp in milliseconds to start the tournament at a given date and time. By default, it starts 10 minutes after creation. + /// - roundInterval: How long to wait between each round, in seconds. + /// - variant: + /// - position: + /// - description: Anything you want to tell players about the tournament + /// - rated: Games are rated and impact players ratings + /// - password: Make the tournament private and restrict access with a password. + /// - forbiddenPairings: Usernames of players that must not play together. + /// - manualPairings: Manual pairings for the next round. + /// - chatFor: Who can read and write in the chat. + /// - conditions_period_minRating_period_rating: Minimum rating to join. Leave empty to let everyone join the tournament. + /// - conditions_period_maxRating_period_rating: Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// - conditions_period_nbRatedGame_period_nb: Minimum number of rated games required to join. + /// - conditions_period_playYourGames: Only let players join if they have played their last swiss game. + /// - conditions_period_allowList: Predefined list of usernames that are allowed to join, separated by commas. + internal init( + name: Swift.String? = nil, + clock_period_limit: Swift.Double, + clock_period_increment: Swift.Int, + nbRounds: Swift.Int, + startsAt: Swift.Int? = nil, + roundInterval: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.roundIntervalPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + position: Components.Schemas.FromPositionFEN? = nil, + description: Swift.String? = nil, + rated: Swift.Bool? = nil, + password: Swift.String? = nil, + forbiddenPairings: Swift.String? = nil, + manualPairings: Swift.String? = nil, + chatFor: Swift.Double? = nil, + conditions_period_minRating_period_rating: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? = nil, + conditions_period_maxRating_period_rating: Operations.apiSwissNew.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? = nil, + conditions_period_nbRatedGame_period_nb: Swift.Int? = nil, + conditions_period_playYourGames: Swift.Bool? = nil, + conditions_period_allowList: Swift.String? = nil + ) { + self.name = name + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.nbRounds = nbRounds + self.startsAt = startsAt + self.roundInterval = roundInterval + self.variant = variant + self.position = position + self.description = description + self.rated = rated + self.password = password + self.forbiddenPairings = forbiddenPairings + self.manualPairings = manualPairings + self.chatFor = chatFor + self.conditions_period_minRating_period_rating = conditions_period_minRating_period_rating + self.conditions_period_maxRating_period_rating = conditions_period_maxRating_period_rating + self.conditions_period_nbRatedGame_period_nb = conditions_period_nbRatedGame_period_nb + self.conditions_period_playYourGames = conditions_period_playYourGames + self.conditions_period_allowList = conditions_period_allowList + } + internal enum CodingKeys: String, CodingKey { + case name + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case nbRounds + case startsAt + case roundInterval + case variant + case position + case description + case rated + case password + case forbiddenPairings + case manualPairings + case chatFor + case conditions_period_minRating_period_rating = "conditions.minRating.rating" + case conditions_period_maxRating_period_rating = "conditions.maxRating.rating" + case conditions_period_nbRatedGame_period_nb = "conditions.nbRatedGame.nb" + case conditions_period_playYourGames = "conditions.playYourGames" + case conditions_period_allowList = "conditions.allowList" + } + } + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiSwissNew.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiSwissNew.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiSwissNew.Input.Path, + headers: Operations.apiSwissNew.Input.Headers = .init(), + body: Operations.apiSwissNew.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissNew.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.SwissTournament) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.SwissTournament { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissNew.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSwissNew.Output.Ok.Headers = .init(), + body: Operations.apiSwissNew.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The Swiss tournament was successfully created. + /// + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSwissNew.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSwissNew.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/new/{teamId}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissNew.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissNew.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the Swiss tournament failed. + /// + /// - Remark: Generated from `#/paths//api/swiss/new/{teamId}/post(apiSwissNew)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiSwissNew.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiSwissNew.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get info about a Swiss tournament + /// + /// Get detailed info about a Swiss tournament. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/get(swiss)`. + internal enum swiss { + internal static let id: Swift.String = "swiss" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The Swiss tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The Swiss tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.swiss.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.swiss.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.swiss.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.swiss.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.swiss.Input.Path, + headers: Operations.swiss.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.swiss.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.SwissTournament) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.SwissTournament { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.swiss.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.swiss.Output.Ok.Headers = .init(), + body: Operations.swiss.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The information of the Swiss tournament. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/get(swiss)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.swiss.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.swiss.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update a Swiss tournament + /// + /// Update a Swiss tournament. + /// Be mindful not to make important changes to ongoing tournaments. + /// Additional restrictions: + /// - clock.limit + clock.increment > 0 + /// - 15s and 0+1 variant tournaments cannot be rated + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/edit`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)`. + internal enum apiSwissUpdate { + internal static let id: Swift.String = "apiSwissUpdate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiSwissUpdate.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissUpdate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissUpdate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissUpdate.Input.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament name. Leave empty to get a random Grandmaster name + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String? + /// Clock initial time in seconds + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double + /// Clock increment in seconds + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int + /// Maximum number of rounds to play + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/nbRounds`. + internal var nbRounds: Swift.Int + /// Timestamp in milliseconds to start the tournament at a given date and time. By default, it starts 10 minutes after creation. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/startsAt`. + internal var startsAt: Swift.Int? + /// How long to wait between each round, in seconds. + /// Set to 99999999 to manually schedule each round from the tournament UI, or [with the API](#tag/Swiss-tournaments/operation/apiSwissScheduleNextRound). + /// If empty or -1, a sensible value is picked automatically. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/roundInterval`. + @frozen internal enum roundIntervalPayload: Int, Codable, Hashable, Sendable { + case _n1 = -1 + case _5 = 5 + case _10 = 10 + case _20 = 20 + case _30 = 30 + case _45 = 45 + case _60 = 60 + case _120 = 120 + case _180 = 180 + case _300 = 300 + case _600 = 600 + case _900 = 900 + case _1200 = 1200 + case _1800 = 1800 + case _2700 = 2700 + case _3600 = 3600 + case _86400 = 86400 + case _172800 = 172800 + case _604800 = 604800 + case _99999999 = 99999999 + } + /// How long to wait between each round, in seconds. + /// Set to 99999999 to manually schedule each round from the tournament UI, or [with the API](#tag/Swiss-tournaments/operation/apiSwissScheduleNextRound). + /// If empty or -1, a sensible value is picked automatically. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/roundInterval`. + internal var roundInterval: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.roundIntervalPayload? + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// Anything you want to tell players about the tournament + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/description`. + internal var description: Swift.String? + /// Games are rated and impact players ratings + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// Make the tournament private and restrict access with a password. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Usernames of players that must not play together. + /// Two usernames per line, separated by a space. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/forbiddenPairings`. + internal var forbiddenPairings: Swift.String? + /// Manual pairings for the next round. + /// Two usernames per line, separated by a space. + /// Present players without a valid pairing will be given a bye, which is worth 1 point. + /// Forfeited players will get 0 points. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/manualPairings`. + internal var manualPairings: Swift.String? + /// Who can read and write in the chat. + /// - 0 = No-one + /// - 10 = Only team leaders + /// - 20 = Only team members + /// - 30 = All Lichess players + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/chatFor`. + internal var chatFor: Swift.Double? + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + @frozen internal enum conditions_period_minRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _1000 = 1000 + case _1100 = 1100 + case _1200 = 1200 + case _1300 = 1300 + case _1400 = 1400 + case _1500 = 1500 + case _1600 = 1600 + case _1700 = 1700 + case _1800 = 1800 + case _1900 = 1900 + case _2000 = 2000 + case _2100 = 2100 + case _2200 = 2200 + case _2300 = 2300 + case _2400 = 2400 + case _2500 = 2500 + case _2600 = 2600 + } + /// Minimum rating to join. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.minRating.rating`. + internal var conditions_period_minRating_period_rating: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + @frozen internal enum conditions_period_maxRating_period_ratingPayload: Int, Codable, Hashable, Sendable { + case _2200 = 2200 + case _2100 = 2100 + case _2000 = 2000 + case _1900 = 1900 + case _1800 = 1800 + case _1700 = 1700 + case _1600 = 1600 + case _1500 = 1500 + case _1400 = 1400 + case _1300 = 1300 + case _1200 = 1200 + case _1100 = 1100 + case _1000 = 1000 + case _900 = 900 + case _800 = 800 + } + /// Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.maxRating.rating`. + internal var conditions_period_maxRating_period_rating: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? + /// Minimum number of rated games required to join. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.nbRatedGame.nb`. + internal var conditions_period_nbRatedGame_period_nb: Swift.Int? + /// Only let players join if they have played their last swiss game. + /// If they failed to show up in a recent swiss event, they won't be able to enter yours. + /// This results in a better swiss experience for the players who actually show up. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.playYourGames`. + internal var conditions_period_playYourGames: Swift.Bool? + /// Predefined list of usernames that are allowed to join, separated by commas. + /// If this list is non-empty, then usernames absent from this list will be forbidden to join. + /// Adding `%titled` to the list additionally allows any titled player to join. + /// Example: `thibault,german11,%titled` + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/urlEncodedForm/conditions.allowList`. + internal var conditions_period_allowList: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: The tournament name. Leave empty to get a random Grandmaster name + /// - clock_period_limit: Clock initial time in seconds + /// - clock_period_increment: Clock increment in seconds + /// - nbRounds: Maximum number of rounds to play + /// - startsAt: Timestamp in milliseconds to start the tournament at a given date and time. By default, it starts 10 minutes after creation. + /// - roundInterval: How long to wait between each round, in seconds. + /// - variant: + /// - description: Anything you want to tell players about the tournament + /// - rated: Games are rated and impact players ratings + /// - password: Make the tournament private and restrict access with a password. + /// - forbiddenPairings: Usernames of players that must not play together. + /// - manualPairings: Manual pairings for the next round. + /// - chatFor: Who can read and write in the chat. + /// - conditions_period_minRating_period_rating: Minimum rating to join. Leave empty to let everyone join the tournament. + /// - conditions_period_maxRating_period_rating: Maximum rating to join. Based on best rating reached in the last 7 days. Leave empty to let everyone join the tournament. + /// - conditions_period_nbRatedGame_period_nb: Minimum number of rated games required to join. + /// - conditions_period_playYourGames: Only let players join if they have played their last swiss game. + /// - conditions_period_allowList: Predefined list of usernames that are allowed to join, separated by commas. + internal init( + name: Swift.String? = nil, + clock_period_limit: Swift.Double, + clock_period_increment: Swift.Int, + nbRounds: Swift.Int, + startsAt: Swift.Int? = nil, + roundInterval: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.roundIntervalPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + description: Swift.String? = nil, + rated: Swift.Bool? = nil, + password: Swift.String? = nil, + forbiddenPairings: Swift.String? = nil, + manualPairings: Swift.String? = nil, + chatFor: Swift.Double? = nil, + conditions_period_minRating_period_rating: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.conditions_period_minRating_period_ratingPayload? = nil, + conditions_period_maxRating_period_rating: Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload.conditions_period_maxRating_period_ratingPayload? = nil, + conditions_period_nbRatedGame_period_nb: Swift.Int? = nil, + conditions_period_playYourGames: Swift.Bool? = nil, + conditions_period_allowList: Swift.String? = nil + ) { + self.name = name + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.nbRounds = nbRounds + self.startsAt = startsAt + self.roundInterval = roundInterval + self.variant = variant + self.description = description + self.rated = rated + self.password = password + self.forbiddenPairings = forbiddenPairings + self.manualPairings = manualPairings + self.chatFor = chatFor + self.conditions_period_minRating_period_rating = conditions_period_minRating_period_rating + self.conditions_period_maxRating_period_rating = conditions_period_maxRating_period_rating + self.conditions_period_nbRatedGame_period_nb = conditions_period_nbRatedGame_period_nb + self.conditions_period_playYourGames = conditions_period_playYourGames + self.conditions_period_allowList = conditions_period_allowList + } + internal enum CodingKeys: String, CodingKey { + case name + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case nbRounds + case startsAt + case roundInterval + case variant + case description + case rated + case password + case forbiddenPairings + case manualPairings + case chatFor + case conditions_period_minRating_period_rating = "conditions.minRating.rating" + case conditions_period_maxRating_period_rating = "conditions.maxRating.rating" + case conditions_period_nbRatedGame_period_nb = "conditions.nbRatedGame.nb" + case conditions_period_playYourGames = "conditions.playYourGames" + case conditions_period_allowList = "conditions.allowList" + } + } + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiSwissUpdate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiSwissUpdate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiSwissUpdate.Input.Path, + headers: Operations.apiSwissUpdate.Input.Headers = .init(), + body: Operations.apiSwissUpdate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissUpdate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/200/content/application\/json`. + case json(Components.Schemas.SwissTournament) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.SwissTournament { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissUpdate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSwissUpdate.Output.Ok.Headers = .init(), + body: Operations.apiSwissUpdate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The Swiss tournament was successfully updated. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSwissUpdate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSwissUpdate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissUpdate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissUpdate.Output.BadRequest.Body) { + self.body = body + } + } + /// Updating the swiss failed. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiSwissUpdate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiSwissUpdate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + internal struct Unauthorized: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/401/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/edit/POST/responses/401/content/application\/json`. + case json(Components.Schemas.SwissUnauthorisedEdit) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.SwissUnauthorisedEdit { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissUpdate.Output.Unauthorized.Body + /// Creates a new `Unauthorized`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissUpdate.Output.Unauthorized.Body) { + self.body = body + } + } + /// This user cannot update this Swiss. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/edit/post(apiSwissUpdate)/responses/401`. + /// + /// HTTP response code: `401 unauthorized`. + case unauthorized(Operations.apiSwissUpdate.Output.Unauthorized) + /// The associated value of the enum case if `self` is `.unauthorized`. + /// + /// - Throws: An error if `self` is not `.unauthorized`. + /// - SeeAlso: `.unauthorized`. + internal var unauthorized: Operations.apiSwissUpdate.Output.Unauthorized { + get throws { + switch self { + case let .unauthorized(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "unauthorized", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Manually schedule the next round + /// + /// Manually schedule the next round date and time of a Swiss tournament. + /// This sets the `roundInterval` field to `99999999`, i.e. manual scheduling. + /// All further rounds will need to be manually scheduled, unless the `roundInterval` field is changed back to automatic scheduling. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/schedule-next-round`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)`. + internal enum apiSwissScheduleNextRound { + internal static let id: Swift.String = "apiSwissScheduleNextRound" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiSwissScheduleNextRound.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissScheduleNextRound.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissScheduleNextRound.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissScheduleNextRound.Input.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Timestamp in milliseconds to start the next round at a given date and time. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/requestBody/urlEncodedForm/date`. + internal var date: Swift.Int? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - date: Timestamp in milliseconds to start the next round at a given date and time. + internal init(date: Swift.Int? = nil) { + self.date = date + } + internal enum CodingKeys: String, CodingKey { + case date + } + } + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiSwissScheduleNextRound.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiSwissScheduleNextRound.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiSwissScheduleNextRound.Input.Path, + headers: Operations.apiSwissScheduleNextRound.Input.Headers = .init(), + body: Operations.apiSwissScheduleNextRound.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct NoContent: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/204/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/204/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissScheduleNextRound.Output.NoContent.Headers + /// Creates a new `NoContent`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.apiSwissScheduleNextRound.Output.NoContent.Headers = .init()) { + self.headers = headers + } + } + /// The Swiss tournament was successfully updated. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)/responses/204`. + /// + /// HTTP response code: `204 noContent`. + case noContent(Operations.apiSwissScheduleNextRound.Output.NoContent) + /// The associated value of the enum case if `self` is `.noContent`. + /// + /// - Throws: An error if `self` is not `.noContent`. + /// - SeeAlso: `.noContent`. + internal var noContent: Operations.apiSwissScheduleNextRound.Output.NoContent { + get throws { + switch self { + case let .noContent(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "noContent", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissScheduleNextRound.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissScheduleNextRound.Output.BadRequest.Body) { + self.body = body + } + } + /// Updating the swiss failed. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiSwissScheduleNextRound.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiSwissScheduleNextRound.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + internal struct Unauthorized: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/401/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/schedule-next-round/POST/responses/401/content/application\/json`. + case json(Components.Schemas.SwissUnauthorisedEdit) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.SwissUnauthorisedEdit { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissScheduleNextRound.Output.Unauthorized.Body + /// Creates a new `Unauthorized`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissScheduleNextRound.Output.Unauthorized.Body) { + self.body = body + } + } + /// This user cannot update this Swiss. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/schedule-next-round/post(apiSwissScheduleNextRound)/responses/401`. + /// + /// HTTP response code: `401 unauthorized`. + case unauthorized(Operations.apiSwissScheduleNextRound.Output.Unauthorized) + /// The associated value of the enum case if `self` is `.unauthorized`. + /// + /// - Throws: An error if `self` is not `.unauthorized`. + /// - SeeAlso: `.unauthorized`. + internal var unauthorized: Operations.apiSwissScheduleNextRound.Output.Unauthorized { + get throws { + switch self { + case let .unauthorized(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "unauthorized", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Join a Swiss tournament + /// + /// Join a Swiss tournament, possibly with a password. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/join`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)`. + internal enum apiSwissJoin { + internal static let id: Swift.String = "apiSwissJoin" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiSwissJoin.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissJoin.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissJoin.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissJoin.Input.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The tournament password, if one is required + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - password: The tournament password, if one is required + internal init(password: Swift.String? = nil) { + self.password = password + } + internal enum CodingKeys: String, CodingKey { + case password + } + } + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiSwissJoin.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiSwissJoin.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiSwissJoin.Input.Path, + headers: Operations.apiSwissJoin.Input.Headers = .init(), + body: Operations.apiSwissJoin.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissJoin.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissJoin.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSwissJoin.Output.Ok.Headers = .init(), + body: Operations.apiSwissJoin.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tournament was successfully joined. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSwissJoin.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSwissJoin.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/join/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissJoin.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissJoin.Output.BadRequest.Body) { + self.body = body + } + } + /// Joining the tournament failed. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/join/post(apiSwissJoin)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiSwissJoin.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiSwissJoin.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Pause or leave a swiss tournament + /// + /// Leave a future Swiss tournament, or take a break on an ongoing Swiss tournament. + /// It's possible to join again later. Points are preserved. + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/withdraw`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/withdraw/post(apiSwissWithdraw)`. + internal enum apiSwissWithdraw { + internal static let id: Swift.String = "apiSwissWithdraw" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiSwissWithdraw.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissWithdraw.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissWithdraw.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissWithdraw.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiSwissWithdraw.Input.Path, + headers: Operations.apiSwissWithdraw.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissWithdraw.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/withdraw/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissWithdraw.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSwissWithdraw.Output.Ok.Headers = .init(), + body: Operations.apiSwissWithdraw.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tournament was successfully paused or left. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/withdraw/post(apiSwissWithdraw)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSwissWithdraw.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSwissWithdraw.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Terminate a Swiss tournament + /// + /// Terminate a Swiss tournament + /// + /// + /// - Remark: HTTP `POST /api/swiss/{id}/terminate`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)`. + internal enum apiSwissTerminate { + internal static let id: Swift.String = "apiSwissTerminate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/path`. + internal struct Path: Sendable, Hashable { + /// The Swiss tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The Swiss tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiSwissTerminate.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissTerminate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSwissTerminate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSwissTerminate.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiSwissTerminate.Input.Path, + headers: Operations.apiSwissTerminate.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSwissTerminate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissTerminate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSwissTerminate.Output.Ok.Headers = .init(), + body: Operations.apiSwissTerminate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The Swiss tournament was successfully terminated. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSwissTerminate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSwissTerminate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/terminate/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSwissTerminate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiSwissTerminate.Output.BadRequest.Body) { + self.body = body + } + } + /// Terminating the Swiss tournament failed. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/terminate/post(apiSwissTerminate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiSwissTerminate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiSwissTerminate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Export TRF of a Swiss tournament + /// + /// Download a tournament in the Tournament Report File format, the FIDE standard. + /// Documentation: <https://www.fide.com/FIDE/handbook/C04Annex2_TRF16.pdf> + /// Example: <https://lichess.org/swiss/j8rtJ5GL.trf> + /// + /// + /// - Remark: HTTP `GET /swiss/{id}.trf`. + /// - Remark: Generated from `#/paths//swiss/{id}.trf/get(swissTrf)`. + internal enum swissTrf { + internal static let id: Swift.String = "swissTrf" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.swissTrf.Input.Path + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.swissTrf.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.swissTrf.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.swissTrf.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.swissTrf.Input.Path, + headers: Operations.swissTrf.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.swissTrf.Output.Ok.Headers + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/swiss/{id}.trf/GET/responses/200/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.plainText`. + /// + /// - Throws: An error if `self` is not `.plainText`. + /// - SeeAlso: `.plainText`. + internal var plainText: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .plainText(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.swissTrf.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.swissTrf.Output.Ok.Headers = .init(), + body: Operations.swissTrf.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The TRF representation of a Swiss tournament. + /// + /// - Remark: Generated from `#/paths//swiss/{id}.trf/get(swissTrf)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.swissTrf.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.swissTrf.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case plainText + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "text/plain": + self = .plainText + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .plainText: + return "text/plain" + } + } + internal static var allCases: [Self] { + [ + .plainText + ] + } + } + } + /// Export games of a Swiss tournament + /// + /// Download games of a swiss tournament in PGN or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. + /// Games are sorted by reverse chronological order (last round first). + /// The game stream is throttled, depending on who is making the request: + /// - Anonymous request: 20 games per second + /// - [OAuth2 authenticated](#section/Introduction/Authentication) request: 30 games per second + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/games`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/games/get(gamesBySwiss)`. + internal enum gamesBySwiss { + internal static let id: Swift.String = "gamesBySwiss" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.gamesBySwiss.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query`. + internal struct Query: Sendable, Hashable { + /// Only the games played by a given player + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/player`. + internal var player: Swift.String? + /// Include the PGN moves. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/moves`. + internal var moves: Swift.Bool? + /// Include the full PGN within the JSON response, in a `pgn` field. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/pgnInJson`. + internal var pgnInJson: Swift.Bool? + /// Include the PGN tags. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/tags`. + internal var tags: Swift.Bool? + /// Include clock status when available. + /// Either as PGN comments: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// Or in a `clocks` JSON field, as centisecond integers, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis evaluations and comments, when available. + /// Either as PGN comments: `12. Bxf6 { [%eval 0.23] } a3 { [%eval -1.09] }` + /// Or in an `analysis` JSON field, depending on the response type. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/evals`. + internal var evals: Swift.Bool? + /// Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/accuracy`. + internal var accuracy: Swift.Bool? + /// Include the opening name. + /// Example: `[Opening "King's Gambit Accepted, King's Knight Gambit"]` + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/opening`. + internal var opening: Swift.Bool? + /// Plies which mark the beginning of the middlegame and endgame. + /// Only available in JSON + /// + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/query/division`. + internal var division: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - player: Only the games played by a given player + /// - moves: Include the PGN moves. + /// - pgnInJson: Include the full PGN within the JSON response, in a `pgn` field. + /// - tags: Include the PGN tags. + /// - clocks: Include clock status when available. + /// - evals: Include analysis evaluations and comments, when available. + /// - accuracy: Include [accuracy percent](https://lichess.org/page/accuracy) of each player, when available. + /// - opening: Include the opening name. + /// - division: Plies which mark the beginning of the middlegame and endgame. + internal init( + player: Swift.String? = nil, + moves: Swift.Bool? = nil, + pgnInJson: Swift.Bool? = nil, + tags: Swift.Bool? = nil, + clocks: Swift.Bool? = nil, + evals: Swift.Bool? = nil, + accuracy: Swift.Bool? = nil, + opening: Swift.Bool? = nil, + division: Swift.Bool? = nil + ) { + self.player = player + self.moves = moves + self.pgnInJson = pgnInJson + self.tags = tags + self.clocks = clocks + self.evals = evals + self.accuracy = accuracy + self.opening = opening + self.division = division + } + } + internal var query: Operations.gamesBySwiss.Input.Query + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesBySwiss.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.gamesBySwiss.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.gamesBySwiss.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.gamesBySwiss.Input.Path, + query: Operations.gamesBySwiss.Input.Query = .init(), + headers: Operations.gamesBySwiss.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.gamesBySwiss.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-chess-pgn", + body: self + ) + } + } + } + /// - Remark: Generated from `#/paths/api/swiss/{id}/games/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + default: + try throwUnexpectedResponseBody( + expectedContent: "application/x-ndjson", + body: self + ) + } + } + } + } + /// Received HTTP response body + internal var body: Operations.gamesBySwiss.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.gamesBySwiss.Output.Ok.Headers = .init(), + body: Operations.gamesBySwiss.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of games of a Swiss tournament. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/games/get(gamesBySwiss)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.gamesBySwiss.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.gamesBySwiss.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn, + .application_x_hyphen_ndjson + ] + } + } + } + /// Get results of a swiss tournament + /// + /// Players of a swiss tournament, with their score and performance, sorted by rank (best first). + /// Players are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// If called on an ongoing tournament, results can be inconsistent + /// due to ranking changes while the players are being streamed. + /// Use on finished tournaments for guaranteed consistency. + /// + /// + /// - Remark: HTTP `GET /api/swiss/{id}/results`. + /// - Remark: Generated from `#/paths//api/swiss/{id}/results/get(resultsBySwiss)`. + internal enum resultsBySwiss { + internal static let id: Swift.String = "resultsBySwiss" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/path`. + internal struct Path: Sendable, Hashable { + /// The tournament ID. + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The tournament ID. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.resultsBySwiss.Input.Path + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/query`. + internal struct Query: Sendable, Hashable { + /// Max number of players to fetch + /// + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: Max number of players to fetch + internal init(nb: Swift.Int? = nil) { + self.nb = nb + } + } + internal var query: Operations.resultsBySwiss.Input.Query + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.resultsBySwiss.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.resultsBySwiss.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.resultsBySwiss.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.resultsBySwiss.Input.Path, + query: Operations.resultsBySwiss.Input.Query = .init(), + headers: Operations.resultsBySwiss.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.resultsBySwiss.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/swiss/{id}/results/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.resultsBySwiss.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.resultsBySwiss.Output.Ok.Headers = .init(), + body: Operations.resultsBySwiss.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The results of a Swiss tournament. + /// + /// - Remark: Generated from `#/paths//api/swiss/{id}/results/get(resultsBySwiss)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.resultsBySwiss.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.resultsBySwiss.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Get team swiss tournaments + /// + /// Get all swiss tournaments of a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/swiss`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/swiss/get(apiTeamSwiss)`. + internal enum apiTeamSwiss { + internal static let id: Swift.String = "apiTeamSwiss" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.apiTeamSwiss.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many tournaments to download. + /// + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/query/max`. + internal var max: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - max: How many tournaments to download. + internal init(max: Swift.Int? = nil) { + self.max = max + } + } + internal var query: Operations.apiTeamSwiss.Input.Query + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTeamSwiss.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTeamSwiss.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTeamSwiss.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiTeamSwiss.Input.Path, + query: Operations.apiTeamSwiss.Input.Query = .init(), + headers: Operations.apiTeamSwiss.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTeamSwiss.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/swiss/GET/responses/200/content/application\/nd-json`. + case application_nd_hyphen_json(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_nd_hyphen_json`. + /// + /// - Throws: An error if `self` is not `.application_nd_hyphen_json`. + /// - SeeAlso: `.application_nd_hyphen_json`. + internal var application_nd_hyphen_json: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_nd_hyphen_json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTeamSwiss.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTeamSwiss.Output.Ok.Headers = .init(), + body: Operations.apiTeamSwiss.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of Swiss tournaments of a team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/swiss/get(apiTeamSwiss)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTeamSwiss.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTeamSwiss.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_nd_hyphen_json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/nd-json": + self = .application_nd_hyphen_json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_nd_hyphen_json: + return "application/nd-json" + } + } + internal static var allCases: [Self] { + [ + .application_nd_hyphen_json + ] + } + } + } + /// Export one study chapter + /// + /// Download one study chapter in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}/{chapterId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}.pgn/get(studyChapterPgn)`. + internal enum studyChapterPgn { + internal static let id: Swift.String = "studyChapterPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The study ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/path/studyId`. + internal var studyId: Swift.String + /// The chapter ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/path/chapterId`. + internal var chapterId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - studyId: The study ID (8 characters). + /// - chapterId: The chapter ID (8 characters). + internal init( + studyId: Swift.String, + chapterId: Swift.String + ) { + self.studyId = studyId + self.chapterId = chapterId + } + } + internal var path: Operations.studyChapterPgn.Input.Path + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include clock comments in the PGN moves, when available. + /// Example: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis and annotator comments in the PGN moves, when available. + /// Example: `12. Bxf6 { [%eval 0.23] } a3 { White is in a pickle. }` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query/comments`. + internal var comments: Swift.Bool? + /// Include non-mainline moves, when available. + /// Example: `4. d4 Bb4+ (4... Nc6 5. Nf3 Bb4+ 6. Bd2 (6. Nbd2 O-O 7. O-O) 6... Bd6) 5. Nd2` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query/variations`. + internal var variations: Swift.Bool? + /// Add a `Source` PGN tag with the study chapter URL. + /// Example: `[Source "https://lichess.org/study/4NBHImfM/1Tk4IyTz"]` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query/source`. + internal var source: Swift.Bool? + /// Add a `Orientation` PGN tag with the chapter predefined orientation. + /// Example: `[Orientation "white"]` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/query/orientation`. + internal var orientation: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - clocks: Include clock comments in the PGN moves, when available. + /// - comments: Include analysis and annotator comments in the PGN moves, when available. + /// - variations: Include non-mainline moves, when available. + /// - source: Add a `Source` PGN tag with the study chapter URL. + /// - orientation: Add a `Orientation` PGN tag with the chapter predefined orientation. + internal init( + clocks: Swift.Bool? = nil, + comments: Swift.Bool? = nil, + variations: Swift.Bool? = nil, + source: Swift.Bool? = nil, + orientation: Swift.Bool? = nil + ) { + self.clocks = clocks + self.comments = comments + self.variations = variations + self.source = source + self.orientation = orientation + } + } + internal var query: Operations.studyChapterPgn.Input.Query + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyChapterPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyChapterPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.studyChapterPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.studyChapterPgn.Input.Path, + query: Operations.studyChapterPgn.Input.Query = .init(), + headers: Operations.studyChapterPgn.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.studyChapterPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.studyChapterPgn.Output.Ok.Body) { + self.body = body + } + } + /// The chapter of the study. + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}.pgn/get(studyChapterPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.studyChapterPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.studyChapterPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Export all chapters + /// + /// Download all chapters of a study in PGN format. + /// + /// + /// - Remark: HTTP `GET /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/get(studyAllChaptersPgn)`. + internal enum studyAllChaptersPgn { + internal static let id: Swift.String = "studyAllChaptersPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The study ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/path/studyId`. + internal var studyId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - studyId: The study ID (8 characters). + internal init(studyId: Swift.String) { + self.studyId = studyId + } + } + internal var path: Operations.studyAllChaptersPgn.Input.Path + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include clock comments in the PGN moves, when available. + /// Example: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis and annotator comments in the PGN moves, when available. + /// Example: `12. Bxf6 { [%eval 0.23] } a3 { White is in a pickle. }` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query/comments`. + internal var comments: Swift.Bool? + /// Include non-mainline moves, when available. + /// Example: `4. d4 Bb4+ (4... Nc6 5. Nf3 Bb4+ 6. Bd2 (6. Nbd2 O-O 7. O-O) 6... Bd6) 5. Nd2` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query/variations`. + internal var variations: Swift.Bool? + /// Add a `Source` PGN tag with the study chapter URL. + /// Example: `[Source "https://lichess.org/study/4NBHImfM/1Tk4IyTz"]` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query/source`. + internal var source: Swift.Bool? + /// Add a `Orientation` PGN tag with the chapter predefined orientation. + /// Example: `[Orientation "white"]` + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/query/orientation`. + internal var orientation: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - clocks: Include clock comments in the PGN moves, when available. + /// - comments: Include analysis and annotator comments in the PGN moves, when available. + /// - variations: Include non-mainline moves, when available. + /// - source: Add a `Source` PGN tag with the study chapter URL. + /// - orientation: Add a `Orientation` PGN tag with the chapter predefined orientation. + internal init( + clocks: Swift.Bool? = nil, + comments: Swift.Bool? = nil, + variations: Swift.Bool? = nil, + source: Swift.Bool? = nil, + orientation: Swift.Bool? = nil + ) { + self.clocks = clocks + self.comments = comments + self.variations = variations + self.source = source + self.orientation = orientation + } + } + internal var query: Operations.studyAllChaptersPgn.Input.Query + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyAllChaptersPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyAllChaptersPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.studyAllChaptersPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.studyAllChaptersPgn.Input.Path, + query: Operations.studyAllChaptersPgn.Input.Query = .init(), + headers: Operations.studyAllChaptersPgn.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/responses/200/headers/Last-Modified`. + internal var Last_hyphen_Modified: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + /// - Last_hyphen_Modified: + internal init( + Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil, + Last_hyphen_Modified: Swift.String? = nil + ) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + self.Last_hyphen_Modified = Last_hyphen_Modified + } + } + /// Received HTTP response headers + internal var headers: Operations.studyAllChaptersPgn.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.studyAllChaptersPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.studyAllChaptersPgn.Output.Ok.Headers = .init(), + body: Operations.studyAllChaptersPgn.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The PGN representation of the study. + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/get(studyAllChaptersPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.studyAllChaptersPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.studyAllChaptersPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Study metadata + /// + /// Only get the study headers, including `Last-Modified`. + /// + /// + /// - Remark: HTTP `HEAD /api/study/{studyId}.pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/head(studyAllChaptersHead)`. + internal enum studyAllChaptersHead { + internal static let id: Swift.String = "studyAllChaptersHead" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/HEAD/path`. + internal struct Path: Sendable, Hashable { + /// The study ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/HEAD/path/studyId`. + internal var studyId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - studyId: The study ID (8 characters). + internal init(studyId: Swift.String) { + self.studyId = studyId + } + } + internal var path: Operations.studyAllChaptersHead.Input.Path + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + internal init(path: Operations.studyAllChaptersHead.Input.Path) { + self.path = path + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/HEAD/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/HEAD/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// - Remark: Generated from `#/paths/api/study/{studyId}.pgn/HEAD/responses/200/headers/Last-Modified`. + internal var Last_hyphen_Modified: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + /// - Last_hyphen_Modified: + internal init( + Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil, + Last_hyphen_Modified: Swift.String? = nil + ) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + self.Last_hyphen_Modified = Last_hyphen_Modified + } + } + /// Received HTTP response headers + internal var headers: Operations.studyAllChaptersHead.Output.Ok.Headers + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.studyAllChaptersHead.Output.Ok.Headers = .init()) { + self.headers = headers + } + } + /// The study headers. + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}.pgn/head(studyAllChaptersHead)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.studyAllChaptersHead.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.studyAllChaptersHead.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + } + /// Import PGN into a study + /// + /// Imports arbitrary PGN into an existing [study](https://lichess.org/study). Creates a new chapter in the study. + /// If the PGN contains multiple games (separated by 2 or more newlines) + /// then multiple chapters will be created within the study. + /// Note that a study can contain at most 64 chapters. + /// + /// + /// - Remark: HTTP `POST /api/study/{studyId}/import-pgn`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)`. + internal enum apiStudyImportPGN { + internal static let id: Swift.String = "apiStudyImportPGN" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/path`. + internal struct Path: Sendable, Hashable { + /// ID of the study + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/path/studyId`. + internal var studyId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - studyId: ID of the study + internal init(studyId: Swift.String) { + self.studyId = studyId + } + } + internal var path: Operations.apiStudyImportPGN.Input.Path + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStudyImportPGN.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStudyImportPGN.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiStudyImportPGN.Input.Headers + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Name of the new chapter. + /// If multiple chapters are created, the names will be infered from the PGN tags. + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String + /// PGN to import. Can contain multiple games separated by 2 or more newlines. + /// + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm/pgn`. + internal var pgn: Swift.String + /// Default board orientation. + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm/orientation`. + @frozen internal enum orientationPayload: String, Codable, Hashable, Sendable { + case white = "white" + case black = "black" + } + /// Default board orientation. + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm/orientation`. + internal var orientation: Operations.apiStudyImportPGN.Input.Body.urlEncodedFormPayload.orientationPayload? + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: Name of the new chapter. + /// - pgn: PGN to import. Can contain multiple games separated by 2 or more newlines. + /// - orientation: Default board orientation. + /// - variant: + internal init( + name: Swift.String, + pgn: Swift.String, + orientation: Operations.apiStudyImportPGN.Input.Body.urlEncodedFormPayload.orientationPayload? = nil, + variant: Components.Schemas.VariantKey? = nil + ) { + self.name = name + self.pgn = pgn + self.orientation = orientation + self.variant = variant + } + internal enum CodingKeys: String, CodingKey { + case name + case pgn + case orientation + case variant + } + } + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiStudyImportPGN.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiStudyImportPGN.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiStudyImportPGN.Input.Path, + headers: Operations.apiStudyImportPGN.Input.Headers = .init(), + body: Operations.apiStudyImportPGN.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiStudyImportPGN.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/200/content/application\/json`. + case json(Components.Schemas.StudyImportPgnChapters) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.StudyImportPgnChapters { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiStudyImportPGN.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiStudyImportPGN.Output.Ok.Headers = .init(), + body: Operations.apiStudyImportPGN.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The chapters that were created. + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiStudyImportPGN.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiStudyImportPGN.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/import-pgn/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiStudyImportPGN.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiStudyImportPGN.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the chapter(s) failed. + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}/import-pgn/post(apiStudyImportPGN)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiStudyImportPGN.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiStudyImportPGN.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Export all studies of a user + /// + /// Download all chapters of all studies of a user in PGN format. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// + /// + /// - Remark: HTTP `GET /study/by/{username}/export.pgn`. + /// - Remark: Generated from `#/paths//study/by/{username}/export.pgn/get(studyExportAllPgn)`. + internal enum studyExportAllPgn { + internal static let id: Swift.String = "studyExportAllPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The user whose studies we export + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: The user whose studies we export + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.studyExportAllPgn.Input.Path + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query`. + internal struct Query: Sendable, Hashable { + /// Include clock comments in the PGN moves, when available. + /// Example: `2. exd5 { [%clk 1:01:27] } e5 { [%clk 1:01:28] }` + /// + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query/clocks`. + internal var clocks: Swift.Bool? + /// Include analysis and annotator comments in the PGN moves, when available. + /// Example: `12. Bxf6 { [%eval 0.23] } a3 { White is in a pickle. }` + /// + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query/comments`. + internal var comments: Swift.Bool? + /// Include non-mainline moves, when available. + /// Example: `4. d4 Bb4+ (4... Nc6 5. Nf3 Bb4+ 6. Bd2 (6. Nbd2 O-O 7. O-O) 6... Bd6) 5. Nd2` + /// + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query/variations`. + internal var variations: Swift.Bool? + /// Add a `Source` PGN tag with the study chapter URL. + /// Example: `[Source "https://lichess.org/study/4NBHImfM/1Tk4IyTz"]` + /// + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query/source`. + internal var source: Swift.Bool? + /// Add a `Orientation` PGN tag with the chapter predefined orientation. + /// Example: `[Orientation "white"]` + /// + /// + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/query/orientation`. + internal var orientation: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - clocks: Include clock comments in the PGN moves, when available. + /// - comments: Include analysis and annotator comments in the PGN moves, when available. + /// - variations: Include non-mainline moves, when available. + /// - source: Add a `Source` PGN tag with the study chapter URL. + /// - orientation: Add a `Orientation` PGN tag with the chapter predefined orientation. + internal init( + clocks: Swift.Bool? = nil, + comments: Swift.Bool? = nil, + variations: Swift.Bool? = nil, + source: Swift.Bool? = nil, + orientation: Swift.Bool? = nil + ) { + self.clocks = clocks + self.comments = comments + self.variations = variations + self.source = source + self.orientation = orientation + } + } + internal var query: Operations.studyExportAllPgn.Input.Query + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyExportAllPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyExportAllPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.studyExportAllPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.studyExportAllPgn.Input.Path, + query: Operations.studyExportAllPgn.Input.Query = .init(), + headers: Operations.studyExportAllPgn.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/study/by/{username}/export.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.studyExportAllPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.studyExportAllPgn.Output.Ok.Body) { + self.body = body + } + } + /// The studies of the user. + /// + /// - Remark: Generated from `#/paths//study/by/{username}/export.pgn/get(studyExportAllPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.studyExportAllPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.studyExportAllPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// List studies of a user + /// + /// Get metadata (name and dates) of all studies of a user. + /// If authenticated, then all public, unlisted, and private studies are included. + /// If not, only public (non-unlisted) studies are included. + /// Studies are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/study/by/{username}`. + /// - Remark: Generated from `#/paths//api/study/by/{username}/get(studyListMetadata)`. + internal enum studyListMetadata { + internal static let id: Swift.String = "studyListMetadata" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The user whose studies we list + /// + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: The user whose studies we list + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.studyListMetadata.Input.Path + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyListMetadata.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.studyListMetadata.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.studyListMetadata.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.studyListMetadata.Input.Path, + headers: Operations.studyListMetadata.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.studyListMetadata.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/by/{username}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.studyListMetadata.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.studyListMetadata.Output.Ok.Headers = .init(), + body: Operations.studyListMetadata.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of studies. + /// + /// - Remark: Generated from `#/paths//api/study/by/{username}/get(studyListMetadata)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.studyListMetadata.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.studyListMetadata.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Delete a study chapter + /// + /// Delete a chapter of a study you own. This is definitive. + /// A study must have at least one chapter; so if you delete the last chapter, + /// an empty one will be automatically created to replace it. + /// + /// + /// - Remark: HTTP `DELETE /api/study/{studyId}/{chapterId}`. + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}/delete(apiStudyStudyIdChapterIdDelete)`. + internal enum apiStudyStudyIdChapterIdDelete { + internal static let id: Swift.String = "apiStudyStudyIdChapterIdDelete" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}/DELETE/path`. + internal struct Path: Sendable, Hashable { + /// The study ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}/DELETE/path/studyId`. + internal var studyId: Swift.String + /// The chapter ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}/DELETE/path/chapterId`. + internal var chapterId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - studyId: The study ID (8 characters). + /// - chapterId: The chapter ID (8 characters). + internal init( + studyId: Swift.String, + chapterId: Swift.String + ) { + self.studyId = studyId + self.chapterId = chapterId + } + } + internal var path: Operations.apiStudyStudyIdChapterIdDelete.Input.Path + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + internal init(path: Operations.apiStudyStudyIdChapterIdDelete.Input.Path) { + self.path = path + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct NoContent: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}/DELETE/responses/204/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/study/{studyId}/{chapterId}/DELETE/responses/204/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiStudyStudyIdChapterIdDelete.Output.NoContent.Headers + /// Creates a new `NoContent`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.apiStudyStudyIdChapterIdDelete.Output.NoContent.Headers = .init()) { + self.headers = headers + } + } + /// Chapter successfully deleted + /// + /// - Remark: Generated from `#/paths//api/study/{studyId}/{chapterId}/delete(apiStudyStudyIdChapterIdDelete)/responses/204`. + /// + /// HTTP response code: `204 noContent`. + case noContent(Operations.apiStudyStudyIdChapterIdDelete.Output.NoContent) + /// The associated value of the enum case if `self` is `.noContent`. + /// + /// - Throws: An error if `self` is not `.noContent`. + /// - SeeAlso: `.noContent`. + internal var noContent: Operations.apiStudyStudyIdChapterIdDelete.Output.NoContent { + get throws { + switch self { + case let .noContent(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "noContent", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + } + /// Get official broadcasts + /// + /// Get all incoming, ongoing, and finished official broadcasts. + /// The broadcasts are sorted by start date, most recent first. + /// Broadcasts are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/broadcast`. + /// - Remark: Generated from `#/paths//api/broadcast/get(broadcastIndex)`. + internal enum broadcastIndex { + internal static let id: Swift.String = "broadcastIndex" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/GET/query`. + internal struct Query: Sendable, Hashable { + /// Max number of broadcasts to fetch + /// + /// - Remark: Generated from `#/paths/api/broadcast/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: Max number of broadcasts to fetch + internal init(nb: Swift.Int? = nil) { + self.nb = nb + } + } + internal var query: Operations.broadcastIndex.Input.Query + /// - Remark: Generated from `#/paths/api/broadcast/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastIndex.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastIndex.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastIndex.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.broadcastIndex.Input.Query = .init(), + headers: Operations.broadcastIndex.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastIndex.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/broadcast/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastIndex.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastIndex.Output.Ok.Headers = .init(), + body: Operations.broadcastIndex.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of official broadcasts. + /// + /// - Remark: Generated from `#/paths//api/broadcast/get(broadcastIndex)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastIndex.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastIndex.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Create a broadcast tournament + /// + /// Create a new broadcast tournament to relay external games. + /// This endpoint accepts the same form data as the [web form](https://lichess.org/broadcast/new). + /// + /// + /// - Remark: HTTP `POST /broadcast/new`. + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)`. + internal enum broadcastTourCreate { + internal static let id: Swift.String = "broadcastTourCreate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourCreate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourCreate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastTourCreate.Input.Headers + /// - Remark: Generated from `#/paths/broadcast/new/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Components.Schemas.BroadcastForm) + } + internal var body: Operations.broadcastTourCreate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.broadcastTourCreate.Input.Headers = .init(), + body: Operations.broadcastTourCreate.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastTourCreate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastTour) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastTour { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastTourCreate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastTourCreate.Output.Ok.Headers = .init(), + body: Operations.broadcastTourCreate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The broadcast tournament was successfully created. + /// + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastTourCreate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastTourCreate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/new/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastTourCreate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastTourCreate.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the broadcast tournament failed. + /// + /// - Remark: Generated from `#/paths//broadcast/new/post(broadcastTourCreate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.broadcastTourCreate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.broadcastTourCreate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get a broadcast tournament + /// + /// Get information about a broadcast tournament. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}/get(broadcastTourGet)`. + internal enum broadcastTourGet { + internal static let id: Swift.String = "broadcastTourGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast tournament ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}/GET/path/broadcastTournamentId`. + internal var broadcastTournamentId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentId: The broadcast tournament ID (8 characters). + internal init(broadcastTournamentId: Swift.String) { + self.broadcastTournamentId = broadcastTournamentId + } + } + internal var path: Operations.broadcastTourGet.Input.Path + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastTourGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastTourGet.Input.Path, + headers: Operations.broadcastTourGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastTour) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastTour { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastTourGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastTourGet.Output.Ok.Body) { + self.body = body + } + } + /// The information about the broadcast tournament. + /// + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}/get(broadcastTourGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastTourGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastTourGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get a broadcast leaderboard + /// + /// Get the leaderboard of a broadcast tournament, if available. + /// + /// + /// - Remark: HTTP `GET /broadcast/{broadcastTournamentId}/leaderboard`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/leaderboard/get(broadcastLeaderboardGet)`. + internal enum broadcastLeaderboardGet { + internal static let id: Swift.String = "broadcastLeaderboardGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/leaderboard/GET/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast tournament ID (8 characters). + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/leaderboard/GET/path/broadcastTournamentId`. + internal var broadcastTournamentId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentId: The broadcast tournament ID (8 characters). + internal init(broadcastTournamentId: Swift.String) { + self.broadcastTournamentId = broadcastTournamentId + } + } + internal var path: Operations.broadcastLeaderboardGet.Input.Path + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/leaderboard/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastLeaderboardGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastLeaderboardGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastLeaderboardGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastLeaderboardGet.Input.Path, + headers: Operations.broadcastLeaderboardGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/leaderboard/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/leaderboard/GET/responses/200/content/application\/json`. + case json([Components.Schemas.BroadcastLeaderboardEntry]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.BroadcastLeaderboardEntry] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastLeaderboardGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastLeaderboardGet.Output.Ok.Body) { + self.body = body + } + } + /// The broadcast leaderboard players + /// + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/leaderboard/get(broadcastLeaderboardGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastLeaderboardGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastLeaderboardGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update your broadcast tournament + /// + /// Update information about a broadcast tournament that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)`. + internal enum broadcastTourUpdate { + internal static let id: Swift.String = "broadcastTourUpdate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast ID (8 characters). + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/path/broadcastTournamentId`. + internal var broadcastTournamentId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentId: The broadcast ID (8 characters). + internal init(broadcastTournamentId: Swift.String) { + self.broadcastTournamentId = broadcastTournamentId + } + } + internal var path: Operations.broadcastTourUpdate.Input.Path + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourUpdate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastTourUpdate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastTourUpdate.Input.Headers + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Components.Schemas.BroadcastForm) + } + internal var body: Operations.broadcastTourUpdate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.broadcastTourUpdate.Input.Path, + headers: Operations.broadcastTourUpdate.Input.Headers = .init(), + body: Operations.broadcastTourUpdate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastTourUpdate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastTourUpdate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastTourUpdate.Output.Ok.Headers = .init(), + body: Operations.broadcastTourUpdate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The broadcast tournament was successfully edited. + /// + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastTourUpdate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastTourUpdate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/edit/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastTourUpdate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastTourUpdate.Output.BadRequest.Body) { + self.body = body + } + } + /// The edition of the broadcast tournament failed. + /// + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/edit/post(broadcastTourUpdate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.broadcastTourUpdate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.broadcastTourUpdate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create a broadcast round + /// + /// Create a new broadcast round to relay external games. + /// This endpoint accepts the same form data as the web form. + /// + /// + /// - Remark: HTTP `POST /broadcast/{broadcastTournamentId}/new`. + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)`. + internal enum broadcastRoundCreate { + internal static let id: Swift.String = "broadcastRoundCreate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast tournament ID (8 characters). + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/path/broadcastTournamentId`. + internal var broadcastTournamentId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentId: The broadcast tournament ID (8 characters). + internal init(broadcastTournamentId: Swift.String) { + self.broadcastTournamentId = broadcastTournamentId + } + } + internal var path: Operations.broadcastRoundCreate.Input.Path + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundCreate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundCreate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastRoundCreate.Input.Headers + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Name of the broadcast round. Length must be between 3 and 80 characters. + /// Example: `Round 1` + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String + /// URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. + /// Example: `https://myserver.org/myevent/round-10/games.pgn` + /// If the syncUrl is missing, then the broadcast needs to be fed by [pushing PGN to it](#operation/broadcastPush). + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/syncUrl`. + internal var syncUrl: Swift.String? + /// Required if `syncUrl` contains a livechesscloud link. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/syncUrlRound`. + internal var syncUrlRound: Swift.String? + /// Timestamp in milliseconds of broadcast round start. Leave empty to manually start the broadcast round. + /// Example: `1356998400070` + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/startsAt`. + internal var startsAt: Swift.Int? + /// Delay in seconds for movements to appear on the broadcast. Leave it empty if you don't need it. + /// Example: `900` (15 min) + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/delay`. + internal var delay: Swift.Int? + /// (Only for Admins) Waiting time for each poll. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/period`. + internal var period: Swift.Int? + /// Mark whether the round has been completed. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/urlEncodedForm/finished`. + internal var finished: Swift.Bool? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: Name of the broadcast round. Length must be between 3 and 80 characters. + /// - syncUrl: URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. + /// - syncUrlRound: Required if `syncUrl` contains a livechesscloud link. + /// - startsAt: Timestamp in milliseconds of broadcast round start. Leave empty to manually start the broadcast round. + /// - delay: Delay in seconds for movements to appear on the broadcast. Leave it empty if you don't need it. + /// - period: (Only for Admins) Waiting time for each poll. + /// - finished: Mark whether the round has been completed. + internal init( + name: Swift.String, + syncUrl: Swift.String? = nil, + syncUrlRound: Swift.String? = nil, + startsAt: Swift.Int? = nil, + delay: Swift.Int? = nil, + period: Swift.Int? = nil, + finished: Swift.Bool? = nil + ) { + self.name = name + self.syncUrl = syncUrl + self.syncUrlRound = syncUrlRound + self.startsAt = startsAt + self.delay = delay + self.period = period + self.finished = finished + } + internal enum CodingKeys: String, CodingKey { + case name + case syncUrl + case syncUrlRound + case startsAt + case delay + case period + case finished + } + } + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.broadcastRoundCreate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.broadcastRoundCreate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.broadcastRoundCreate.Input.Path, + headers: Operations.broadcastRoundCreate.Input.Headers = .init(), + body: Operations.broadcastRoundCreate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastRoundCreate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastRound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastRound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundCreate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastRoundCreate.Output.Ok.Headers = .init(), + body: Operations.broadcastRoundCreate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The broadcast round was successfully created. + /// + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastRoundCreate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastRoundCreate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/{broadcastTournamentId}/new/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundCreate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastRoundCreate.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the broadcast failed. + /// + /// - Remark: Generated from `#/paths//broadcast/{broadcastTournamentId}/new/post(broadcastRoundCreate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.broadcastRoundCreate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.broadcastRoundCreate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get a broadcast round + /// + /// Get information about a broadcast round. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/get(broadcastRoundGet)`. + internal enum broadcastRoundGet { + internal static let id: Swift.String = "broadcastRoundGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast tournament slug. Only used for SEO, the slug can be safely replaced by `-`. Only the `broadcastRoundId` is actually used. + /// + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/path/broadcastTournamentSlug`. + internal var broadcastTournamentSlug: Swift.String + /// The broadcast round slug. Only used for SEO, the slug can be safely replaced by `-`. Only the `broadcastRoundId` is actually used. + /// + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/path/broadcastRoundSlug`. + internal var broadcastRoundSlug: Swift.String + /// The broadcast Round ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/path/broadcastRoundId`. + internal var broadcastRoundId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentSlug: The broadcast tournament slug. Only used for SEO, the slug can be safely replaced by `-`. Only the `broadcastRoundId` is actually used. + /// - broadcastRoundSlug: The broadcast round slug. Only used for SEO, the slug can be safely replaced by `-`. Only the `broadcastRoundId` is actually used. + /// - broadcastRoundId: The broadcast Round ID (8 characters). + internal init( + broadcastTournamentSlug: Swift.String, + broadcastRoundSlug: Swift.String, + broadcastRoundId: Swift.String + ) { + self.broadcastTournamentSlug = broadcastTournamentSlug + self.broadcastRoundSlug = broadcastRoundSlug + self.broadcastRoundId = broadcastRoundId + } + } + internal var path: Operations.broadcastRoundGet.Input.Path + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastRoundGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastRoundGet.Input.Path, + headers: Operations.broadcastRoundGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastRound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastRound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastRoundGet.Output.Ok.Body) { + self.body = body + } + } + /// The information about the broadcast round. + /// + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentSlug}/{broadcastRoundSlug}/{broadcastRoundId}/get(broadcastRoundGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastRoundGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastRoundGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update your broadcast round + /// + /// Update information about a broadcast round that you created. + /// This endpoint accepts the same form data as the web form. + /// All fields must be populated with data. Missing fields will override the broadcast with empty data. + /// For instance, if you omit `startDate`, then any pre-existing start date will be removed. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/edit`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)`. + internal enum broadcastRoundUpdate { + internal static let id: Swift.String = "broadcastRoundUpdate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast round ID (8 characters). + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/path/broadcastRoundId`. + internal var broadcastRoundId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastRoundId: The broadcast round ID (8 characters). + internal init(broadcastRoundId: Swift.String) { + self.broadcastRoundId = broadcastRoundId + } + } + internal var path: Operations.broadcastRoundUpdate.Input.Path + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundUpdate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundUpdate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastRoundUpdate.Input.Headers + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Name of the broadcast round. Length must be between 3 and 80 characters. + /// Example: `Round 10` + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String + /// URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. + /// Example: `https://myserver.org/myevent/round-10/games.pgn` + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/syncUrl`. + internal var syncUrl: Swift.String? + /// Required if `syncUrl` contains a livechesscloud link. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/syncUrlRound`. + internal var syncUrlRound: Swift.String? + /// Timestamp in milliseconds of broadcast start. Leave empty to manually start the broadcast. + /// Example: `1356998400070` + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/startsAt`. + internal var startsAt: Swift.Int? + /// Delay in seconds for movements to appear on the broadcast. Leave it empty if you don't need it. + /// Example: `900` (15 min) + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/delay`. + internal var delay: Swift.Int? + /// (Only for Admins) Waiting time for each poll. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/period`. + internal var period: Swift.Int? + /// Mark whether the round has been completed. + /// + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/urlEncodedForm/finished`. + internal var finished: Swift.Bool? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - name: Name of the broadcast round. Length must be between 3 and 80 characters. + /// - syncUrl: URL that Lichess will poll to get updates about the games. It must be publicly accessible from the Internet. + /// - syncUrlRound: Required if `syncUrl` contains a livechesscloud link. + /// - startsAt: Timestamp in milliseconds of broadcast start. Leave empty to manually start the broadcast. + /// - delay: Delay in seconds for movements to appear on the broadcast. Leave it empty if you don't need it. + /// - period: (Only for Admins) Waiting time for each poll. + /// - finished: Mark whether the round has been completed. + internal init( + name: Swift.String, + syncUrl: Swift.String? = nil, + syncUrlRound: Swift.String? = nil, + startsAt: Swift.Int? = nil, + delay: Swift.Int? = nil, + period: Swift.Int? = nil, + finished: Swift.Bool? = nil + ) { + self.name = name + self.syncUrl = syncUrl + self.syncUrlRound = syncUrlRound + self.startsAt = startsAt + self.delay = delay + self.period = period + self.finished = finished + } + internal enum CodingKeys: String, CodingKey { + case name + case syncUrl + case syncUrlRound + case startsAt + case delay + case period + case finished + } + } + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.broadcastRoundUpdate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.broadcastRoundUpdate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.broadcastRoundUpdate.Input.Path, + headers: Operations.broadcastRoundUpdate.Input.Headers = .init(), + body: Operations.broadcastRoundUpdate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastRoundUpdate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundUpdate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastRoundUpdate.Output.Ok.Headers = .init(), + body: Operations.broadcastRoundUpdate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The broadcast round was successfully edited. + /// + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastRoundUpdate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastRoundUpdate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/edit/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundUpdate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastRoundUpdate.Output.BadRequest.Body) { + self.body = body + } + } + /// The edition of the broadcast tournament failed. + /// + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/edit/post(broadcastRoundUpdate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.broadcastRoundUpdate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.broadcastRoundUpdate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Push PGN to your broadcast round + /// + /// Update your broadcast with new PGN. + /// Only for broadcast without a source URL. + /// + /// + /// - Remark: HTTP `POST /broadcast/round/{broadcastRoundId}/push`. + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)`. + internal enum broadcastPush { + internal static let id: Swift.String = "broadcastPush" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast round ID (8 characters). + /// + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/path/broadcastRoundId`. + internal var broadcastRoundId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastRoundId: The broadcast round ID (8 characters). + internal init(broadcastRoundId: Swift.String) { + self.broadcastRoundId = broadcastRoundId + } + } + internal var path: Operations.broadcastPush.Input.Path + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastPush.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastPush.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastPush.Input.Headers + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.broadcastPush.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.broadcastPush.Input.Path, + headers: Operations.broadcastPush.Input.Headers = .init(), + body: Operations.broadcastPush.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastPush.Output.Ok.Headers + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastPgnPush) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastPgnPush { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastPush.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastPush.Output.Ok.Headers = .init(), + body: Operations.broadcastPush.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The broadcast was successfully updated. + /// + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastPush.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastPush.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastPush.Output.BadRequest.Headers + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/content/json/error`. + internal var error: Swift.String? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - error: + internal init(error: Swift.String? = nil) { + self.error = error + } + internal enum CodingKeys: String, CodingKey { + case error + } + } + /// - Remark: Generated from `#/paths/broadcast/round/{broadcastRoundId}/push/POST/responses/400/content/application\/json`. + case json(Operations.broadcastPush.Output.BadRequest.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.broadcastPush.Output.BadRequest.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastPush.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastPush.Output.BadRequest.Headers = .init(), + body: Operations.broadcastPush.Output.BadRequest.Body + ) { + self.headers = headers + self.body = body + } + } + /// There was a problem with the pushed PGN. + /// + /// - Remark: Generated from `#/paths//broadcast/round/{broadcastRoundId}/push/post(broadcastPush)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.broadcastPush.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.broadcastPush.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Stream an ongoing broadcast tournament as PGN + /// + /// This streaming endpoint first sends all games of a broadcast tournament in PGN format. + /// Then, it waits for new moves to be played. As soon as it happens, the entire PGN of the game is sent to the stream. + /// The stream will also send PGNs when games are added to the tournament. + /// This is the best way to get updates about an ongoing tournament. Streaming means no polling, + /// and no pollings means no latency, and minimum impact on the server. + /// + /// + /// - Remark: HTTP `GET /api/stream/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/stream/broadcast/round/{broadcastRoundId}.pgn/get(broadcastStreamRoundPgn)`. + internal enum broadcastStreamRoundPgn { + internal static let id: Swift.String = "broadcastStreamRoundPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast round ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/path/broadcastRoundId`. + internal var broadcastRoundId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastRoundId: The broadcast round ID (8 characters). + internal init(broadcastRoundId: Swift.String) { + self.broadcastRoundId = broadcastRoundId + } + } + internal var path: Operations.broadcastStreamRoundPgn.Input.Path + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastStreamRoundPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastStreamRoundPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastStreamRoundPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastStreamRoundPgn.Input.Path, + headers: Operations.broadcastStreamRoundPgn.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastStreamRoundPgn.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastStreamRoundPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastStreamRoundPgn.Output.Ok.Headers = .init(), + body: Operations.broadcastStreamRoundPgn.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The PGN representation of the tournament games, then the PGNs of games as they are updated. + /// + /// - Remark: Generated from `#/paths//api/stream/broadcast/round/{broadcastRoundId}.pgn/get(broadcastStreamRoundPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastStreamRoundPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastStreamRoundPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Export one round as PGN + /// + /// Download all games of a single round of a broadcast tournament in PGN format. + /// You *could* poll this endpoint to get updates about a tournament, but it would be slow, + /// and very inefficient. + /// Instead, consider [streaming the tournament](#operation/broadcastStreamRoundPgn) to get + /// a new PGN every time a game is updated, in real-time. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/round/{broadcastRoundId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/round/{broadcastRoundId}.pgn/get(broadcastRoundPgn)`. + internal enum broadcastRoundPgn { + internal static let id: Swift.String = "broadcastRoundPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The round ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/path/broadcastRoundId`. + internal var broadcastRoundId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastRoundId: The round ID (8 characters). + internal init(broadcastRoundId: Swift.String) { + self.broadcastRoundId = broadcastRoundId + } + } + internal var path: Operations.broadcastRoundPgn.Input.Path + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastRoundPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastRoundPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastRoundPgn.Input.Path, + headers: Operations.broadcastRoundPgn.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastRoundPgn.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/round/{broadcastRoundId}.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastRoundPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastRoundPgn.Output.Ok.Headers = .init(), + body: Operations.broadcastRoundPgn.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The PGN representation of the round. + /// + /// - Remark: Generated from `#/paths//api/broadcast/round/{broadcastRoundId}.pgn/get(broadcastRoundPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastRoundPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastRoundPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Export all rounds as PGN + /// + /// Download all games of all rounds of a broadcast in PGN format. + /// If a `study:read` [OAuth token](#tag/OAuth) is provided, + /// the private rounds where the user is a contributor will be available. + /// You may want to [download only the games of a single round](#operation/broadcastRoundPgn) instead. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/{broadcastTournamentId}.pgn`. + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}.pgn/get(broadcastAllRoundsPgn)`. + internal enum broadcastAllRoundsPgn { + internal static let id: Swift.String = "broadcastAllRoundsPgn" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/path`. + internal struct Path: Sendable, Hashable { + /// The broadcast tournament ID (8 characters). + /// + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/path/broadcastTournamentId`. + internal var broadcastTournamentId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - broadcastTournamentId: The broadcast tournament ID (8 characters). + internal init(broadcastTournamentId: Swift.String) { + self.broadcastTournamentId = broadcastTournamentId + } + } + internal var path: Operations.broadcastAllRoundsPgn.Input.Path + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastAllRoundsPgn.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastAllRoundsPgn.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastAllRoundsPgn.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.broadcastAllRoundsPgn.Input.Path, + headers: Operations.broadcastAllRoundsPgn.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.broadcastAllRoundsPgn.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/{broadcastTournamentId}.pgn/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastAllRoundsPgn.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.broadcastAllRoundsPgn.Output.Ok.Headers = .init(), + body: Operations.broadcastAllRoundsPgn.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The PGN representation of the broadcast. + /// + /// - Remark: Generated from `#/paths//api/broadcast/{broadcastTournamentId}.pgn/get(broadcastAllRoundsPgn)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastAllRoundsPgn.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastAllRoundsPgn.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Get your broadcast rounds + /// + /// Stream all broadcast rounds you are a member of. + /// Also includes broadcasts rounds you did not create, but were invited to. + /// Also includes broadcasts rounds where you're a non-writing member. See the `writeable` flag in the response. + /// Rounds are ordered by rank, which is roughly chronological, most recent first, slightly pondered with popularity. + /// + /// + /// - Remark: HTTP `GET /api/broadcast/my-rounds`. + /// - Remark: Generated from `#/paths//api/broadcast/my-rounds/get(broadcastMyRoundsGet)`. + internal enum broadcastMyRoundsGet { + internal static let id: Swift.String = "broadcastMyRoundsGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/my-rounds/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many rounds to get + /// + /// - Remark: Generated from `#/paths/api/broadcast/my-rounds/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: How many rounds to get + internal init(nb: Swift.Int? = nil) { + self.nb = nb + } + } + internal var query: Operations.broadcastMyRoundsGet.Input.Query + /// - Remark: Generated from `#/paths/api/broadcast/my-rounds/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastMyRoundsGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.broadcastMyRoundsGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.broadcastMyRoundsGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.broadcastMyRoundsGet.Input.Query = .init(), + headers: Operations.broadcastMyRoundsGet.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/my-rounds/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/broadcast/my-rounds/GET/responses/200/content/application\/json`. + case json(Components.Schemas.BroadcastMyRound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BroadcastMyRound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.broadcastMyRoundsGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.broadcastMyRoundsGet.Output.Ok.Body) { + self.body = body + } + } + /// The broadcast rounds with their tournament and a `study.writeable` flag. + /// + /// - Remark: Generated from `#/paths//api/broadcast/my-rounds/get(broadcastMyRoundsGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.broadcastMyRoundsGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.broadcastMyRoundsGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get current simuls + /// + /// Get recently created, started, finished, simuls. + /// Created and finished simul lists are not exhaustives, only those with + /// strong enough host will be listed, the same filter is used to display simuls on https://lichess.org/simul. + /// When [authenticated with OAuth2](#section/Introduction/Authentication), the pending list will be populated with your created, but unstarted simuls. + /// + /// + /// - Remark: HTTP `GET /api/simul`. + /// - Remark: Generated from `#/paths//api/simul/get(apiSimul)`. + internal enum apiSimul { + internal static let id: Swift.String = "apiSimul" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/simul/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSimul.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiSimul.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiSimul.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiSimul.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiSimul.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/json/pending`. + internal var pending: [Components.Schemas.Simul]? + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/json/created`. + internal var created: [Components.Schemas.Simul]? + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/json/started`. + internal var started: [Components.Schemas.Simul]? + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/json/finished`. + internal var finished: [Components.Schemas.Simul]? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - pending: + /// - created: + /// - started: + /// - finished: + internal init( + pending: [Components.Schemas.Simul]? = nil, + created: [Components.Schemas.Simul]? = nil, + started: [Components.Schemas.Simul]? = nil, + finished: [Components.Schemas.Simul]? = nil + ) { + self.pending = pending + self.created = created + self.started = started + self.finished = finished + } + internal enum CodingKeys: String, CodingKey { + case pending + case created + case started + case finished + } + } + /// - Remark: Generated from `#/paths/api/simul/GET/responses/200/content/application\/json`. + case json(Operations.apiSimul.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.apiSimul.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiSimul.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiSimul.Output.Ok.Headers = .init(), + body: Operations.apiSimul.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of simuls. + /// + /// - Remark: Generated from `#/paths//api/simul/get(apiSimul)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiSimul.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiSimul.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get a single team + /// + /// Public info about a team. Includes the list of publicly visible leaders. + /// + /// - Remark: HTTP `GET /api/team/{teamId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/get(teamShow)`. + internal enum teamShow { + internal static let id: Swift.String = "teamShow" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamShow.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamShow.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamShow.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamShow.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamShow.Input.Path, + headers: Operations.teamShow.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamShow.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.Team) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Team { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamShow.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamShow.Output.Ok.Headers = .init(), + body: Operations.teamShow.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The information about the team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/get(teamShow)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamShow.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamShow.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get popular teams + /// + /// Paginator of the most popular teams. + /// + /// + /// - Remark: HTTP `GET /api/team/all`. + /// - Remark: Generated from `#/paths//api/team/all/get(teamAll)`. + internal enum teamAll { + internal static let id: Swift.String = "teamAll" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/all/GET/query`. + internal struct Query: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/all/GET/query/page`. + internal var page: Swift.Double? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - page: + internal init(page: Swift.Double? = nil) { + self.page = page + } + } + internal var query: Operations.teamAll.Input.Query + /// - Remark: Generated from `#/paths/api/team/all/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamAll.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamAll.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamAll.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.teamAll.Input.Query = .init(), + headers: Operations.teamAll.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/all/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/all/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamAll.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/all/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/all/GET/responses/200/content/application\/json`. + case json(Components.Schemas.TeamPaginatorJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.TeamPaginatorJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamAll.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamAll.Output.Ok.Headers = .init(), + body: Operations.teamAll.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// A paginated list of the most popular teams. + /// + /// - Remark: Generated from `#/paths//api/team/all/get(teamAll)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamAll.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamAll.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Teams of a player + /// + /// All the teams a player is a member of. + /// + /// + /// - Remark: HTTP `GET /api/team/of/{username}`. + /// - Remark: Generated from `#/paths//api/team/of/{username}/get(teamOfUsername)`. + internal enum teamOfUsername { + internal static let id: Swift.String = "teamOfUsername" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.teamOfUsername.Input.Path + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamOfUsername.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamOfUsername.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamOfUsername.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamOfUsername.Input.Path, + headers: Operations.teamOfUsername.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamOfUsername.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/of/{username}/GET/responses/200/content/application\/json`. + case json([Components.Schemas.Team]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.Team] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamOfUsername.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamOfUsername.Output.Ok.Headers = .init(), + body: Operations.teamOfUsername.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of teams the user is a member of. + /// + /// - Remark: Generated from `#/paths//api/team/of/{username}/get(teamOfUsername)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamOfUsername.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamOfUsername.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Search teams + /// + /// Paginator of team search results for a keyword. + /// + /// + /// - Remark: HTTP `GET /api/team/search`. + /// - Remark: Generated from `#/paths//api/team/search/get(teamSearch)`. + internal enum teamSearch { + internal static let id: Swift.String = "teamSearch" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/search/GET/query`. + internal struct Query: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/search/GET/query/text`. + internal var text: Swift.String? + /// - Remark: Generated from `#/paths/api/team/search/GET/query/page`. + internal var page: Swift.Double? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - text: + /// - page: + internal init( + text: Swift.String? = nil, + page: Swift.Double? = nil + ) { + self.text = text + self.page = page + } + } + internal var query: Operations.teamSearch.Input.Query + /// - Remark: Generated from `#/paths/api/team/search/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamSearch.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamSearch.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamSearch.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.teamSearch.Input.Query = .init(), + headers: Operations.teamSearch.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/search/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/search/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamSearch.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/search/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/search/GET/responses/200/content/application\/json`. + case json(Components.Schemas.TeamPaginatorJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.TeamPaginatorJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamSearch.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamSearch.Output.Ok.Headers = .init(), + body: Operations.teamSearch.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The paginated list of teams. + /// + /// - Remark: Generated from `#/paths//api/team/search/get(teamSearch)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamSearch.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamSearch.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get members of a team + /// + /// Members are sorted by reverse chronological order of joining the team (most recent first). + /// OAuth is only required if the list of members is private. + /// Members are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/users`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/users/get(teamIdUsers)`. + internal enum teamIdUsers { + internal static let id: Swift.String = "teamIdUsers" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamIdUsers.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdUsers.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdUsers.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamIdUsers.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamIdUsers.Input.Path, + headers: Operations.teamIdUsers.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamIdUsers.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/users/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdUsers.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamIdUsers.Output.Ok.Headers = .init(), + body: Operations.teamIdUsers.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of users in the team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/users/get(teamIdUsers)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamIdUsers.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamIdUsers.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Get team Arena tournaments + /// + /// Get all Arena tournaments relevant to a team. + /// Tournaments are sorted by reverse chronological order of start date (last starting first). + /// Tournaments are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/team/{teamId}/arena`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/arena/get(apiTeamArena)`. + internal enum apiTeamArena { + internal static let id: Swift.String = "apiTeamArena" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/path`. + internal struct Path: Sendable, Hashable { + /// ID of the team + /// + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: ID of the team + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.apiTeamArena.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many tournaments to download. + /// + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/query/max`. + internal var max: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - max: How many tournaments to download. + internal init(max: Swift.Int? = nil) { + self.max = max + } + } + internal var query: Operations.apiTeamArena.Input.Query + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTeamArena.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiTeamArena.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiTeamArena.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiTeamArena.Input.Path, + query: Operations.apiTeamArena.Input.Query = .init(), + headers: Operations.apiTeamArena.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTeamArena.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/arena/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiTeamArena.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiTeamArena.Output.Ok.Headers = .init(), + body: Operations.apiTeamArena.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of Arena tournaments of a team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/arena/get(apiTeamArena)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiTeamArena.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiTeamArena.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Join a team + /// + /// Join a team. + /// If the team requires a password but the `password` field is incorrect, + /// then the call fails with `403 Forbidden`. + /// Similarly, if the team join policy requires a confirmation but the + /// `message` parameter is not given, then the call fails with + /// `403 Forbidden`. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/join`. + /// - Remark: Generated from `#/paths//team/{teamId}/join/post(teamIdJoin)`. + internal enum teamIdJoin { + internal static let id: Swift.String = "teamIdJoin" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamIdJoin.Input.Path + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdJoin.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdJoin.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamIdJoin.Input.Headers + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Optional request message, if the team requires one. + /// + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/requestBody/urlEncodedForm/message`. + internal var message: Swift.String? + /// Optional password, if the team requires one. + /// + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/requestBody/urlEncodedForm/password`. + internal var password: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - message: Optional request message, if the team requires one. + /// - password: Optional password, if the team requires one. + internal init( + message: Swift.String? = nil, + password: Swift.String? = nil + ) { + self.message = message + self.password = password + } + internal enum CodingKeys: String, CodingKey { + case message + case password + } + } + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.teamIdJoin.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.teamIdJoin.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.teamIdJoin.Input.Path, + headers: Operations.teamIdJoin.Input.Headers = .init(), + body: Operations.teamIdJoin.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/join/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdJoin.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamIdJoin.Output.Ok.Body) { + self.body = body + } + } + /// The request to join a team was successfully sent. + /// + /// - Remark: Generated from `#/paths//team/{teamId}/join/post(teamIdJoin)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamIdJoin.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamIdJoin.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Leave a team + /// + /// Leave a team. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/quit`. + /// - Remark: Generated from `#/paths//team/{teamId}/quit/post(teamIdQuit)`. + internal enum teamIdQuit { + internal static let id: Swift.String = "teamIdQuit" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/quit/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/quit/POST/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamIdQuit.Input.Path + /// - Remark: Generated from `#/paths/team/{teamId}/quit/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdQuit.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdQuit.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamIdQuit.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamIdQuit.Input.Path, + headers: Operations.teamIdQuit.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/quit/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/quit/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdQuit.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamIdQuit.Output.Ok.Body) { + self.body = body + } + } + /// The logged in user has successfully left the team. + /// + /// - Remark: Generated from `#/paths//team/{teamId}/quit/post(teamIdQuit)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamIdQuit.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamIdQuit.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get join requests + /// + /// Get pending join requests of your team + /// + /// - Remark: HTTP `GET /api/team/{teamId}/requests`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/requests/get(teamRequests)`. + internal enum teamRequests { + internal static let id: Swift.String = "teamRequests" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamRequests.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/query`. + internal struct Query: Sendable, Hashable { + /// Get the declined join requests + /// + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/query/declined`. + internal var declined: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - declined: Get the declined join requests + internal init(declined: Swift.Bool? = nil) { + self.declined = declined + } + } + internal var query: Operations.teamRequests.Input.Query + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequests.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequests.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamRequests.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.teamRequests.Input.Path, + query: Operations.teamRequests.Input.Query = .init(), + headers: Operations.teamRequests.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/requests/GET/responses/200/content/application\/json`. + case json([Components.Schemas.TeamRequestWithUser]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.TeamRequestWithUser] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamRequests.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamRequests.Output.Ok.Body) { + self.body = body + } + } + /// The list of pending join requests on your team + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/requests/get(teamRequests)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamRequests.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamRequests.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Accept join request + /// + /// Accept someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/accept`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/accept/post(teamRequestAccept)`. + internal enum teamRequestAccept { + internal static let id: Swift.String = "teamRequestAccept" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/path/teamId`. + internal var teamId: Swift.String + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/path/userId`. + internal var userId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + /// - userId: + internal init( + teamId: Swift.String, + userId: Swift.String + ) { + self.teamId = teamId + self.userId = userId + } + } + internal var path: Operations.teamRequestAccept.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequestAccept.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequestAccept.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamRequestAccept.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamRequestAccept.Input.Path, + headers: Operations.teamRequestAccept.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/accept/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamRequestAccept.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamRequestAccept.Output.Ok.Body) { + self.body = body + } + } + /// The member has been added to the team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/accept/post(teamRequestAccept)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamRequestAccept.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamRequestAccept.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Decline join request + /// + /// Decline someone's request to join your team + /// + /// - Remark: HTTP `POST /api/team/{teamId}/request/{userId}/decline`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/decline/post(teamRequestDecline)`. + internal enum teamRequestDecline { + internal static let id: Swift.String = "teamRequestDecline" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/path/teamId`. + internal var teamId: Swift.String + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/path/userId`. + internal var userId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + /// - userId: + internal init( + teamId: Swift.String, + userId: Swift.String + ) { + self.teamId = teamId + self.userId = userId + } + } + internal var path: Operations.teamRequestDecline.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequestDecline.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamRequestDecline.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamRequestDecline.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamRequestDecline.Input.Path, + headers: Operations.teamRequestDecline.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/request/{userId}/decline/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamRequestDecline.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamRequestDecline.Output.Ok.Body) { + self.body = body + } + } + /// The join request has been declined and is no longer pending. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/request/{userId}/decline/post(teamRequestDecline)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamRequestDecline.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamRequestDecline.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Kick a user from your team + /// + /// Kick a member out of one of your teams. + /// - <https://lichess.org/team> + /// + /// + /// - Remark: HTTP `POST /api/team/{teamId}/kick/{userId}`. + /// - Remark: Generated from `#/paths//api/team/{teamId}/kick/{userId}/post(teamIdKickUserId)`. + internal enum teamIdKickUserId { + internal static let id: Swift.String = "teamIdKickUserId" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/path/teamId`. + internal var teamId: Swift.String + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/path/userId`. + internal var userId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + /// - userId: + internal init( + teamId: Swift.String, + userId: Swift.String + ) { + self.teamId = teamId + self.userId = userId + } + } + internal var path: Operations.teamIdKickUserId.Input.Path + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdKickUserId.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdKickUserId.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamIdKickUserId.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.teamIdKickUserId.Input.Path, + headers: Operations.teamIdKickUserId.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/team/{teamId}/kick/{userId}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdKickUserId.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamIdKickUserId.Output.Ok.Body) { + self.body = body + } + } + /// The member has been kicked from the team. + /// + /// - Remark: Generated from `#/paths//api/team/{teamId}/kick/{userId}/post(teamIdKickUserId)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamIdKickUserId.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamIdKickUserId.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Message all members + /// + /// Send a private message to all members of a team. + /// You must be a team leader with the "Messages" permission. + /// + /// + /// - Remark: HTTP `POST /team/{teamId}/pm-all`. + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)`. + internal enum teamIdPmAll { + internal static let id: Swift.String = "teamIdPmAll" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/path/teamId`. + internal var teamId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - teamId: + internal init(teamId: Swift.String) { + self.teamId = teamId + } + } + internal var path: Operations.teamIdPmAll.Input.Path + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdPmAll.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.teamIdPmAll.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.teamIdPmAll.Input.Headers + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The message to send to all your team members. + /// + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/requestBody/urlEncodedForm/message`. + internal var message: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - message: The message to send to all your team members. + internal init(message: Swift.String? = nil) { + self.message = message + } + internal enum CodingKeys: String, CodingKey { + case message + } + } + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.teamIdPmAll.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.teamIdPmAll.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.teamIdPmAll.Input.Path, + headers: Operations.teamIdPmAll.Input.Headers = .init(), + body: Operations.teamIdPmAll.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.teamIdPmAll.Output.Ok.Headers + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdPmAll.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.teamIdPmAll.Output.Ok.Headers = .init(), + body: Operations.teamIdPmAll.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The message has successfully been sent to all team members. + /// + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.teamIdPmAll.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.teamIdPmAll.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/team/{teamId}/pm-all/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.teamIdPmAll.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.teamIdPmAll.Output.BadRequest.Body) { + self.body = body + } + } + /// The sending of message to all team members has failed. + /// + /// - Remark: Generated from `#/paths//team/{teamId}/pm-all/post(teamIdPmAll)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.teamIdPmAll.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.teamIdPmAll.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get live streamers + /// + /// Get basic info about currently streaming users. + /// This API is very fast and cheap on lichess side. + /// So you can call it quite often (like once every 5 seconds). + /// + /// + /// - Remark: HTTP `GET /api/streamer/live`. + /// - Remark: Generated from `#/paths//api/streamer/live/get(streamerLive)`. + internal enum streamerLive { + internal static let id: Swift.String = "streamerLive" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/streamer/live/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.streamerLive.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.streamerLive.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.streamerLive.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.streamerLive.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/streamer/live/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/streamer/live/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.streamerLive.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/streamer/live/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/streamer/live/GET/responses/200/content/application\/json`. + case json([Components.Schemas.LightUser]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.LightUser] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.streamerLive.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.streamerLive.Output.Ok.Headers = .init(), + body: Operations.streamerLive.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of live streamers and their respective information. + /// + /// - Remark: Generated from `#/paths//api/streamer/live/get(streamerLive)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.streamerLive.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.streamerLive.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get crosstable + /// + /// Get total number of games, and current score, of any two users. + /// If the `matchup` flag is provided, and the users are currently playing, also gets the current match game number and scores. + /// + /// + /// - Remark: HTTP `GET /api/crosstable/{user1}/{user2}`. + /// - Remark: Generated from `#/paths//api/crosstable/{user1}/{user2}/get(apiCrosstable)`. + internal enum apiCrosstable { + internal static let id: Swift.String = "apiCrosstable" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/path/user1`. + internal var user1: Swift.String + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/path/user2`. + internal var user2: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - user1: + /// - user2: + internal init( + user1: Swift.String, + user2: Swift.String + ) { + self.user1 = user1 + self.user2 = user2 + } + } + internal var path: Operations.apiCrosstable.Input.Path + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/query`. + internal struct Query: Sendable, Hashable { + /// Whether to get the current match data, if any + /// + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/query/matchup`. + internal var matchup: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - matchup: Whether to get the current match data, if any + internal init(matchup: Swift.Bool? = nil) { + self.matchup = matchup + } + } + internal var query: Operations.apiCrosstable.Input.Query + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiCrosstable.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiCrosstable.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiCrosstable.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.apiCrosstable.Input.Path, + query: Operations.apiCrosstable.Input.Query = .init(), + headers: Operations.apiCrosstable.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiCrosstable.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/crosstable/{user1}/{user2}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.Crosstable) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Crosstable { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiCrosstable.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiCrosstable.Output.Ok.Headers = .init(), + body: Operations.apiCrosstable.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The crosstable of the two users. + /// + /// - Remark: Generated from `#/paths//api/crosstable/{user1}/{user2}/get(apiCrosstable)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiCrosstable.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiCrosstable.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Autocomplete usernames + /// + /// Provides autocompletion options for an incomplete username. + /// + /// + /// - Remark: HTTP `GET /api/player/autocomplete`. + /// - Remark: Generated from `#/paths//api/player/autocomplete/get(apiPlayerAutocomplete)`. + internal enum apiPlayerAutocomplete { + internal static let id: Swift.String = "apiPlayerAutocomplete" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/query`. + internal struct Query: Sendable, Hashable { + /// The beginning of a username + /// + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/query/term`. + internal var term: Swift.String + /// - `false` returns an array of usernames + /// - `true` returns an object with matching users + /// + /// + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/query/object`. + internal var object: Swift.Bool? + /// Returns followed players matching `term` if any, else returns other players. + /// Requires [OAuth](#tag/OAuth). + /// + /// + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/query/friend`. + internal var friend: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - term: The beginning of a username + /// - object: + /// - friend: Returns followed players matching `term` if any, else returns other players. + internal init( + term: Swift.String, + object: Swift.Bool? = nil, + friend: Swift.Bool? = nil + ) { + self.term = term + self.object = object + self.friend = friend + } + } + internal var query: Operations.apiPlayerAutocomplete.Input.Query + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPlayerAutocomplete.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiPlayerAutocomplete.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiPlayerAutocomplete.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiPlayerAutocomplete.Input.Query, + headers: Operations.apiPlayerAutocomplete.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiPlayerAutocomplete.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/json`. + @frozen internal enum jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/json/case1`. + case case1([Swift.String]) + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/json/case2`. + internal struct Case2Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/json/case2/result`. + internal var result: [Components.Schemas.LightUserOnline]? + /// Creates a new `Case2Payload`. + /// + /// - Parameters: + /// - result: + internal init(result: [Components.Schemas.LightUserOnline]? = nil) { + self.result = result + } + internal enum CodingKeys: String, CodingKey { + case result + } + } + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/json/case2`. + case case2(Operations.apiPlayerAutocomplete.Output.Ok.Body.jsonPayload.Case2Payload) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .case1(try decoder.decodeFromSingleValueContainer()) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .case1(value): + try encoder.encodeToSingleValueContainer(value) + case let .case2(value): + try value.encode(to: encoder) + } + } + } + /// - Remark: Generated from `#/paths/api/player/autocomplete/GET/responses/200/content/application\/json`. + case json(Operations.apiPlayerAutocomplete.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.apiPlayerAutocomplete.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiPlayerAutocomplete.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiPlayerAutocomplete.Output.Ok.Headers = .init(), + body: Operations.apiPlayerAutocomplete.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// An array of players which usernames start with the provided term. + /// + /// - Remark: Generated from `#/paths//api/player/autocomplete/get(apiPlayerAutocomplete)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiPlayerAutocomplete.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiPlayerAutocomplete.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get notes for a user + /// + /// Get the private notes that you have added for a user. + /// + /// + /// - Remark: HTTP `GET /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/get(readNote)`. + internal enum readNote { + internal static let id: Swift.String = "readNote" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.readNote.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.readNote.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.readNote.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.readNote.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.readNote.Input.Path, + headers: Operations.readNote.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.readNote.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/GET/responses/200/content/application\/json`. + case json([Components.Schemas.UserNote]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.UserNote] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.readNote.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.readNote.Output.Ok.Headers = .init(), + body: Operations.readNote.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of notes you have added for this user + /// + /// - Remark: Generated from `#/paths//api/user/{username}/note/get(readNote)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.readNote.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.readNote.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Add a note for a user + /// + /// Add a private note available only to you about this account. + /// + /// + /// - Remark: HTTP `POST /api/user/{username}/note`. + /// - Remark: Generated from `#/paths//api/user/{username}/note/post(writeNote)`. + internal enum writeNote { + internal static let id: Swift.String = "writeNote" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.writeNote.Input.Path + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.writeNote.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.writeNote.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.writeNote.Input.Headers + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// The contents of the note + /// + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/requestBody/urlEncodedForm/text`. + internal var text: Swift.String + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - text: The contents of the note + internal init(text: Swift.String) { + self.text = text + } + internal enum CodingKeys: String, CodingKey { + case text + } + } + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.writeNote.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.writeNote.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.writeNote.Input.Path, + headers: Operations.writeNote.Input.Headers = .init(), + body: Operations.writeNote.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/user/{username}/note/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.writeNote.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.writeNote.Output.Ok.Body) { + self.body = body + } + } + /// The note was successfully added. + /// + /// - Remark: Generated from `#/paths//api/user/{username}/note/post(writeNote)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.writeNote.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.writeNote.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get users followed by the logged in user + /// + /// Users are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// + /// - Remark: HTTP `GET /api/rel/following`. + /// - Remark: Generated from `#/paths//api/rel/following/get(apiUserFollowing)`. + internal enum apiUserFollowing { + internal static let id: Swift.String = "apiUserFollowing" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/following/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserFollowing.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiUserFollowing.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiUserFollowing.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiUserFollowing.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/following/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/following/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiUserFollowing.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/rel/following/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/following/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiUserFollowing.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiUserFollowing.Output.Ok.Headers = .init(), + body: Operations.apiUserFollowing.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of users followed by a user. + /// + /// - Remark: Generated from `#/paths//api/rel/following/get(apiUserFollowing)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiUserFollowing.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiUserFollowing.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Follow a player + /// + /// Follow a player, adding them to your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/follow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/follow/{username}/post(followUser)`. + internal enum followUser { + internal static let id: Swift.String = "followUser" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/follow/{username}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/follow/{username}/POST/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.followUser.Input.Path + /// - Remark: Generated from `#/paths/api/rel/follow/{username}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.followUser.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.followUser.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.followUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.followUser.Input.Path, + headers: Operations.followUser.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/follow/{username}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/follow/{username}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.followUser.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.followUser.Output.Ok.Body) { + self.body = body + } + } + /// The player was successfully added. + /// + /// - Remark: Generated from `#/paths//api/rel/follow/{username}/post(followUser)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.followUser.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.followUser.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Unfollow a player + /// + /// Unfollow a player, removing them from your list of Lichess friends. + /// + /// + /// - Remark: HTTP `POST /api/rel/unfollow/{username}`. + /// - Remark: Generated from `#/paths//api/rel/unfollow/{username}/post(unfollowUser)`. + internal enum unfollowUser { + internal static let id: Swift.String = "unfollowUser" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/unfollow/{username}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/unfollow/{username}/POST/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.unfollowUser.Input.Path + /// - Remark: Generated from `#/paths/api/rel/unfollow/{username}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.unfollowUser.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.unfollowUser.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.unfollowUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.unfollowUser.Input.Path, + headers: Operations.unfollowUser.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/unfollow/{username}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/rel/unfollow/{username}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.unfollowUser.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.unfollowUser.Output.Ok.Body) { + self.body = body + } + } + /// The player was successfully removed. + /// + /// - Remark: Generated from `#/paths//api/rel/unfollow/{username}/post(unfollowUser)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.unfollowUser.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.unfollowUser.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Stream incoming events + /// + /// + /// Stream the events reaching a lichess user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// An empty line is sent every 6 seconds for keep alive purposes. + /// + /// Each non-empty line is a JSON object containing a `type` field. Possible values are: + /// - `gameStart` Start of a game + /// - `gameFinish` Completion of a game + /// - `challenge` A player sends you a challenge or you challenge someone + /// - `challengeCanceled` A player cancels their challenge to you + /// - `challengeDeclined` The opponent declines your challenge + /// + /// When the stream opens, all current challenges and games are sent. + /// + /// - Remark: HTTP `GET /api/stream/event`. + /// - Remark: Generated from `#/paths//api/stream/event/get(apiStreamEvent)`. + internal enum apiStreamEvent { + internal static let id: Swift.String = "apiStreamEvent" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/event/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStreamEvent.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiStreamEvent.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiStreamEvent.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiStreamEvent.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/event/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/event/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiStreamEvent.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/stream/event/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/stream/event/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiStreamEvent.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiStreamEvent.Output.Ok.Headers = .init(), + body: Operations.apiStreamEvent.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The stream of events reaching the logged in user. + /// + /// - Remark: Generated from `#/paths//api/stream/event/get(apiStreamEvent)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiStreamEvent.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiStreamEvent.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Create a seek + /// + /// + /// Create a public seek, to start a game with a random player. + /// + /// ### Real-time seek + /// + /// Specify the `time` and `increment` clock values. The response is streamed but doesn't contain any information. + /// + /// **Keep the connection open to keep the seek active**. + /// + /// If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. + /// When the seek is accepted, or expires, the server closes the connection. + /// + /// **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. + /// We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, + /// you won't miss the game event if the seek is accepted immediately. + /// + /// ### Correspondence seek + /// + /// Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone. + /// + /// - Remark: HTTP `POST /api/board/seek`. + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)`. + internal enum apiBoardSeek { + internal static let id: Swift.String = "apiBoardSeek" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiBoardSeek.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiBoardSeek.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiBoardSeek.Input.Headers + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Whether the game is rated and impacts players ratings. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// Clock initial time in minutes. Required for real-time seeks. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/time`. + internal var time: Swift.Double? + /// Clock increment in seconds. Required for real-time seeks. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/increment`. + internal var increment: Swift.Int? + /// Days per turn. Required for correspondence seeks. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/days`. + @frozen internal enum daysPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _7 = 7 + case _10 = 10 + case _14 = 14 + } + /// Days per turn. Required for correspondence seeks. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/days`. + internal var days: Operations.apiBoardSeek.Input.Body.urlEncodedFormPayload.daysPayload? + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// The color to play. Better left empty to automatically get 50% white. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/color`. + @frozen internal enum colorPayload: String, Codable, Hashable, Sendable { + case random = "random" + case white = "white" + case black = "black" + } + /// The color to play. Better left empty to automatically get 50% white. + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/color`. + internal var color: Operations.apiBoardSeek.Input.Body.urlEncodedFormPayload.colorPayload? + /// The rating range of potential opponents. Better left empty. + /// Example: 1500-1800 + /// + /// + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/urlEncodedForm/ratingRange`. + internal var ratingRange: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - rated: Whether the game is rated and impacts players ratings. + /// - time: Clock initial time in minutes. Required for real-time seeks. + /// - increment: Clock increment in seconds. Required for real-time seeks. + /// - days: Days per turn. Required for correspondence seeks. + /// - variant: + /// - color: The color to play. Better left empty to automatically get 50% white. + /// - ratingRange: The rating range of potential opponents. Better left empty. + internal init( + rated: Swift.Bool? = nil, + time: Swift.Double? = nil, + increment: Swift.Int? = nil, + days: Operations.apiBoardSeek.Input.Body.urlEncodedFormPayload.daysPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + color: Operations.apiBoardSeek.Input.Body.urlEncodedFormPayload.colorPayload? = nil, + ratingRange: Swift.String? = nil + ) { + self.rated = rated + self.time = time + self.increment = increment + self.days = days + self.variant = variant + self.color = color + self.ratingRange = ratingRange + } + internal enum CodingKeys: String, CodingKey { + case rated + case time + case increment + case days + case variant + case color + case ratingRange + } + } + /// - Remark: Generated from `#/paths/api/board/seek/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiBoardSeek.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiBoardSeek.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiBoardSeek.Input.Headers = .init(), + body: Operations.apiBoardSeek.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiBoardSeek.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/200/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.plainText`. + /// + /// - Throws: An error if `self` is not `.plainText`. + /// - SeeAlso: `.plainText`. + internal var plainText: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .plainText(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiBoardSeek.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiBoardSeek.Output.Ok.Headers = .init(), + body: Operations.apiBoardSeek.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The seek was successfully created. + /// + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiBoardSeek.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiBoardSeek.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/seek/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiBoardSeek.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiBoardSeek.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the seek failed. + /// + /// - Remark: Generated from `#/paths//api/board/seek/post(apiBoardSeek)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiBoardSeek.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiBoardSeek.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case plainText + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "text/plain": + self = .plainText + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .plainText: + return "text/plain" + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .plainText, + .json + ] + } + } + } + /// Stream Board game state + /// + /// Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, a draw is offered, or when the game ends. + /// - `chatLine` Chat message sent by a user in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// + /// The server closes the stream when the game ends, or if the game has already ended. + /// + /// - Remark: HTTP `GET /api/board/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)`. + internal enum boardGameStream { + internal static let id: Swift.String = "boardGameStream" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameStream.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameStream.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameStream.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameStream.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameStream.Input.Path, + headers: Operations.boardGameStream.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameStream.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameStream.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameStream.Output.Ok.Headers = .init(), + body: Operations.boardGameStream.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The stream of the game. + /// + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameStream.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameStream.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/stream/{gameId}/GET/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameStream.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameStream.Output.NotFound.Body) { + self.body = body + } + } + /// The game was not found. + /// + /// - Remark: Generated from `#/paths//api/board/game/stream/{gameId}/get(boardGameStream)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.boardGameStream.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.boardGameStream.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson, + .json + ] + } + } + } + /// Make a Board move + /// + /// Make a move in a game being played with the Board API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)`. + internal enum boardGameMove { + internal static let id: Swift.String = "boardGameMove" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/path/gameId`. + internal var gameId: Swift.String + /// The move to play, in UCI format + /// + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/path/move`. + internal var move: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - move: The move to play, in UCI format + internal init( + gameId: Swift.String, + move: Swift.String + ) { + self.gameId = gameId + self.move = move + } + } + internal var path: Operations.boardGameMove.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/query`. + internal struct Query: Sendable, Hashable { + /// Whether to offer (or agree to) a draw + /// + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/query/offeringDraw`. + internal var offeringDraw: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - offeringDraw: Whether to offer (or agree to) a draw + internal init(offeringDraw: Swift.Bool? = nil) { + self.offeringDraw = offeringDraw + } + } + internal var query: Operations.boardGameMove.Input.Query + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameMove.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameMove.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameMove.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.boardGameMove.Input.Path, + query: Operations.boardGameMove.Input.Query = .init(), + headers: Operations.boardGameMove.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameMove.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameMove.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameMove.Output.Ok.Headers = .init(), + body: Operations.boardGameMove.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The move was successfully made. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameMove.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameMove.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/move/{move}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameMove.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameMove.Output.BadRequest.Body) { + self.body = body + } + } + /// The move failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/move/{move}/post(boardGameMove)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameMove.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameMove.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/get(boardGameChatGet)`. + internal enum boardGameChatGet { + internal static let id: Swift.String = "boardGameChatGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameChatGet.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameChatGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameChatGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameChatGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameChatGet.Input.Path, + headers: Operations.boardGameChatGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameChatGet.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameChatGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameChatGet.Output.Ok.Headers = .init(), + body: Operations.boardGameChatGet.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The messages posted in the chat. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/get(boardGameChatGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameChatGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameChatGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)`. + internal enum boardGameChatPost { + internal static let id: Swift.String = "boardGameChatPost" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameChatPost.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameChatPost.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameChatPost.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameChatPost.Input.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody/urlEncodedForm/room`. + @frozen internal enum roomPayload: String, Codable, Hashable, Sendable { + case player = "player" + case spectator = "spectator" + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody/urlEncodedForm/room`. + internal var room: Operations.boardGameChatPost.Input.Body.urlEncodedFormPayload.roomPayload + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody/urlEncodedForm/text`. + internal var text: Swift.String + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - room: + /// - text: + internal init( + room: Operations.boardGameChatPost.Input.Body.urlEncodedFormPayload.roomPayload, + text: Swift.String + ) { + self.room = room + self.text = text + } + internal enum CodingKeys: String, CodingKey { + case room + case text + } + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.boardGameChatPost.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.boardGameChatPost.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.boardGameChatPost.Input.Path, + headers: Operations.boardGameChatPost.Input.Headers = .init(), + body: Operations.boardGameChatPost.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameChatPost.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameChatPost.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameChatPost.Output.Ok.Headers = .init(), + body: Operations.boardGameChatPost.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The message was successfully posted in the chat. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameChatPost.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameChatPost.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/chat/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameChatPost.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameChatPost.Output.BadRequest.Body) { + self.body = body + } + } + /// The posting of the message in the chat failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/chat/post(boardGameChatPost)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameChatPost.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameChatPost.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Abort a game + /// + /// Abort a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)`. + internal enum boardGameAbort { + internal static let id: Swift.String = "boardGameAbort" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameAbort.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameAbort.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameAbort.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameAbort.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameAbort.Input.Path, + headers: Operations.boardGameAbort.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameAbort.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameAbort.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameAbort.Output.Ok.Headers = .init(), + body: Operations.boardGameAbort.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game successfully aborted. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameAbort.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameAbort.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/abort/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameAbort.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameAbort.Output.BadRequest.Body) { + self.body = body + } + } + /// The abortion of the game failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/abort/post(boardGameAbort)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameAbort.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameAbort.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Resign a game + /// + /// Resign a game being played with the Board API. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)`. + internal enum boardGameResign { + internal static let id: Swift.String = "boardGameResign" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameResign.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameResign.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameResign.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameResign.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameResign.Input.Path, + headers: Operations.boardGameResign.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameResign.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameResign.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameResign.Output.Ok.Headers = .init(), + body: Operations.boardGameResign.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game was successfully resigned. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameResign.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameResign.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/resign/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameResign.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameResign.Output.BadRequest.Body) { + self.body = body + } + } + /// The resigning from the game failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/resign/post(boardGameResign)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameResign.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameResign.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)`. + internal enum boardGameDraw { + internal static let id: Swift.String = "boardGameDraw" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/gameId`. + internal var gameId: Swift.String + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/accept`. + internal struct acceptPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/accept/value1`. + internal var value1: Swift.Bool? + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/accept/value2`. + @frozen internal enum Value2Payload: String, Codable, Hashable, Sendable { + case yes = "yes" + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/accept/value2`. + internal var value2: Operations.boardGameDraw.Input.Path.acceptPayload.Value2Payload? + /// Creates a new `acceptPayload`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Swift.Bool? = nil, + value2: Operations.boardGameDraw.Input.Path.acceptPayload.Value2Payload? = nil + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + value1 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + do { + value2 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil( + [ + value1, + value2 + ], + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeFirstNonNilValueToSingleValueContainer([ + value1, + value2 + ]) + } + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/path/accept`. + internal var accept: Operations.boardGameDraw.Input.Path.acceptPayload + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - accept: + internal init( + gameId: Swift.String, + accept: Operations.boardGameDraw.Input.Path.acceptPayload + ) { + self.gameId = gameId + self.accept = accept + } + } + internal var path: Operations.boardGameDraw.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameDraw.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameDraw.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameDraw.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameDraw.Input.Path, + headers: Operations.boardGameDraw.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameDraw.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameDraw.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameDraw.Output.Ok.Headers = .init(), + body: Operations.boardGameDraw.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The draw offer was successfully sent. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameDraw.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameDraw.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/draw/{accept}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameDraw.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameDraw.Output.BadRequest.Body) { + self.body = body + } + } + /// The draw offering failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/draw/{accept}/post(boardGameDraw)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameDraw.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameDraw.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)`. + internal enum boardGameTakeback { + internal static let id: Swift.String = "boardGameTakeback" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/gameId`. + internal var gameId: Swift.String + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/accept`. + internal struct acceptPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/accept/value1`. + internal var value1: Swift.Bool? + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/accept/value2`. + @frozen internal enum Value2Payload: String, Codable, Hashable, Sendable { + case yes = "yes" + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/accept/value2`. + internal var value2: Operations.boardGameTakeback.Input.Path.acceptPayload.Value2Payload? + /// Creates a new `acceptPayload`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Swift.Bool? = nil, + value2: Operations.boardGameTakeback.Input.Path.acceptPayload.Value2Payload? = nil + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + value1 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + do { + value2 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil( + [ + value1, + value2 + ], + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeFirstNonNilValueToSingleValueContainer([ + value1, + value2 + ]) + } + } + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/path/accept`. + internal var accept: Operations.boardGameTakeback.Input.Path.acceptPayload + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - accept: + internal init( + gameId: Swift.String, + accept: Operations.boardGameTakeback.Input.Path.acceptPayload + ) { + self.gameId = gameId + self.accept = accept + } + } + internal var path: Operations.boardGameTakeback.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameTakeback.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameTakeback.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameTakeback.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameTakeback.Input.Path, + headers: Operations.boardGameTakeback.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameTakeback.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameTakeback.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameTakeback.Output.Ok.Headers = .init(), + body: Operations.boardGameTakeback.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The takeback offer was successfully sent. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameTakeback.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameTakeback.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/takeback/{accept}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameTakeback.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameTakeback.Output.BadRequest.Body) { + self.body = body + } + } + /// The takeback offering failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/takeback/{accept}/post(boardGameTakeback)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameTakeback.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameTakeback.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Claim victory of a game + /// + /// Claim victory when the opponent has left the game for a while. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/claim-victory`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)`. + internal enum boardGameClaimVictory { + internal static let id: Swift.String = "boardGameClaimVictory" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameClaimVictory.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameClaimVictory.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameClaimVictory.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameClaimVictory.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameClaimVictory.Input.Path, + headers: Operations.boardGameClaimVictory.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameClaimVictory.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameClaimVictory.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameClaimVictory.Output.Ok.Headers = .init(), + body: Operations.boardGameClaimVictory.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The victory was successfully claimed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameClaimVictory.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameClaimVictory.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/claim-victory/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameClaimVictory.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameClaimVictory.Output.BadRequest.Body) { + self.body = body + } + } + /// The victory claim has failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/claim-victory/post(boardGameClaimVictory)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameClaimVictory.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameClaimVictory.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Berserk a tournament game + /// + /// Go berserk on an arena tournament game. Halves the clock time, grants an extra point upon winning. + /// Only available in arena tournaments that allow berserk, and before each player has made a move. + /// + /// + /// - Remark: HTTP `POST /api/board/game/{gameId}/berserk`. + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)`. + internal enum boardGameBerserk { + internal static let id: Swift.String = "boardGameBerserk" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.boardGameBerserk.Input.Path + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameBerserk.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.boardGameBerserk.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.boardGameBerserk.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.boardGameBerserk.Input.Path, + headers: Operations.boardGameBerserk.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.boardGameBerserk.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameBerserk.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.boardGameBerserk.Output.Ok.Headers = .init(), + body: Operations.boardGameBerserk.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The player successfully whent berserk. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.boardGameBerserk.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.boardGameBerserk.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/board/game/{gameId}/berserk/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.boardGameBerserk.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.boardGameBerserk.Output.BadRequest.Body) { + self.body = body + } + } + /// The berserk has failed. + /// + /// - Remark: Generated from `#/paths//api/board/game/{gameId}/berserk/post(boardGameBerserk)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.boardGameBerserk.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.boardGameBerserk.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get online bots + /// + /// Stream the [online bot users](https://lichess.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second. + /// + /// - Remark: HTTP `GET /api/bot/online`. + /// - Remark: Generated from `#/paths//api/bot/online/get(apiBotOnline)`. + internal enum apiBotOnline { + internal static let id: Swift.String = "apiBotOnline" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/online/GET/query`. + internal struct Query: Sendable, Hashable { + /// How many bot users to fetch + /// + /// - Remark: Generated from `#/paths/api/bot/online/GET/query/nb`. + internal var nb: Swift.Int? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - nb: How many bot users to fetch + internal init(nb: Swift.Int? = nil) { + self.nb = nb + } + } + internal var query: Operations.apiBotOnline.Input.Query + /// - Remark: Generated from `#/paths/api/bot/online/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiBotOnline.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiBotOnline.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiBotOnline.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiBotOnline.Input.Query = .init(), + headers: Operations.apiBotOnline.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/online/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/online/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiBotOnline.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/online/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/online/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiBotOnline.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiBotOnline.Output.Ok.Headers = .init(), + body: Operations.apiBotOnline.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of online bot users + /// + /// - Remark: Generated from `#/paths//api/bot/online/get(apiBotOnline)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiBotOnline.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiBotOnline.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Upgrade to Bot account + /// + /// Upgrade a lichess player account into a Bot account. Only Bot accounts can use the Bot API. + /// The account **cannot have played any game** before becoming a Bot account. The upgrade is **irreversible**. The account will only be able to play as a Bot. + /// To upgrade an account to Bot, use the [official lichess-bot client](https://github.com/lichess-bot-devs/lichess-bot), or follow these steps: + /// - Create an [API access token](https://lichess.org/account/oauth/token/create?scopes[]=bot:play) with "Play bot moves" permission. + /// - `curl -d '' https://lichess.org/api/bot/account/upgrade -H "Authorization: Bearer <yourTokenHere>"` + /// To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): + /// the `title` field should be set to `BOT`. + /// + /// + /// - Remark: HTTP `POST /api/bot/account/upgrade`. + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)`. + internal enum botAccountUpgrade { + internal static let id: Swift.String = "botAccountUpgrade" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botAccountUpgrade.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botAccountUpgrade.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botAccountUpgrade.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.botAccountUpgrade.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botAccountUpgrade.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botAccountUpgrade.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botAccountUpgrade.Output.Ok.Headers = .init(), + body: Operations.botAccountUpgrade.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The bot account was successfully upgraded. + /// + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botAccountUpgrade.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botAccountUpgrade.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/account/upgrade/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botAccountUpgrade.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botAccountUpgrade.Output.BadRequest.Body) { + self.body = body + } + } + /// The upgrade of the bot account failed. + /// + /// - Remark: Generated from `#/paths//api/bot/account/upgrade/post(botAccountUpgrade)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botAccountUpgrade.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botAccountUpgrade.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Stream Bot game state + /// + /// Stream the state of a game being played with the Bot API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// + /// Use this endpoint to get updates about the game in real-time, with a single request. + /// + /// Each line is a JSON object containing a `type` field. Possible values are: + /// - `gameFull` Full game data. All values are immutable, except for the `state` field. + /// - `gameState` Current state of the game. Immutable values not included. + /// - `chatLine` Chat message sent by a user (or the bot itself) in the `room` "player" or "spectator". + /// + /// - `opponentGone` Whether the opponent has left the game, and how long before you can claim a win or draw. + /// + /// + /// The first line is always of type `gameFull`. + /// + /// - Remark: HTTP `GET /api/bot/game/stream/{gameId}`. + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)`. + internal enum botGameStream { + internal static let id: Swift.String = "botGameStream" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.botGameStream.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameStream.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameStream.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameStream.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameStream.Input.Path, + headers: Operations.botGameStream.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameStream.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameStream.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameStream.Output.Ok.Headers = .init(), + body: Operations.botGameStream.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The stream of the bot game. + /// + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameStream.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameStream.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/stream/{gameId}/GET/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameStream.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameStream.Output.NotFound.Body) { + self.body = body + } + } + /// The bot game was not found. + /// + /// - Remark: Generated from `#/paths//api/bot/game/stream/{gameId}/get(botGameStream)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.botGameStream.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.botGameStream.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson, + .json + ] + } + } + } + /// Make a Bot move + /// + /// Make a move in a game being played with the Bot API. + /// The move can also contain a draw offer/agreement. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/move/{move}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)`. + internal enum botGameMove { + internal static let id: Swift.String = "botGameMove" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/path/gameId`. + internal var gameId: Swift.String + /// The move to play, in UCI format + /// + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/path/move`. + internal var move: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - move: The move to play, in UCI format + internal init( + gameId: Swift.String, + move: Swift.String + ) { + self.gameId = gameId + self.move = move + } + } + internal var path: Operations.botGameMove.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/query`. + internal struct Query: Sendable, Hashable { + /// Whether to offer (or agree to) a draw + /// + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/query/offeringDraw`. + internal var offeringDraw: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - offeringDraw: Whether to offer (or agree to) a draw + internal init(offeringDraw: Swift.Bool? = nil) { + self.offeringDraw = offeringDraw + } + } + internal var query: Operations.botGameMove.Input.Query + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameMove.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameMove.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameMove.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.botGameMove.Input.Path, + query: Operations.botGameMove.Input.Query = .init(), + headers: Operations.botGameMove.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameMove.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameMove.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameMove.Output.Ok.Headers = .init(), + body: Operations.botGameMove.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The bot move was successfully made. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameMove.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameMove.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/move/{move}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameMove.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameMove.Output.BadRequest.Body) { + self.body = body + } + } + /// The bot move failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/move/{move}/post(botGameMove)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameMove.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameMove.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Fetch the game chat + /// + /// Get the messages posted in the game chat + /// + /// + /// - Remark: HTTP `GET /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/get(botGameChatGet)`. + internal enum botGameChatGet { + internal static let id: Swift.String = "botGameChatGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.botGameChatGet.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameChatGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameChatGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameChatGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameChatGet.Input.Path, + headers: Operations.botGameChatGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameChatGet.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/GET/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameChatGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameChatGet.Output.Ok.Headers = .init(), + body: Operations.botGameChatGet.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The messages posted in the chat. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/get(botGameChatGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameChatGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameChatGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Write in the chat + /// + /// Post a message to the player or spectator chat, in a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/chat`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)`. + internal enum botGameChat { + internal static let id: Swift.String = "botGameChat" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.botGameChat.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameChat.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameChat.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameChat.Input.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody/urlEncodedForm/room`. + @frozen internal enum roomPayload: String, Codable, Hashable, Sendable { + case player = "player" + case spectator = "spectator" + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody/urlEncodedForm/room`. + internal var room: Operations.botGameChat.Input.Body.urlEncodedFormPayload.roomPayload + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody/urlEncodedForm/text`. + internal var text: Swift.String + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - room: + /// - text: + internal init( + room: Operations.botGameChat.Input.Body.urlEncodedFormPayload.roomPayload, + text: Swift.String + ) { + self.room = room + self.text = text + } + internal enum CodingKeys: String, CodingKey { + case room + case text + } + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.botGameChat.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.botGameChat.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.botGameChat.Input.Path, + headers: Operations.botGameChat.Input.Headers = .init(), + body: Operations.botGameChat.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameChat.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameChat.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameChat.Output.Ok.Headers = .init(), + body: Operations.botGameChat.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The message was successfully posted in chat. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameChat.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameChat.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/chat/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameChat.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameChat.Output.BadRequest.Body) { + self.body = body + } + } + /// The posting of the message in chat failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/chat/post(botGameChat)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameChat.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameChat.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Abort a game + /// + /// Abort a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/abort`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)`. + internal enum botGameAbort { + internal static let id: Swift.String = "botGameAbort" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.botGameAbort.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameAbort.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameAbort.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameAbort.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameAbort.Input.Path, + headers: Operations.botGameAbort.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameAbort.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameAbort.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameAbort.Output.Ok.Headers = .init(), + body: Operations.botGameAbort.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game was successfully aborted. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameAbort.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameAbort.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/abort/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameAbort.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameAbort.Output.BadRequest.Body) { + self.body = body + } + } + /// The abortion of the game failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/abort/post(botGameAbort)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameAbort.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameAbort.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Resign a game + /// + /// Resign a game being played with the Bot API. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/resign`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)`. + internal enum botGameResign { + internal static let id: Swift.String = "botGameResign" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.botGameResign.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameResign.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameResign.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameResign.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameResign.Input.Path, + headers: Operations.botGameResign.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameResign.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameResign.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameResign.Output.Ok.Headers = .init(), + body: Operations.botGameResign.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game was successfully resigned from. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameResign.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameResign.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/resign/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameResign.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameResign.Output.BadRequest.Body) { + self.body = body + } + } + /// Resigning the game failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/resign/post(botGameResign)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameResign.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameResign.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Handle draw offers + /// + /// Create/accept/decline draw offers with the Bot API. + /// - `yes`: Offer a draw, or accept the opponent's draw offer. + /// - `no`: Decline a draw offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/draw/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)`. + internal enum botGameDraw { + internal static let id: Swift.String = "botGameDraw" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/gameId`. + internal var gameId: Swift.String + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/accept`. + internal struct acceptPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/accept/value1`. + internal var value1: Swift.Bool? + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/accept/value2`. + @frozen internal enum Value2Payload: String, Codable, Hashable, Sendable { + case yes = "yes" + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/accept/value2`. + internal var value2: Operations.botGameDraw.Input.Path.acceptPayload.Value2Payload? + /// Creates a new `acceptPayload`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Swift.Bool? = nil, + value2: Operations.botGameDraw.Input.Path.acceptPayload.Value2Payload? = nil + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + value1 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + do { + value2 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil( + [ + value1, + value2 + ], + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeFirstNonNilValueToSingleValueContainer([ + value1, + value2 + ]) + } + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/path/accept`. + internal var accept: Operations.botGameDraw.Input.Path.acceptPayload + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - accept: + internal init( + gameId: Swift.String, + accept: Operations.botGameDraw.Input.Path.acceptPayload + ) { + self.gameId = gameId + self.accept = accept + } + } + internal var path: Operations.botGameDraw.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameDraw.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameDraw.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameDraw.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameDraw.Input.Path, + headers: Operations.botGameDraw.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameDraw.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameDraw.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameDraw.Output.Ok.Headers = .init(), + body: Operations.botGameDraw.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The draw offer was successfully sent. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameDraw.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameDraw.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/draw/{accept}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameDraw.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameDraw.Output.BadRequest.Body) { + self.body = body + } + } + /// The draw offering failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/draw/{accept}/post(botGameDraw)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameDraw.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameDraw.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Handle takeback offers + /// + /// Create/accept/decline takebacks with the Bot API. + /// - `yes`: Propose a takeback, or accept the opponent's takeback offer. + /// - `no`: Decline a takeback offer from the opponent. + /// + /// + /// - Remark: HTTP `POST /api/bot/game/{gameId}/takeback/{accept}`. + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)`. + internal enum botGameTakeback { + internal static let id: Swift.String = "botGameTakeback" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/gameId`. + internal var gameId: Swift.String + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/accept`. + internal struct acceptPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/accept/value1`. + internal var value1: Swift.Bool? + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/accept/value2`. + @frozen internal enum Value2Payload: String, Codable, Hashable, Sendable { + case yes = "yes" + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/accept/value2`. + internal var value2: Operations.botGameTakeback.Input.Path.acceptPayload.Value2Payload? + /// Creates a new `acceptPayload`. + /// + /// - Parameters: + /// - value1: + /// - value2: + internal init( + value1: Swift.Bool? = nil, + value2: Operations.botGameTakeback.Input.Path.acceptPayload.Value2Payload? = nil + ) { + self.value1 = value1 + self.value2 = value2 + } + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + value1 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + do { + value2 = try decoder.decodeFromSingleValueContainer() + } catch { + errors.append(error) + } + try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil( + [ + value1, + value2 + ], + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeFirstNonNilValueToSingleValueContainer([ + value1, + value2 + ]) + } + } + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/path/accept`. + internal var accept: Operations.botGameTakeback.Input.Path.acceptPayload + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - accept: + internal init( + gameId: Swift.String, + accept: Operations.botGameTakeback.Input.Path.acceptPayload + ) { + self.gameId = gameId + self.accept = accept + } + } + internal var path: Operations.botGameTakeback.Input.Path + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameTakeback.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.botGameTakeback.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.botGameTakeback.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.botGameTakeback.Input.Path, + headers: Operations.botGameTakeback.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.botGameTakeback.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameTakeback.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.botGameTakeback.Output.Ok.Headers = .init(), + body: Operations.botGameTakeback.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The takeback offer was successfully sent. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.botGameTakeback.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.botGameTakeback.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bot/game/{gameId}/takeback/{accept}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.botGameTakeback.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.botGameTakeback.Output.BadRequest.Body) { + self.body = body + } + } + /// The takeback offering failed. + /// + /// - Remark: Generated from `#/paths//api/bot/game/{gameId}/takeback/{accept}/post(botGameTakeback)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.botGameTakeback.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.botGameTakeback.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// List your challenges + /// + /// Get a list of challenges created by or targeted at you. + /// + /// + /// - Remark: HTTP `GET /api/challenge`. + /// - Remark: Generated from `#/paths//api/challenge/get(challengeList)`. + internal enum challengeList { + internal static let id: Swift.String = "challengeList" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeList.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeList.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeList.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.challengeList.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeList.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// Incoming challenges i.e. targeted at you + /// + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/content/json/in`. + internal var _in: [Components.Schemas.ChallengeJson]? + /// Outgoing challenges i.e. created by you + /// + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/content/json/out`. + internal var out: [Components.Schemas.ChallengeJson]? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - _in: Incoming challenges i.e. targeted at you + /// - out: Outgoing challenges i.e. created by you + internal init( + _in: [Components.Schemas.ChallengeJson]? = nil, + out: [Components.Schemas.ChallengeJson]? = nil + ) { + self._in = _in + self.out = out + } + internal enum CodingKeys: String, CodingKey { + case _in = "in" + case out + } + } + /// - Remark: Generated from `#/paths/api/challenge/GET/responses/200/content/application\/json`. + case json(Operations.challengeList.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.challengeList.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeList.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeList.Output.Ok.Headers = .init(), + body: Operations.challengeList.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of challenges created by or targeted at the logged in user. + /// + /// - Remark: Generated from `#/paths//api/challenge/get(challengeList)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeList.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeList.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create a challenge + /// + /// Challenge someone to play. The targeted player can choose to accept or decline. + /// If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) + /// that a new game has started. The game ID will be the same as the challenge ID. + /// Challenges for realtime games (not correspondence) expire after 20s if not accepted. + /// To prevent that, use the `keepAliveStream` flag described below. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{username}`. + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)`. + internal enum challengeCreate { + internal static let id: Swift.String = "challengeCreate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.challengeCreate.Input.Path + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeCreate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeCreate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeCreate.Input.Headers + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Game is rated and impacts players ratings + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// Clock initial time in seconds. If empty, a correspondence game is created. Valid values are 0, 15, 30, 45, 60, 90, and any multiple of 60 up to 10800 (3 hours). + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double? + /// Clock increment in seconds. If empty, a correspondence game is created. + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int? + /// Days per move, for correspondence games. Clock settings must be omitted. + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/days`. + @frozen internal enum daysPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _7 = 7 + case _10 = 10 + case _14 = 14 + } + /// Days per move, for correspondence games. Clock settings must be omitted. + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/days`. + internal var days: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.daysPayload? + /// Which color you get to play + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/color`. + @frozen internal enum colorPayload: String, Codable, Hashable, Sendable { + case random = "random" + case white = "white" + case black = "black" + } + /// Which color you get to play + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/color`. + internal var color: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.colorPayload? + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/fen`. + internal var fen: Components.Schemas.FromPositionFEN? + /// If set, the response is streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// The challenge is kept alive until the connection is closed by the client. + /// When the challenge is accepted, declined or canceled, a message of the form `{"done":"accepted"}` is sent, + /// then the connection is closed by the server. + /// If not set, the response is not streamed, and the challenge expires after 20s if not accepted. + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/keepAliveStream`. + internal var keepAliveStream: Swift.Bool? + /// Extra game rules separated by commas. + /// Example: `noAbort,noRematch` + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/rules`. + @frozen internal enum rulesPayload: String, Codable, Hashable, Sendable { + case noAbort = "noAbort" + case noRematch = "noRematch" + case noGiveTime = "noGiveTime" + case noClaimWin = "noClaimWin" + case noEarlyDraw = "noEarlyDraw" + } + /// Extra game rules separated by commas. + /// Example: `noAbort,noRematch` + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/urlEncodedForm/rules`. + internal var rules: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.rulesPayload? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - rated: Game is rated and impacts players ratings + /// - clock_period_limit: Clock initial time in seconds. If empty, a correspondence game is created. Valid values are 0, 15, 30, 45, 60, 90, and any multiple of 60 up to 10800 (3 hours). + /// - clock_period_increment: Clock increment in seconds. If empty, a correspondence game is created. + /// - days: Days per move, for correspondence games. Clock settings must be omitted. + /// - color: Which color you get to play + /// - variant: + /// - fen: + /// - keepAliveStream: If set, the response is streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). + /// - rules: Extra game rules separated by commas. + internal init( + rated: Swift.Bool? = nil, + clock_period_limit: Swift.Double? = nil, + clock_period_increment: Swift.Int? = nil, + days: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.daysPayload? = nil, + color: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.colorPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + fen: Components.Schemas.FromPositionFEN? = nil, + keepAliveStream: Swift.Bool? = nil, + rules: Operations.challengeCreate.Input.Body.urlEncodedFormPayload.rulesPayload? = nil + ) { + self.rated = rated + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.days = days + self.color = color + self.variant = variant + self.fen = fen + self.keepAliveStream = keepAliveStream + self.rules = rules + } + internal enum CodingKeys: String, CodingKey { + case rated + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case days + case color + case variant + case fen + case keepAliveStream + case rules + } + } + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.challengeCreate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.challengeCreate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.challengeCreate.Input.Path, + headers: Operations.challengeCreate.Input.Headers = .init(), + body: Operations.challengeCreate.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeCreate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/content/json/challenge`. + internal var challenge: Components.Schemas.ChallengeJson? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - challenge: + internal init(challenge: Components.Schemas.ChallengeJson? = nil) { + self.challenge = challenge + } + internal enum CodingKeys: String, CodingKey { + case challenge + } + } + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/200/content/application\/json`. + case json(Operations.challengeCreate.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.challengeCreate.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeCreate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeCreate.Output.Ok.Headers = .init(), + body: Operations.challengeCreate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The challenge was successfully created. + /// + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeCreate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeCreate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{username}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeCreate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeCreate.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the challenge failed. + /// + /// - Remark: Generated from `#/paths//api/challenge/{username}/post(challengeCreate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.challengeCreate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.challengeCreate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Accept a challenge + /// + /// Accept an incoming challenge. + /// You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent). + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/accept`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)`. + internal enum challengeAccept { + internal static let id: Swift.String = "challengeAccept" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/path/challengeId`. + internal var challengeId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - challengeId: + internal init(challengeId: Swift.String) { + self.challengeId = challengeId + } + } + internal var path: Operations.challengeAccept.Input.Path + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeAccept.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeAccept.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeAccept.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.challengeAccept.Input.Path, + headers: Operations.challengeAccept.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeAccept.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeAccept.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeAccept.Output.Ok.Headers = .init(), + body: Operations.challengeAccept.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The challenge was successfully accepted. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeAccept.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeAccept.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/accept/POST/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeAccept.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeAccept.Output.NotFound.Body) { + self.body = body + } + } + /// The challenge to accept was not found. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/accept/post(challengeAccept)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.challengeAccept.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.challengeAccept.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Decline a challenge + /// + /// Decline an incoming challenge. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/decline`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)`. + internal enum challengeDecline { + internal static let id: Swift.String = "challengeDecline" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/path/challengeId`. + internal var challengeId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - challengeId: + internal init(challengeId: Swift.String) { + self.challengeId = challengeId + } + } + internal var path: Operations.challengeDecline.Input.Path + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeDecline.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeDecline.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeDecline.Input.Headers + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Reason challenge was declined. It will be translated to the player's language. See [the full list in the translation file](https://github.com/ornicar/lila/blob/master/translation/source/challenge.xml#L14). + /// + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/requestBody/urlEncodedForm/reason`. + @frozen internal enum reasonPayload: String, Codable, Hashable, Sendable { + case generic = "generic" + case later = "later" + case tooFast = "tooFast" + case tooSlow = "tooSlow" + case timeControl = "timeControl" + case rated = "rated" + case casual = "casual" + case standard = "standard" + case variant = "variant" + case noBot = "noBot" + case onlyBot = "onlyBot" + } + /// Reason challenge was declined. It will be translated to the player's language. See [the full list in the translation file](https://github.com/ornicar/lila/blob/master/translation/source/challenge.xml#L14). + /// + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/requestBody/urlEncodedForm/reason`. + internal var reason: Operations.challengeDecline.Input.Body.urlEncodedFormPayload.reasonPayload? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - reason: Reason challenge was declined. It will be translated to the player's language. See [the full list in the translation file](https://github.com/ornicar/lila/blob/master/translation/source/challenge.xml#L14). + internal init(reason: Operations.challengeDecline.Input.Body.urlEncodedFormPayload.reasonPayload? = nil) { + self.reason = reason + } + internal enum CodingKeys: String, CodingKey { + case reason + } + } + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.challengeDecline.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.challengeDecline.Input.Body? + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.challengeDecline.Input.Path, + headers: Operations.challengeDecline.Input.Headers = .init(), + body: Operations.challengeDecline.Input.Body? = nil + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeDecline.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeDecline.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeDecline.Output.Ok.Headers = .init(), + body: Operations.challengeDecline.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The challenge was successfully declined. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeDecline.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeDecline.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/decline/POST/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeDecline.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeDecline.Output.NotFound.Body) { + self.body = body + } + } + /// The challenge to decline was not found. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/decline/post(challengeDecline)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.challengeDecline.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.challengeDecline.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Cancel a challenge + /// + /// Cancel a challenge you sent, or aborts the game if the challenge was accepted, but the game was not yet played. + /// Note that the ID of a game is the same as the ID of the challenge that created it. + /// Works for user challenges and open challenges alike. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{challengeId}/cancel`. + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)`. + internal enum challengeCancel { + internal static let id: Swift.String = "challengeCancel" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/path/challengeId`. + internal var challengeId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - challengeId: + internal init(challengeId: Swift.String) { + self.challengeId = challengeId + } + } + internal var path: Operations.challengeCancel.Input.Path + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/query`. + internal struct Query: Sendable, Hashable { + /// Optional `challenge:write` token of the opponent. If set, the game can be canceled even if both players have moved. + /// + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/query/opponentToken`. + internal var opponentToken: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - opponentToken: Optional `challenge:write` token of the opponent. If set, the game can be canceled even if both players have moved. + internal init(opponentToken: Swift.String? = nil) { + self.opponentToken = opponentToken + } + } + internal var query: Operations.challengeCancel.Input.Query + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeCancel.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeCancel.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeCancel.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.challengeCancel.Input.Path, + query: Operations.challengeCancel.Input.Query = .init(), + headers: Operations.challengeCancel.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeCancel.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeCancel.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeCancel.Output.Ok.Headers = .init(), + body: Operations.challengeCancel.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The challenge was successfully cancelled. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeCancel.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeCancel.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{challengeId}/cancel/POST/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeCancel.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeCancel.Output.NotFound.Body) { + self.body = body + } + } + /// The challenge to cancel was not found. + /// + /// - Remark: Generated from `#/paths//api/challenge/{challengeId}/cancel/post(challengeCancel)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.challengeCancel.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.challengeCancel.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Challenge the AI + /// + /// Start a game with Lichess AI. + /// You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. + /// + /// + /// - Remark: HTTP `POST /api/challenge/ai`. + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)`. + internal enum challengeAi { + internal static let id: Swift.String = "challengeAi" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeAi.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeAi.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeAi.Input.Headers + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// AI strength + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/level`. + internal var level: Swift.Double? + /// Clock initial time in seconds. If empty, a correspondence game is created. + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double? + /// Clock increment in seconds. If empty, a correspondence game is created. + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int? + /// Days per move, for correspondence games. Clock settings must be omitted. + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/days`. + @frozen internal enum daysPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _7 = 7 + case _10 = 10 + case _14 = 14 + } + /// Days per move, for correspondence games. Clock settings must be omitted. + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/days`. + internal var days: Operations.challengeAi.Input.Body.urlEncodedFormPayload.daysPayload? + /// Which color you get to play + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/color`. + @frozen internal enum colorPayload: String, Codable, Hashable, Sendable { + case random = "random" + case white = "white" + case black = "black" + } + /// Which color you get to play + /// + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/color`. + internal var color: Operations.challengeAi.Input.Body.urlEncodedFormPayload.colorPayload? + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/urlEncodedForm/fen`. + internal var fen: Components.Schemas.FromPositionFEN? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - level: AI strength + /// - clock_period_limit: Clock initial time in seconds. If empty, a correspondence game is created. + /// - clock_period_increment: Clock increment in seconds. If empty, a correspondence game is created. + /// - days: Days per move, for correspondence games. Clock settings must be omitted. + /// - color: Which color you get to play + /// - variant: + /// - fen: + internal init( + level: Swift.Double? = nil, + clock_period_limit: Swift.Double? = nil, + clock_period_increment: Swift.Int? = nil, + days: Operations.challengeAi.Input.Body.urlEncodedFormPayload.daysPayload? = nil, + color: Operations.challengeAi.Input.Body.urlEncodedFormPayload.colorPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + fen: Components.Schemas.FromPositionFEN? = nil + ) { + self.level = level + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.days = days + self.color = color + self.variant = variant + self.fen = fen + } + internal enum CodingKeys: String, CodingKey { + case level + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case days + case color + case variant + case fen + } + } + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.challengeAi.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.challengeAi.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.challengeAi.Input.Headers = .init(), + body: Operations.challengeAi.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Created: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/201/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/201/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeAi.Output.Created.Headers + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/201/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/201/content/application\/json`. + case json(Components.Schemas.GameJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.GameJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeAi.Output.Created.Body + /// Creates a new `Created`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeAi.Output.Created.Headers = .init(), + body: Operations.challengeAi.Output.Created.Body + ) { + self.headers = headers + self.body = body + } + } + /// The game with Lichess AI was successfully started. + /// + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)/responses/201`. + /// + /// HTTP response code: `201 created`. + case created(Operations.challengeAi.Output.Created) + /// The associated value of the enum case if `self` is `.created`. + /// + /// - Throws: An error if `self` is not `.created`. + /// - SeeAlso: `.created`. + internal var created: Operations.challengeAi.Output.Created { + get throws { + switch self { + case let .created(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "created", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/ai/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeAi.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeAi.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of a game with Lichess AI failed. + /// + /// - Remark: Generated from `#/paths//api/challenge/ai/post(challengeAi)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.challengeAi.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.challengeAi.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Open-ended challenge + /// + /// Create a challenge that any 2 players can join. + /// Share the URL of the challenge. the first 2 players to click it will be paired for a game. + /// The response body also contains `whiteUrl` and `blackUrl`. + /// You can control which color each player gets by giving them these URLs, + /// instead of the main challenge URL. + /// Open challenges expire after 24h. + /// If the challenge creation is [authenticated with OAuth2](#section/Introduction/Authentication), + /// then you can use the [challenge cancel endpoint](#operation/challengeCancel) to cancel it. + /// To directly pair 2 known players, use [this endpoint](#operation/bulkPairingList) instead. + /// + /// + /// - Remark: HTTP `POST /api/challenge/open`. + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)`. + internal enum challengeOpen { + internal static let id: Swift.String = "challengeOpen" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeOpen.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeOpen.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeOpen.Input.Headers + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Game is rated and impacts players ratings + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// Clock initial time in seconds. If empty, a correspondence game is created. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double? + /// Clock increment in seconds. If empty, a correspondence game is created. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int? + /// Days per turn. For correspondence challenges. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/days`. + @frozen internal enum daysPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _7 = 7 + case _10 = 10 + case _14 = 14 + } + /// Days per turn. For correspondence challenges. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/days`. + internal var days: Operations.challengeOpen.Input.Body.urlEncodedFormPayload.daysPayload? + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/fen`. + internal var fen: Components.Schemas.FromPositionFEN? + /// Optional name for the challenge, that players will see on the challenge page. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/name`. + internal var name: Swift.String? + /// Extra game rules separated by commas. + /// Example: `noRematch,noGiveTime` + /// The `noAbort` rule is available for Lichess admins only + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/rules`. + @frozen internal enum rulesPayload: String, Codable, Hashable, Sendable { + case noRematch = "noRematch" + case noGiveTime = "noGiveTime" + case noClaimWin = "noClaimWin" + case noEarlyDraw = "noEarlyDraw" + case noAbort = "noAbort" + } + /// Extra game rules separated by commas. + /// Example: `noRematch,noGiveTime` + /// The `noAbort` rule is available for Lichess admins only + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/rules`. + internal var rules: Operations.challengeOpen.Input.Body.urlEncodedFormPayload.rulesPayload? + /// Optional pair of usernames, separated by a comma. + /// If set, only these users will be allowed to join the game. + /// The first username gets the white pieces. + /// Example: `Username1,Username2` + /// + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/users`. + internal var users: Swift.String? + /// Timestamp in milliseconds to expire the challenge. Defaults to 24h after creation. Can't be more than 2 weeks after creation. + /// + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/urlEncodedForm/expiresAt`. + internal var expiresAt: Swift.Int? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - rated: Game is rated and impacts players ratings + /// - clock_period_limit: Clock initial time in seconds. If empty, a correspondence game is created. + /// - clock_period_increment: Clock increment in seconds. If empty, a correspondence game is created. + /// - days: Days per turn. For correspondence challenges. + /// - variant: + /// - fen: + /// - name: Optional name for the challenge, that players will see on the challenge page. + /// - rules: Extra game rules separated by commas. + /// - users: Optional pair of usernames, separated by a comma. + /// - expiresAt: Timestamp in milliseconds to expire the challenge. Defaults to 24h after creation. Can't be more than 2 weeks after creation. + internal init( + rated: Swift.Bool? = nil, + clock_period_limit: Swift.Double? = nil, + clock_period_increment: Swift.Int? = nil, + days: Operations.challengeOpen.Input.Body.urlEncodedFormPayload.daysPayload? = nil, + variant: Components.Schemas.VariantKey? = nil, + fen: Components.Schemas.FromPositionFEN? = nil, + name: Swift.String? = nil, + rules: Operations.challengeOpen.Input.Body.urlEncodedFormPayload.rulesPayload? = nil, + users: Swift.String? = nil, + expiresAt: Swift.Int? = nil + ) { + self.rated = rated + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.days = days + self.variant = variant + self.fen = fen + self.name = name + self.rules = rules + self.users = users + self.expiresAt = expiresAt + } + internal enum CodingKeys: String, CodingKey { + case rated + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case days + case variant + case fen + case name + case rules + case users + case expiresAt + } + } + /// - Remark: Generated from `#/paths/api/challenge/open/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.challengeOpen.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.challengeOpen.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.challengeOpen.Input.Headers = .init(), + body: Operations.challengeOpen.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeOpen.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/200/content/application\/json`. + case json(Components.Schemas.ChallengeOpenJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ChallengeOpenJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeOpen.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeOpen.Output.Ok.Headers = .init(), + body: Operations.challengeOpen.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The challenge was successfully created. + /// + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeOpen.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeOpen.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/open/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeOpen.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.challengeOpen.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the challenge failed. + /// + /// - Remark: Generated from `#/paths//api/challenge/open/post(challengeOpen)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.challengeOpen.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.challengeOpen.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Start clocks of a game + /// + /// Start the clocks of a game immediately, even if a player has not yet made a move. + /// Requires the OAuth tokens of both players with `challenge:write` scope. + /// If the clocks have already started, the call will have no effect. + /// + /// + /// - Remark: HTTP `POST /api/challenge/{gameId}/start-clocks`. + /// - Remark: Generated from `#/paths//api/challenge/{gameId}/start-clocks/post(challengeStartClocks)`. + internal enum challengeStartClocks { + internal static let id: Swift.String = "challengeStartClocks" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.challengeStartClocks.Input.Path + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/query`. + internal struct Query: Sendable, Hashable { + /// OAuth token of a player + /// + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/query/token1`. + internal var token1: Swift.String? + /// OAuth token of the other player + /// + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/query/token2`. + internal var token2: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - token1: OAuth token of a player + /// - token2: OAuth token of the other player + internal init( + token1: Swift.String? = nil, + token2: Swift.String? = nil + ) { + self.token1 = token1 + self.token2 = token2 + } + } + internal var query: Operations.challengeStartClocks.Input.Query + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeStartClocks.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.challengeStartClocks.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.challengeStartClocks.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + internal init( + path: Operations.challengeStartClocks.Input.Path, + query: Operations.challengeStartClocks.Input.Query = .init(), + headers: Operations.challengeStartClocks.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.challengeStartClocks.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/challenge/{gameId}/start-clocks/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.challengeStartClocks.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.challengeStartClocks.Output.Ok.Headers = .init(), + body: Operations.challengeStartClocks.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The clock of a game was successfully started. + /// + /// - Remark: Generated from `#/paths//api/challenge/{gameId}/start-clocks/post(challengeStartClocks)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.challengeStartClocks.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.challengeStartClocks.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// View your bulk pairings + /// + /// Get a list of bulk pairings you created. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/get(bulkPairingList)`. + internal enum bulkPairingList { + internal static let id: Swift.String = "bulkPairingList" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingList.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingList.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.bulkPairingList.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.bulkPairingList.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.bulkPairingList.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/GET/responses/200/content/application\/json`. + case json([Components.Schemas.BulkPairing]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.BulkPairing] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingList.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.bulkPairingList.Output.Ok.Headers = .init(), + body: Operations.bulkPairingList.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The list of bulk pairing the logged in user created. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/get(bulkPairingList)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.bulkPairingList.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.bulkPairingList.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create a bulk pairing + /// + /// Schedule many games at once, up to 24h in advance. + /// OAuth tokens are required for all paired players, with the `challenge:write` scope. + /// You can schedule up to 500 games every 10 minutes. [Contact us](mailto:contact@lichess.org) if you need higher limits. + /// If games have a real-time clock, each player must have only one pairing. + /// For correspondence games, players can have multiple pairings within the same bulk. + /// The entire bulk is rejected if: + /// - a token is missing + /// - a token is present more than once (except in correspondence) + /// - a token lacks the `challenge:write` scope + /// - a player account is closed + /// - a player is paired more than once (except in correspondence) + /// - a bulk is already scheduled to start at the same time with the same player + /// - you have 20 scheduled bulks + /// - you have 1000 scheduled games + /// Partial bulks are never created. Either it all fails, or it all succeeds. + /// When it fails, it does so with an error message explaining the issue. + /// Failed bulks are not counted in the rate limiting, they are free. + /// Fix the issues, manually or programmatically, then retry to schedule the bulk. + /// A successful bulk creation returns a JSON bulk document. Its ID can be used for further operations. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)`. + internal enum bulkPairingCreate { + internal static let id: Swift.String = "bulkPairingCreate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingCreate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingCreate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.bulkPairingCreate.Input.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// OAuth tokens of all the players to pair, with the syntax `tokenOfWhitePlayerInGame1:tokenOfBlackPlayerInGame1,tokenOfWhitePlayerInGame2:tokenOfBlackPlayerInGame2,...`. + /// The 2 tokens of the players of a game are separated with `:`. The first token gets the white pieces. Games are separated with `,`. + /// Up to 1000 tokens can be sent, for a max of 500 games. + /// Each token must be included at most once. + /// Example: `token1:token2,token3:token4,token5:token6` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/players`. + internal var players: Swift.String? + /// Clock initial time in seconds. Example: `600` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/clock.limit`. + internal var clock_period_limit: Swift.Double? + /// Clock increment in seconds. Example: `2` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/clock.increment`. + internal var clock_period_increment: Swift.Int? + /// Days per turn. For correspondence games only. + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/days`. + @frozen internal enum daysPayload: Int, Codable, Hashable, Sendable { + case _1 = 1 + case _2 = 2 + case _3 = 3 + case _5 = 5 + case _7 = 7 + case _10 = 10 + case _14 = 14 + } + /// Days per turn. For correspondence games only. + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/days`. + internal var days: Operations.bulkPairingCreate.Input.Body.urlEncodedFormPayload.daysPayload? + /// Date at which the games will be created as a Unix timestamp in milliseconds. + /// Up to 7 days in the future. + /// Omit, or set to current date and time, to start the games immediately. + /// Example: `1612289869919` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/pairAt`. + internal var pairAt: Swift.Int? + /// Date at which the clocks will be automatically started as a Unix timestamp in milliseconds. + /// Up to 7 days in the future. + /// Note that the clocks can start earlier than specified, if players start making moves in the game. + /// If omitted, the clocks will not start automatically. + /// Example: `1612289869919` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/startClocksAt`. + internal var startClocksAt: Swift.Int? + /// Game is rated and impacts players ratings + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/rated`. + internal var rated: Swift.Bool? + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/variant`. + internal var variant: Components.Schemas.VariantKey? + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/fen`. + internal var fen: Components.Schemas.FromPositionFEN? + /// Message that will be sent to each player, when the game is created. It is sent from your user account. + /// `{opponent}` and `{game}` are placeholders that will be replaced with the opponent and the game URLs. + /// You can omit this field to send the default message, + /// but if you set your own message, it must at least contain the `{game}` placeholder. + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/message`. + internal var message: Swift.String? + /// Extra game rules separated by commas. + /// Example: `noAbort,noRematch` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/rules`. + @frozen internal enum rulesPayload: String, Codable, Hashable, Sendable { + case noAbort = "noAbort" + case noRematch = "noRematch" + case noGiveTime = "noGiveTime" + case noClaimWin = "noClaimWin" + case noEarlyDraw = "noEarlyDraw" + } + /// Extra game rules separated by commas. + /// Example: `noAbort,noRematch` + /// + /// + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/urlEncodedForm/rules`. + internal var rules: Operations.bulkPairingCreate.Input.Body.urlEncodedFormPayload.rulesPayload? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - players: OAuth tokens of all the players to pair, with the syntax `tokenOfWhitePlayerInGame1:tokenOfBlackPlayerInGame1,tokenOfWhitePlayerInGame2:tokenOfBlackPlayerInGame2,...`. + /// - clock_period_limit: Clock initial time in seconds. Example: `600` + /// - clock_period_increment: Clock increment in seconds. Example: `2` + /// - days: Days per turn. For correspondence games only. + /// - pairAt: Date at which the games will be created as a Unix timestamp in milliseconds. + /// - startClocksAt: Date at which the clocks will be automatically started as a Unix timestamp in milliseconds. + /// - rated: Game is rated and impacts players ratings + /// - variant: + /// - fen: + /// - message: Message that will be sent to each player, when the game is created. It is sent from your user account. + /// - rules: Extra game rules separated by commas. + internal init( + players: Swift.String? = nil, + clock_period_limit: Swift.Double? = nil, + clock_period_increment: Swift.Int? = nil, + days: Operations.bulkPairingCreate.Input.Body.urlEncodedFormPayload.daysPayload? = nil, + pairAt: Swift.Int? = nil, + startClocksAt: Swift.Int? = nil, + rated: Swift.Bool? = nil, + variant: Components.Schemas.VariantKey? = nil, + fen: Components.Schemas.FromPositionFEN? = nil, + message: Swift.String? = nil, + rules: Operations.bulkPairingCreate.Input.Body.urlEncodedFormPayload.rulesPayload? = nil + ) { + self.players = players + self.clock_period_limit = clock_period_limit + self.clock_period_increment = clock_period_increment + self.days = days + self.pairAt = pairAt + self.startClocksAt = startClocksAt + self.rated = rated + self.variant = variant + self.fen = fen + self.message = message + self.rules = rules + } + internal enum CodingKeys: String, CodingKey { + case players + case clock_period_limit = "clock.limit" + case clock_period_increment = "clock.increment" + case days + case pairAt + case startClocksAt + case rated + case variant + case fen + case message + case rules + } + } + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.bulkPairingCreate.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.bulkPairingCreate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.bulkPairingCreate.Input.Headers = .init(), + body: Operations.bulkPairingCreate.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.bulkPairingCreate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/200/content/application\/json`. + case json(Components.Schemas.BulkPairing) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BulkPairing { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingCreate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.bulkPairingCreate.Output.Ok.Headers = .init(), + body: Operations.bulkPairingCreate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The bulk pairing has been successfully created. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.bulkPairingCreate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.bulkPairingCreate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingCreate.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.bulkPairingCreate.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the bulk pairings failed. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/post(bulkPairingCreate)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.bulkPairingCreate.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.bulkPairingCreate.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Manually start clocks + /// + /// Immediately start all clocks of the games of a bulk pairing. + /// This overrides the `startClocksAt` value of an existing bulk pairing. + /// If the games have not yet been created (`bulk.pairAt` is in the future), then this does nothing. + /// If the clocks have already started (`bulk.startClocksAt` is in the past), then this does nothing. + /// + /// + /// - Remark: HTTP `POST /api/bulk-pairing/{id}/start-clocks`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)`. + internal enum bulkPairingStartClocks { + internal static let id: Swift.String = "bulkPairingStartClocks" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.bulkPairingStartClocks.Input.Path + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingStartClocks.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingStartClocks.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.bulkPairingStartClocks.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.bulkPairingStartClocks.Input.Path, + headers: Operations.bulkPairingStartClocks.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.bulkPairingStartClocks.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingStartClocks.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.bulkPairingStartClocks.Output.Ok.Headers = .init(), + body: Operations.bulkPairingStartClocks.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The clocks of the games of a bulk pairing were successfully started. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.bulkPairingStartClocks.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.bulkPairingStartClocks.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/start-clocks/POST/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingStartClocks.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.bulkPairingStartClocks.Output.NotFound.Body) { + self.body = body + } + } + /// The bulk pairing was not found. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/start-clocks/post(bulkPairingStartClocks)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.bulkPairingStartClocks.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.bulkPairingStartClocks.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Show a bulk pairing + /// + /// Get a single bulk pairing by its ID. + /// + /// + /// - Remark: HTTP `GET /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)`. + internal enum bulkPairingGet { + internal static let id: Swift.String = "bulkPairingGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.bulkPairingGet.Input.Path + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.bulkPairingGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.bulkPairingGet.Input.Path, + headers: Operations.bulkPairingGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.bulkPairingGet.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.BulkPairing) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.BulkPairing { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.bulkPairingGet.Output.Ok.Headers = .init(), + body: Operations.bulkPairingGet.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The bulk pairing. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.bulkPairingGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.bulkPairingGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/GET/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingGet.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.bulkPairingGet.Output.NotFound.Body) { + self.body = body + } + } + /// The bulk pairing was not found. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/get(bulkPairingGet)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.bulkPairingGet.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.bulkPairingGet.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Cancel a bulk pairing + /// + /// Cancel and delete a bulk pairing that is scheduled in the future. + /// If the games have already been created, then this does nothing. + /// Canceling a bulk pairing does not refund the rate limit cost of that bulk pairing. + /// + /// + /// - Remark: HTTP `DELETE /api/bulk-pairing/{id}`. + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)`. + internal enum bulkPairingDelete { + internal static let id: Swift.String = "bulkPairingDelete" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.bulkPairingDelete.Input.Path + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingDelete.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.bulkPairingDelete.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.bulkPairingDelete.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.bulkPairingDelete.Input.Path, + headers: Operations.bulkPairingDelete.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.bulkPairingDelete.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingDelete.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.bulkPairingDelete.Output.Ok.Headers = .init(), + body: Operations.bulkPairingDelete.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The bulk pairing was successfully deleted. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.bulkPairingDelete.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.bulkPairingDelete.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NotFound: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/404/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/bulk-pairing/{id}/DELETE/responses/404/content/application\/json`. + case json(Components.Schemas.NotFound) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.NotFound { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.bulkPairingDelete.Output.NotFound.Body + /// Creates a new `NotFound`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.bulkPairingDelete.Output.NotFound.Body) { + self.body = body + } + } + /// The bulk pairing to delete was not found. + /// + /// - Remark: Generated from `#/paths//api/bulk-pairing/{id}/delete(bulkPairingDelete)/responses/404`. + /// + /// HTTP response code: `404 notFound`. + case notFound(Operations.bulkPairingDelete.Output.NotFound) + /// The associated value of the enum case if `self` is `.notFound`. + /// + /// - Throws: An error if `self` is not `.notFound`. + /// - SeeAlso: `.notFound`. + internal var notFound: Operations.bulkPairingDelete.Output.NotFound { + get throws { + switch self { + case let .notFound(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "notFound", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Add time to the opponent clock + /// + /// Add seconds to the opponent's clock. Can be used to create games with time odds. + /// + /// + /// - Remark: HTTP `POST /api/round/{gameId}/add-time/{seconds}`. + /// - Remark: Generated from `#/paths//api/round/{gameId}/add-time/{seconds}/post(roundAddTime)`. + internal enum roundAddTime { + internal static let id: Swift.String = "roundAddTime" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/path/gameId`. + internal var gameId: Swift.String + /// How many seconds to give + /// + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/path/seconds`. + internal var seconds: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + /// - seconds: How many seconds to give + internal init( + gameId: Swift.String, + seconds: Swift.String + ) { + self.gameId = gameId + self.seconds = seconds + } + } + internal var path: Operations.roundAddTime.Input.Path + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.roundAddTime.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.roundAddTime.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.roundAddTime.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.roundAddTime.Input.Path, + headers: Operations.roundAddTime.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.roundAddTime.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/round/{gameId}/add-time/{seconds}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.roundAddTime.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.roundAddTime.Output.Ok.Headers = .init(), + body: Operations.roundAddTime.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Time was successfully added to the opponent's clock. + /// + /// - Remark: Generated from `#/paths//api/round/{gameId}/add-time/{seconds}/post(roundAddTime)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.roundAddTime.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.roundAddTime.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Admin challenge tokens + /// + /// **This endpoint can only be used by Lichess administrators. It will not work if you do not have the appropriate permissions.** Tournament organizers should instead use [OAuth](#tag/OAuth) to obtain `challenge:write` tokens from users in order to perform bulk pairing.* + /// Create and obtain `challenge:write` tokens for multiple users. + /// If a similar token already exists for a user, it is reused. This endpoint is idempotent. + /// + /// + /// - Remark: HTTP `POST /api/token/admin-challenge`. + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)`. + internal enum adminChallengeTokens { + internal static let id: Swift.String = "adminChallengeTokens" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.adminChallengeTokens.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.adminChallengeTokens.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.adminChallengeTokens.Input.Headers + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Usernames separated with commas + /// + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/requestBody/urlEncodedForm/users`. + internal var users: Swift.String + /// User visible description of the token + /// + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/requestBody/urlEncodedForm/description`. + internal var description: Swift.String + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - users: Usernames separated with commas + /// - description: User visible description of the token + internal init( + users: Swift.String, + description: Swift.String + ) { + self.users = users + self.description = description + } + internal enum CodingKeys: String, CodingKey { + case users + case description + } + } + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.adminChallengeTokens.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.adminChallengeTokens.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.adminChallengeTokens.Input.Headers = .init(), + body: Operations.adminChallengeTokens.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.adminChallengeTokens.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.adminChallengeTokens.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.adminChallengeTokens.Output.Ok.Headers = .init(), + body: Operations.adminChallengeTokens.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The `challenge:write` tokens of each user + /// + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.adminChallengeTokens.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.adminChallengeTokens.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/admin-challenge/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.adminChallengeTokens.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.adminChallengeTokens.Output.BadRequest.Body) { + self.body = body + } + } + /// The creation of the tokens failed. + /// + /// - Remark: Generated from `#/paths//api/token/admin-challenge/post(adminChallengeTokens)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.adminChallengeTokens.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.adminChallengeTokens.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Send a private message + /// + /// Send a private message to another player. + /// + /// + /// - Remark: HTTP `POST /inbox/{username}`. + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)`. + internal enum inboxUsername { + internal static let id: Swift.String = "inboxUsername" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/path/username`. + internal var username: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: + internal init(username: Swift.String) { + self.username = username + } + } + internal var path: Operations.inboxUsername.Input.Path + /// - Remark: Generated from `#/paths/inbox/{username}/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.inboxUsername.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.inboxUsername.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.inboxUsername.Input.Headers + /// - Remark: Generated from `#/paths/inbox/{username}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/requestBody/urlEncodedForm/text`. + internal var text: Swift.String + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - text: + internal init(text: Swift.String) { + self.text = text + } + internal enum CodingKeys: String, CodingKey { + case text + } + } + /// - Remark: Generated from `#/paths/inbox/{username}/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.inboxUsername.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.inboxUsername.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.inboxUsername.Input.Path, + headers: Operations.inboxUsername.Input.Headers = .init(), + body: Operations.inboxUsername.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.inboxUsername.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.inboxUsername.Output.Ok.Body) { + self.body = body + } + } + /// The private message has been successfully sent. + /// + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.inboxUsername.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.inboxUsername.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/inbox/{username}/POST/responses/400/content/application\/json`. + case json(Components.Schemas._Error) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas._Error { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.inboxUsername.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.inboxUsername.Output.BadRequest.Body) { + self.body = body + } + } + /// The sending of the private message has failed. + /// + /// - Remark: Generated from `#/paths//inbox/{username}/post(inboxUsername)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.inboxUsername.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.inboxUsername.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get cloud evaluation of a position. + /// + /// Get the cached evaluation of a position, if available. + /// Opening positions have more chances of being available. There are about 15 million positions in the database. + /// Up to 5 variations may be available. Variants are supported. + /// Use this endpoint to fetch a few positions here and there. + /// If you want to download a lot of positions, [get the full list](https://database.lichess.org/#evals) from our exported database. + /// + /// + /// - Remark: HTTP `GET /api/cloud-eval`. + /// - Remark: Generated from `#/paths//api/cloud-eval/get(apiCloudEval)`. + internal enum apiCloudEval { + internal static let id: Swift.String = "apiCloudEval" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/query`. + internal struct Query: Sendable, Hashable { + /// FEN of the position + /// + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/query/fen`. + internal var fen: Swift.String + /// Number of variations + /// + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/query/multiPv`. + internal var multiPv: Swift.Double? + /// Variant + /// + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/query/variant`. + internal var variant: Components.Schemas.VariantKey? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - fen: FEN of the position + /// - multiPv: Number of variations + /// - variant: Variant + internal init( + fen: Swift.String, + multiPv: Swift.Double? = nil, + variant: Components.Schemas.VariantKey? = nil + ) { + self.fen = fen + self.multiPv = multiPv + self.variant = variant + } + } + internal var query: Operations.apiCloudEval.Input.Query + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiCloudEval.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiCloudEval.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiCloudEval.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.apiCloudEval.Input.Query, + headers: Operations.apiCloudEval.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiCloudEval.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/cloud-eval/GET/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiCloudEval.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiCloudEval.Output.Ok.Headers = .init(), + body: Operations.apiCloudEval.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The evaluation of the position. + /// + /// - Remark: Generated from `#/paths//api/cloud-eval/get(apiCloudEval)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiCloudEval.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiCloudEval.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// List external engines + /// + /// Lists all external engines that have been registered for the user, + /// and the credentials required to use them. + /// + /// + /// - Remark: HTTP `GET /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/get(apiExternalEngineList)`. + internal enum apiExternalEngineList { + internal static let id: Swift.String = "apiExternalEngineList" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineList.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineList.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineList.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.apiExternalEngineList.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineList.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/GET/responses/200/content/application\/json`. + case json([Components.Schemas.ExternalEngine]) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: [Components.Schemas.ExternalEngine] { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineList.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEngineList.Output.Ok.Headers = .init(), + body: Operations.apiExternalEngineList.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// A list of external engines. + /// + /// - Remark: Generated from `#/paths//api/external-engine/get(apiExternalEngineList)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineList.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineList.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Create external engine + /// + /// Registers a new external engine for the user. It can then be selected + /// and used on the analysis board. + /// After registering, the provider should start waiting for analyis requests. + /// + /// + /// - Remark: HTTP `POST /api/external-engine`. + /// - Remark: Generated from `#/paths//api/external-engine/post(apiExternalEngineCreate)`. + internal enum apiExternalEngineCreate { + internal static let id: Swift.String = "apiExternalEngineCreate" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineCreate.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineCreate.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineCreate.Input.Headers + /// - Remark: Generated from `#/paths/api/external-engine/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/POST/requestBody/content/application\/json`. + case json(Components.Schemas.ExternalEngineRegistration) + } + internal var body: Operations.apiExternalEngineCreate.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiExternalEngineCreate.Input.Headers = .init(), + body: Operations.apiExternalEngineCreate.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineCreate.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/POST/responses/200/content/application\/json`. + case json(Components.Schemas.ExternalEngine) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ExternalEngine { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineCreate.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEngineCreate.Output.Ok.Headers = .init(), + body: Operations.apiExternalEngineCreate.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The registered engine. + /// + /// - Remark: Generated from `#/paths//api/external-engine/post(apiExternalEngineCreate)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineCreate.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineCreate.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Get external engine + /// + /// Get properties and credentials of an external engine. + /// + /// + /// - Remark: HTTP `GET /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/get(apiExternalEngineGet)`. + internal enum apiExternalEngineGet { + internal static let id: Swift.String = "apiExternalEngineGet" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/path`. + internal struct Path: Sendable, Hashable { + /// The external engine id. + /// + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The external engine id. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiExternalEngineGet.Input.Path + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineGet.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineGet.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineGet.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiExternalEngineGet.Input.Path, + headers: Operations.apiExternalEngineGet.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineGet.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/GET/responses/200/content/application\/json`. + case json(Components.Schemas.ExternalEngine) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ExternalEngine { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineGet.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEngineGet.Output.Ok.Headers = .init(), + body: Operations.apiExternalEngineGet.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// A registered engine. + /// + /// - Remark: Generated from `#/paths//api/external-engine/{id}/get(apiExternalEngineGet)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineGet.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineGet.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Update external engine + /// + /// Updates the properties of an external engine. + /// + /// + /// - Remark: HTTP `PUT /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/put(apiExternalEnginePut)`. + internal enum apiExternalEnginePut { + internal static let id: Swift.String = "apiExternalEnginePut" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/path`. + internal struct Path: Sendable, Hashable { + /// The external engine id. + /// + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The external engine id. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiExternalEnginePut.Input.Path + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEnginePut.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEnginePut.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEnginePut.Input.Headers + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/requestBody/content/application\/json`. + case json(Components.Schemas.ExternalEngineRegistration) + } + internal var body: Operations.apiExternalEnginePut.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiExternalEnginePut.Input.Path, + headers: Operations.apiExternalEnginePut.Input.Headers = .init(), + body: Operations.apiExternalEnginePut.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEnginePut.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/PUT/responses/200/content/application\/json`. + case json(Components.Schemas.ExternalEngine) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.ExternalEngine { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEnginePut.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEnginePut.Output.Ok.Headers = .init(), + body: Operations.apiExternalEnginePut.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// A registered engine. + /// + /// - Remark: Generated from `#/paths//api/external-engine/{id}/put(apiExternalEnginePut)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEnginePut.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEnginePut.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Delete external engine + /// + /// Unregisters an external engine. + /// + /// + /// - Remark: HTTP `DELETE /api/external-engine/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/delete(apiExternalEngineDelete)`. + internal enum apiExternalEngineDelete { + internal static let id: Swift.String = "apiExternalEngineDelete" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/DELETE/path`. + internal struct Path: Sendable, Hashable { + /// The external engine id. + /// + /// - Remark: Generated from `#/paths/api/external-engine/{id}/DELETE/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The external engine id. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiExternalEngineDelete.Input.Path + /// - Remark: Generated from `#/paths/api/external-engine/{id}/DELETE/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineDelete.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineDelete.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineDelete.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.apiExternalEngineDelete.Input.Path, + headers: Operations.apiExternalEngineDelete.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/DELETE/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/DELETE/responses/200/content/application\/json`. + case json(Components.Schemas.Ok) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.Ok { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineDelete.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.apiExternalEngineDelete.Output.Ok.Body) { + self.body = body + } + } + /// Engine successfully deleted + /// + /// - Remark: Generated from `#/paths//api/external-engine/{id}/delete(apiExternalEngineDelete)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineDelete.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineDelete.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Analyse with external engine + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/{id}/analyse`** + /// Request analysis from an external engine. + /// Response content is streamed as [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). + /// The properties are based on the [UCI specification](https://backscattering.de/chess/uci/#engine). + /// Analysis stops when the client goes away, the requested limit + /// is reached, or the provider goes away. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/{id}/analyse`. + /// - Remark: Generated from `#/paths//api/external-engine/{id}/analyse/post(apiExternalEngineAnalyse)`. + internal enum apiExternalEngineAnalyse { + internal static let id: Swift.String = "apiExternalEngineAnalyse" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/path`. + internal struct Path: Sendable, Hashable { + /// The external engine id. + /// + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: The external engine id. + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiExternalEngineAnalyse.Input.Path + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineAnalyse.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineAnalyse.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineAnalyse.Input.Headers + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/requestBody/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/requestBody/json/clientSecret`. + internal var clientSecret: Swift.String + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/requestBody/json/work`. + internal var work: Components.Schemas.ExternalEngineWork + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - clientSecret: + /// - work: + internal init( + clientSecret: Swift.String, + work: Components.Schemas.ExternalEngineWork + ) { + self.clientSecret = clientSecret + self.work = work + } + internal enum CodingKeys: String, CodingKey { + case clientSecret + case work + } + } + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/requestBody/content/application\/json`. + case json(Operations.apiExternalEngineAnalyse.Input.Body.jsonPayload) + } + internal var body: Operations.apiExternalEngineAnalyse.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + /// - body: + internal init( + path: Operations.apiExternalEngineAnalyse.Input.Path, + headers: Operations.apiExternalEngineAnalyse.Input.Headers = .init(), + body: Operations.apiExternalEngineAnalyse.Input.Body + ) { + self.path = path + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineAnalyse.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/{id}/analyse/POST/responses/200/content/application\/x-ndjson`. + case application_x_hyphen_ndjson(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_ndjson`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_ndjson`. + /// - SeeAlso: `.application_x_hyphen_ndjson`. + internal var application_x_hyphen_ndjson: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_ndjson(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineAnalyse.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEngineAnalyse.Output.Ok.Headers = .init(), + body: Operations.apiExternalEngineAnalyse.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Stream of analysis output + /// + /// - Remark: Generated from `#/paths//api/external-engine/{id}/analyse/post(apiExternalEngineAnalyse)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineAnalyse.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineAnalyse.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_ndjson + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-ndjson": + self = .application_x_hyphen_ndjson + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_ndjson: + return "application/x-ndjson" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_ndjson + ] + } + } + } + /// Acquire analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work`** + /// Wait for an analysis requests to any of the external engines that + /// have been registered with the given `secret`. + /// Uses long polling. + /// After acquiring a request, the provider should immediately + /// [start streaming the results](#tag/External-engine/operation/apiExternalEngineSubmit). + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work`. + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)`. + internal enum apiExternalEngineAcquire { + internal static let id: Swift.String = "apiExternalEngineAcquire" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineAcquire.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiExternalEngineAcquire.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiExternalEngineAcquire.Input.Headers + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/requestBody/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/requestBody/json/providerSecret`. + internal var providerSecret: Swift.String? + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - providerSecret: + internal init(providerSecret: Swift.String? = nil) { + self.providerSecret = providerSecret + } + internal enum CodingKeys: String, CodingKey { + case providerSecret + } + } + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/requestBody/content/application\/json`. + case json(Operations.apiExternalEngineAcquire.Input.Body.jsonPayload) + } + internal var body: Operations.apiExternalEngineAcquire.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiExternalEngineAcquire.Input.Headers = .init(), + body: Operations.apiExternalEngineAcquire.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineAcquire.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content/json/id`. + internal var id: Swift.String + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content/json/work`. + internal var work: Components.Schemas.ExternalEngineWork + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content/json/engine`. + internal var engine: Components.Schemas.ExternalEngine + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - id: + /// - work: + /// - engine: + internal init( + id: Swift.String, + work: Components.Schemas.ExternalEngineWork, + engine: Components.Schemas.ExternalEngine + ) { + self.id = id + self.work = work + self.engine = engine + } + internal enum CodingKeys: String, CodingKey { + case id + case work + case engine + } + } + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/200/content/application\/json`. + case json(Operations.apiExternalEngineAcquire.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.apiExternalEngineAcquire.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiExternalEngineAcquire.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiExternalEngineAcquire.Output.Ok.Headers = .init(), + body: Operations.apiExternalEngineAcquire.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Analysis has been requested + /// + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineAcquire.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineAcquire.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct NoContent: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/204/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/POST/responses/204/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineAcquire.Output.NoContent.Headers + /// Creates a new `NoContent`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.apiExternalEngineAcquire.Output.NoContent.Headers = .init()) { + self.headers = headers + } + } + /// No pending analysis + /// + /// - Remark: Generated from `#/paths//api/external-engine/work/post(apiExternalEngineAcquire)/responses/204`. + /// + /// HTTP response code: `204 noContent`. + case noContent(Operations.apiExternalEngineAcquire.Output.NoContent) + /// The associated value of the enum case if `self` is `.noContent`. + /// + /// - Throws: An error if `self` is not `.noContent`. + /// - SeeAlso: `.noContent`. + internal var noContent: Operations.apiExternalEngineAcquire.Output.NoContent { + get throws { + switch self { + case let .noContent(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "noContent", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Answer analysis request + /// + /// **Endpoint: `https://engine.lichess.ovh/api/external-engine/work/{id}`** + /// Submit a stream of analysis as [UCI output](https://backscattering.de/chess/uci/#engine-info). + /// * The engine should always be in `UCI_Chess960` mode. + /// * `UCI_AnalyseMode` enabled if available. + /// * It produces `info` with at least: + /// - `depth` + /// - `multipv` (between 1 and 5) + /// - `score` + /// - `nodes` + /// - `time` + /// - `pv` + /// The server may close the connection at any time, indicating that + /// the requester has gone away and analysis should be stopped. + /// + /// + /// - Remark: HTTP `POST /api/external-engine/work/{id}`. + /// - Remark: Generated from `#/paths//api/external-engine/work/{id}/post(apiExternalEngineSubmit)`. + internal enum apiExternalEngineSubmit { + internal static let id: Swift.String = "apiExternalEngineSubmit" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/path/id`. + internal var id: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - id: + internal init(id: Swift.String) { + self.id = id + } + } + internal var path: Operations.apiExternalEngineSubmit.Input.Path + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.apiExternalEngineSubmit.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - body: + internal init( + path: Operations.apiExternalEngineSubmit.Input.Path, + body: Operations.apiExternalEngineSubmit.Input.Body + ) { + self.path = path + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/external-engine/work/{id}/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiExternalEngineSubmit.Output.Ok.Headers + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.apiExternalEngineSubmit.Output.Ok.Headers = .init()) { + self.headers = headers + } + } + /// Thanks + /// + /// - Remark: Generated from `#/paths//api/external-engine/work/{id}/post(apiExternalEngineSubmit)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiExternalEngineSubmit.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiExternalEngineSubmit.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + } + /// Request authorization code + /// + /// OAuth2 authorization endpoint. + /// Start the OAuth2 Authorization Code Flow with PKCE by securely + /// generating two random strings unique to each authorization + /// request: + /// * `code_verifier` + /// * `state` + /// Store these in session storage. Make sure not to reveal `code_verifier` + /// to eavesdroppers. Do not show it in URLs, do not abuse `state` to store + /// it, do not send it over insecure connections. However it is fine if + /// the user themselves can extract `code_verifier`, which will always be + /// possible for fully client-side apps. + /// Then send the user to this endpoint. They will be prompted to grant + /// authorization and then be redirected back to the given `redirect_uri`. + /// If the authorization failed, the following query string parameters will + /// be appended to the redirection: + /// * `error`, in particular with value `access_denied` if the user + /// cancelled authorization + /// * `error_description` to aid debugging + /// * `state`, exactly as passed in the `state` parameter + /// If the authorization succeeded, the following query string parameters + /// will be appended to the redirection: + /// * `code`, containing a fresh short-lived authorization code + /// * `state`, exactly as passed in the `state` parameter + /// Next, to defend against cross site request forgery, check that the + /// returned `state` matches the `state` you originally generated. + /// Finally, continue by using the authorization code to + /// [obtain an access token](#operation/apiToken). + /// + /// + /// - Remark: HTTP `GET /oauth`. + /// - Remark: Generated from `#/paths//oauth/get(oauth)`. + internal enum oauth { + internal static let id: Swift.String = "oauth" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/oauth/GET/query`. + internal struct Query: Sendable, Hashable { + /// Must be `code`. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/response_type`. + internal var response_type: Swift.String + /// Arbitrary identifier that uniquely identifies your application. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/client_id`. + internal var client_id: Swift.String + /// The absolute URL that the user should be redirected to with the authorization result. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/redirect_uri`. + internal var redirect_uri: Swift.String + /// Must be `S256`. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/code_challenge_method`. + internal var code_challenge_method: Swift.String + /// Compute `BASE64URL(SHA256(code_verifier))`. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/code_challenge`. + internal var code_challenge: Swift.String + /// Space separated list of requested OAuth scopes, if any. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/scope`. + internal var scope: Swift.String? + /// Hint that you want the user to log in with a specific Lichess username. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/username`. + internal var username: Swift.String? + /// Arbitrary state that will be returned verbatim with the authorization result. + /// + /// - Remark: Generated from `#/paths/oauth/GET/query/state`. + internal var state: Swift.String? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - response_type: Must be `code`. + /// - client_id: Arbitrary identifier that uniquely identifies your application. + /// - redirect_uri: The absolute URL that the user should be redirected to with the authorization result. + /// - code_challenge_method: Must be `S256`. + /// - code_challenge: Compute `BASE64URL(SHA256(code_verifier))`. + /// - scope: Space separated list of requested OAuth scopes, if any. + /// - username: Hint that you want the user to log in with a specific Lichess username. + /// - state: Arbitrary state that will be returned verbatim with the authorization result. + internal init( + response_type: Swift.String, + client_id: Swift.String, + redirect_uri: Swift.String, + code_challenge_method: Swift.String, + code_challenge: Swift.String, + scope: Swift.String? = nil, + username: Swift.String? = nil, + state: Swift.String? = nil + ) { + self.response_type = response_type + self.client_id = client_id + self.redirect_uri = redirect_uri + self.code_challenge_method = code_challenge_method + self.code_challenge = code_challenge + self.scope = scope + self.username = username + self.state = state + } + } + internal var query: Operations.oauth.Input.Query + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + internal init(query: Operations.oauth.Input.Query) { + self.query = query + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// Creates a new `Ok`. + internal init() {} + } + /// Authorization prompt will be displayed to the user. + /// + /// - Remark: Generated from `#/paths//oauth/get(oauth)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.oauth.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.oauth.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + } + /// Obtain access token + /// + /// OAuth2 token endpoint. Exchanges an authorization code for an access token. + /// + /// + /// - Remark: HTTP `POST /api/token`. + /// - Remark: Generated from `#/paths//api/token/post(apiToken)`. + internal enum apiToken { + internal static let id: Swift.String = "apiToken" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiToken.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.apiToken.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.apiToken.Input.Headers + /// - Remark: Generated from `#/paths/api/token/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm`. + internal struct urlEncodedFormPayload: Codable, Hashable, Sendable { + /// Must be `authorization_code`. + /// + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm/grant_type`. + internal var grant_type: Swift.String? + /// The authorization code that was sent in the `code` parameter to your `redirect_uri`. + /// + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm/code`. + internal var code: Swift.String? + /// A `code_challenge` was used to request the authorization code. This must be the `code_verifier` it was derived from. + /// + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm/code_verifier`. + internal var code_verifier: Swift.String? + /// Must match the `redirect_uri` used to request the authorization code. + /// + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm/redirect_uri`. + internal var redirect_uri: Swift.String? + /// Must match the `client_id` used to request the authorization code. + /// + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/urlEncodedForm/client_id`. + internal var client_id: Swift.String? + /// Creates a new `urlEncodedFormPayload`. + /// + /// - Parameters: + /// - grant_type: Must be `authorization_code`. + /// - code: The authorization code that was sent in the `code` parameter to your `redirect_uri`. + /// - code_verifier: A `code_challenge` was used to request the authorization code. This must be the `code_verifier` it was derived from. + /// - redirect_uri: Must match the `redirect_uri` used to request the authorization code. + /// - client_id: Must match the `client_id` used to request the authorization code. + internal init( + grant_type: Swift.String? = nil, + code: Swift.String? = nil, + code_verifier: Swift.String? = nil, + redirect_uri: Swift.String? = nil, + client_id: Swift.String? = nil + ) { + self.grant_type = grant_type + self.code = code + self.code_verifier = code_verifier + self.redirect_uri = redirect_uri + self.client_id = client_id + } + internal enum CodingKeys: String, CodingKey { + case grant_type + case code + case code_verifier + case redirect_uri + case client_id + } + } + /// - Remark: Generated from `#/paths/api/token/POST/requestBody/content/application\/x-www-form-urlencoded`. + case urlEncodedForm(Operations.apiToken.Input.Body.urlEncodedFormPayload) + } + internal var body: Operations.apiToken.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.apiToken.Input.Headers = .init(), + body: Operations.apiToken.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiToken.Output.Ok.Headers + /// - Remark: Generated from `#/paths/api/token/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/200/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIValueContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: OpenAPIRuntime.OpenAPIValueContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiToken.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiToken.Output.Ok.Headers = .init(), + body: Operations.apiToken.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Access token successfully obtained. + /// + /// - Remark: Generated from `#/paths//api/token/post(apiToken)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.apiToken.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.apiToken.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + internal struct BadRequest: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/400/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/400/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiToken.Output.BadRequest.Headers + /// - Remark: Generated from `#/paths/api/token/POST/responses/400/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/POST/responses/400/content/application\/json`. + case json(Components.Schemas.OAuthError) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.OAuthError { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.apiToken.Output.BadRequest.Body + /// Creates a new `BadRequest`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.apiToken.Output.BadRequest.Headers = .init(), + body: Operations.apiToken.Output.BadRequest.Body + ) { + self.headers = headers + self.body = body + } + } + /// Failed to obtain access token. + /// + /// - Remark: Generated from `#/paths//api/token/post(apiToken)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Operations.apiToken.Output.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + internal var badRequest: Operations.apiToken.Output.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Revoke access token + /// + /// Revokes the access token sent as Bearer for this request. + /// + /// - Remark: HTTP `DELETE /api/token`. + /// - Remark: Generated from `#/paths//api/token/delete(apiTokenDelete)`. + internal enum apiTokenDelete { + internal static let id: Swift.String = "apiTokenDelete" + internal struct Input: Sendable, Hashable { + /// Creates a new `Input`. + internal init() {} + } + @frozen internal enum Output: Sendable, Hashable { + internal struct NoContent: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/DELETE/responses/204/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/DELETE/responses/204/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.apiTokenDelete.Output.NoContent.Headers + /// Creates a new `NoContent`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + internal init(headers: Operations.apiTokenDelete.Output.NoContent.Headers = .init()) { + self.headers = headers + } + } + /// Access token revoked. + /// + /// - Remark: Generated from `#/paths//api/token/delete(apiTokenDelete)/responses/204`. + /// + /// HTTP response code: `204 noContent`. + case noContent(Operations.apiTokenDelete.Output.NoContent) + /// The associated value of the enum case if `self` is `.noContent`. + /// + /// - Throws: An error if `self` is not `.noContent`. + /// - SeeAlso: `.noContent`. + internal var noContent: Operations.apiTokenDelete.Output.NoContent { + get throws { + switch self { + case let .noContent(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "noContent", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + } + /// Test multiple OAuth tokens + /// + /// For up to 1000 OAuth tokens, + /// returns their associated user ID and scopes, + /// or `null` if the token is invalid. + /// The method is `POST` so a longer list of tokens can be sent in the request body. + /// + /// + /// - Remark: HTTP `POST /api/token/test`. + /// - Remark: Generated from `#/paths//api/token/test/post(tokenTest)`. + internal enum tokenTest { + internal static let id: Swift.String = "tokenTest" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/test/POST/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tokenTest.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tokenTest.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tokenTest.Input.Headers + /// - Remark: Generated from `#/paths/api/token/test/POST/requestBody`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/test/POST/requestBody/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + } + internal var body: Operations.tokenTest.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + internal init( + headers: Operations.tokenTest.Input.Headers = .init(), + body: Operations.tokenTest.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json`. + internal struct jsonPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties`. + @frozen internal enum additionalPropertiesPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case1`. + internal struct Case1Payload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case1/userId`. + internal var userId: Swift.String? + /// Comma-separated list of scopes. Empty string if the token has no scopes. + /// + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case1/scopes`. + internal var scopes: Swift.String? + /// Unix-timestampe in milliseconds or null if the token never expires. + /// + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case1/expires`. + internal var expires: Swift.Int? + /// Creates a new `Case1Payload`. + /// + /// - Parameters: + /// - userId: + /// - scopes: Comma-separated list of scopes. Empty string if the token has no scopes. + /// - expires: Unix-timestampe in milliseconds or null if the token never expires. + internal init( + userId: Swift.String? = nil, + scopes: Swift.String? = nil, + expires: Swift.Int? = nil + ) { + self.userId = userId + self.scopes = scopes + self.expires = expires + } + internal enum CodingKeys: String, CodingKey { + case userId + case scopes + case expires + } + } + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case1`. + case case1(Operations.tokenTest.Output.Ok.Body.jsonPayload.additionalPropertiesPayload.Case1Payload) + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/json/additionalProperties/case2`. + case case2(OpenAPIRuntime.OpenAPIValueContainer) + internal init(from decoder: any Decoder) throws { + var errors: [any Error] = [] + do { + self = .case1(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + do { + self = .case2(try .init(from: decoder)) + return + } catch { + errors.append(error) + } + throw Swift.DecodingError.failedToDecodeOneOfSchema( + type: Self.self, + codingPath: decoder.codingPath, + errors: errors + ) + } + internal func encode(to encoder: any Encoder) throws { + switch self { + case let .case1(value): + try value.encode(to: encoder) + case let .case2(value): + try value.encode(to: encoder) + } + } + } + /// A container of undocumented properties. + internal var additionalProperties: [String: Operations.tokenTest.Output.Ok.Body.jsonPayload.additionalPropertiesPayload] + /// Creates a new `jsonPayload`. + /// + /// - Parameters: + /// - additionalProperties: A container of undocumented properties. + internal init(additionalProperties: [String: Operations.tokenTest.Output.Ok.Body.jsonPayload.additionalPropertiesPayload] = .init()) { + self.additionalProperties = additionalProperties + } + internal init(from decoder: any Decoder) throws { + additionalProperties = try decoder.decodeAdditionalProperties(knownKeys: []) + } + internal func encode(to encoder: any Encoder) throws { + try encoder.encodeAdditionalProperties(additionalProperties) + } + } + /// - Remark: Generated from `#/paths/api/token/test/POST/responses/200/content/application\/json`. + case json(Operations.tokenTest.Output.Ok.Body.jsonPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Operations.tokenTest.Output.Ok.Body.jsonPayload { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tokenTest.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + internal init(body: Operations.tokenTest.Output.Ok.Body) { + self.body = body + } + } + /// The representation of the OAuth tokens. + /// + /// - Remark: Generated from `#/paths//api/token/test/post(tokenTest)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tokenTest.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tokenTest.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Masters database + /// + /// **Endpoint: <https://explorer.lichess.ovh/masters>** + /// Example: `curl https://explorer.lichess.ovh/masters?play=d2d4,d7d5,c2c4,c7c6,c4d5` + /// + /// + /// - Remark: HTTP `GET /masters`. + /// - Remark: Generated from `#/paths//masters/get(openingExplorerMaster)`. + internal enum openingExplorerMaster { + internal static let id: Swift.String = "openingExplorerMaster" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/masters/GET/query`. + internal struct Query: Sendable, Hashable { + /// FEN of the root position + /// + /// - Remark: Generated from `#/paths/masters/GET/query/fen`. + internal var fen: Swift.String? + /// Comma separated sequence of legal moves in UCI notation. + /// Play additional moves starting from `fen`. + /// Required to find an opening name, if `fen` is not an exact match + /// for a named position. + /// + /// + /// - Remark: Generated from `#/paths/masters/GET/query/play`. + internal var play: Swift.String? + /// Include only games from this year or later + /// + /// - Remark: Generated from `#/paths/masters/GET/query/since`. + internal var since: Swift.Double? + /// Include only games from this year or earlier + /// + /// - Remark: Generated from `#/paths/masters/GET/query/until`. + internal var until: Swift.Double? + /// Number of most common moves to display + /// + /// - Remark: Generated from `#/paths/masters/GET/query/moves`. + internal var moves: Swift.Double? + /// Number of top games to display + /// + /// - Remark: Generated from `#/paths/masters/GET/query/topGames`. + internal var topGames: Swift.Double? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - fen: FEN of the root position + /// - play: Comma separated sequence of legal moves in UCI notation. + /// - since: Include only games from this year or later + /// - until: Include only games from this year or earlier + /// - moves: Number of most common moves to display + /// - topGames: Number of top games to display + internal init( + fen: Swift.String? = nil, + play: Swift.String? = nil, + since: Swift.Double? = nil, + until: Swift.Double? = nil, + moves: Swift.Double? = nil, + topGames: Swift.Double? = nil + ) { + self.fen = fen + self.play = play + self.since = since + self.until = until + self.moves = moves + self.topGames = topGames + } + } + internal var query: Operations.openingExplorerMaster.Input.Query + /// - Remark: Generated from `#/paths/masters/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerMaster.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerMaster.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.openingExplorerMaster.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.openingExplorerMaster.Input.Query = .init(), + headers: Operations.openingExplorerMaster.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/masters/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/masters/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.openingExplorerMaster.Output.Ok.Headers + /// - Remark: Generated from `#/paths/masters/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/masters/GET/responses/200/content/application\/json`. + case json(Components.Schemas.OpeningExplorerJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.OpeningExplorerJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.openingExplorerMaster.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.openingExplorerMaster.Output.Ok.Headers = .init(), + body: Operations.openingExplorerMaster.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Opening statistics and game references for the position. + /// + /// - Remark: Generated from `#/paths//masters/get(openingExplorerMaster)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.openingExplorerMaster.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.openingExplorerMaster.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Lichess games + /// + /// **Endpoint: <https://explorer.lichess.ovh/lichess>** + /// Games sampled from all Lichess players. + /// Example: `curl https://explorer.lichess.ovh/lichess?variant=standard&speeds=blitz,rapid,classical&ratings=2200,2500&fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201` + /// + /// + /// - Remark: HTTP `GET /lichess`. + /// - Remark: Generated from `#/paths//lichess/get(openingExplorerLichess)`. + internal enum openingExplorerLichess { + internal static let id: Swift.String = "openingExplorerLichess" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/lichess/GET/query`. + internal struct Query: Sendable, Hashable { + /// Variant + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/variant`. + internal var variant: Components.Schemas.VariantKey? + /// FEN or EPD of the root position + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/fen`. + internal var fen: Swift.String? + /// Comma separated sequence of legal moves in UCI notation. + /// Play additional moves starting from `fen`. + /// Required to find an opening name, if `fen` is not an exact match + /// for a named position. + /// + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/play`. + internal var play: Swift.String? + /// Comma separated list of game speeds to filter by + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/speeds`. + internal var speeds: [Components.Schemas.Speed]? + /// Comma separated list of ratings groups to filter by. + /// Each group ranges from its value to the next higher + /// group in the enum (`0` from 0 to 999, `1000` from 1000 to 1199, + /// ..., `2500` from 2500 to any rating above). + /// + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/ratings`. + internal var ratings: [Swift.Double]? + /// Include only games from this month or later + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/since`. + internal var since: Swift.String? + /// Include only games from this month or earlier + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/until`. + internal var until: Swift.String? + /// Number of most common moves to display + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/moves`. + internal var moves: Swift.Double? + /// Number of top games to display + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/topGames`. + internal var topGames: Swift.Double? + /// Number of recent games to display + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/recentGames`. + internal var recentGames: Swift.Double? + /// Optionally retrieve history + /// + /// - Remark: Generated from `#/paths/lichess/GET/query/history`. + internal var history: Swift.Bool? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - variant: Variant + /// - fen: FEN or EPD of the root position + /// - play: Comma separated sequence of legal moves in UCI notation. + /// - speeds: Comma separated list of game speeds to filter by + /// - ratings: Comma separated list of ratings groups to filter by. + /// - since: Include only games from this month or later + /// - until: Include only games from this month or earlier + /// - moves: Number of most common moves to display + /// - topGames: Number of top games to display + /// - recentGames: Number of recent games to display + /// - history: Optionally retrieve history + internal init( + variant: Components.Schemas.VariantKey? = nil, + fen: Swift.String? = nil, + play: Swift.String? = nil, + speeds: [Components.Schemas.Speed]? = nil, + ratings: [Swift.Double]? = nil, + since: Swift.String? = nil, + until: Swift.String? = nil, + moves: Swift.Double? = nil, + topGames: Swift.Double? = nil, + recentGames: Swift.Double? = nil, + history: Swift.Bool? = nil + ) { + self.variant = variant + self.fen = fen + self.play = play + self.speeds = speeds + self.ratings = ratings + self.since = since + self.until = until + self.moves = moves + self.topGames = topGames + self.recentGames = recentGames + self.history = history + } + } + internal var query: Operations.openingExplorerLichess.Input.Query + /// - Remark: Generated from `#/paths/lichess/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerLichess.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerLichess.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.openingExplorerLichess.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.openingExplorerLichess.Input.Query = .init(), + headers: Operations.openingExplorerLichess.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/lichess/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/lichess/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.openingExplorerLichess.Output.Ok.Headers + /// - Remark: Generated from `#/paths/lichess/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/lichess/GET/responses/200/content/application\/json`. + case json(Components.Schemas.OpeningExplorerJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.OpeningExplorerJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.openingExplorerLichess.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.openingExplorerLichess.Output.Ok.Headers = .init(), + body: Operations.openingExplorerLichess.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Opening statistics and game references for the position. + /// + /// - Remark: Generated from `#/paths//lichess/get(openingExplorerLichess)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.openingExplorerLichess.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.openingExplorerLichess.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Player games + /// + /// **Endpoint: <https://explorer.lichess.ovh/player>** + /// Games of a Lichess player. + /// Responds with a stream of [newline delimited JSON](#section/Introduction/Streaming-with-ND-JSON). Will start indexing + /// on demand, immediately respond with the current results, and stream + /// more updates until indexing is complete. The stream is throttled + /// and deduplicated. Empty lines may be sent to avoid timeouts. + /// Will index new games at most once per minute, and revisit previously + /// ongoing games at most once every day. + /// Example: `curl https://explorer.lichess.ovh/player?player=revoof&color=white&play=d2d4,d7d5&recentGames=1` + /// + /// + /// - Remark: HTTP `GET /player`. + /// - Remark: Generated from `#/paths//player/get(openingExplorerPlayer)`. + internal enum openingExplorerPlayer { + internal static let id: Swift.String = "openingExplorerPlayer" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/player/GET/query`. + internal struct Query: Sendable, Hashable { + /// Username or ID of the player + /// + /// - Remark: Generated from `#/paths/player/GET/query/player`. + internal var player: Swift.String? + /// Variant + /// + /// - Remark: Generated from `#/paths/player/GET/query/variant`. + internal var variant: Components.Schemas.VariantKey? + /// FEN of the root position + /// + /// - Remark: Generated from `#/paths/player/GET/query/fen`. + internal var fen: Swift.String? + /// Comma separated sequence of legal moves in UCI notation. + /// Play additional moves starting from `fen`. + /// Required to find an opening name, if `fen` is not an exact match + /// for a named position. + /// + /// + /// - Remark: Generated from `#/paths/player/GET/query/play`. + internal var play: Swift.String? + /// Comma separated list of game speeds to look for + /// + /// - Remark: Generated from `#/paths/player/GET/query/speeds`. + internal var speeds: [Components.Schemas.Speed]? + /// - Remark: Generated from `#/paths/player/GET/query/modesPayload`. + @frozen internal enum modesPayloadPayload: String, Codable, Hashable, Sendable { + case casual = "casual" + case rated = "rated" + } + /// - Remark: Generated from `#/paths/player/GET/query/modes`. + internal typealias modesPayload = [Operations.openingExplorerPlayer.Input.Query.modesPayloadPayload] + /// Comma separated list of modes + /// + /// - Remark: Generated from `#/paths/player/GET/query/modes`. + internal var modes: Operations.openingExplorerPlayer.Input.Query.modesPayload? + /// Include only games from this month or later + /// + /// - Remark: Generated from `#/paths/player/GET/query/since`. + internal var since: Swift.String? + /// Include only games from this month or earlier + /// + /// - Remark: Generated from `#/paths/player/GET/query/until`. + internal var until: Swift.String? + /// Number of most common moves to display + /// + /// - Remark: Generated from `#/paths/player/GET/query/moves`. + internal var moves: Swift.Double? + /// Number of recent games to display + /// + /// - Remark: Generated from `#/paths/player/GET/query/recentGames`. + internal var recentGames: Swift.Double? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - player: Username or ID of the player + /// - variant: Variant + /// - fen: FEN of the root position + /// - play: Comma separated sequence of legal moves in UCI notation. + /// - speeds: Comma separated list of game speeds to look for + /// - modes: Comma separated list of modes + /// - since: Include only games from this month or later + /// - until: Include only games from this month or earlier + /// - moves: Number of most common moves to display + /// - recentGames: Number of recent games to display + internal init( + player: Swift.String? = nil, + variant: Components.Schemas.VariantKey? = nil, + fen: Swift.String? = nil, + play: Swift.String? = nil, + speeds: [Components.Schemas.Speed]? = nil, + modes: Operations.openingExplorerPlayer.Input.Query.modesPayload? = nil, + since: Swift.String? = nil, + until: Swift.String? = nil, + moves: Swift.Double? = nil, + recentGames: Swift.Double? = nil + ) { + self.player = player + self.variant = variant + self.fen = fen + self.play = play + self.speeds = speeds + self.modes = modes + self.since = since + self.until = until + self.moves = moves + self.recentGames = recentGames + } + } + internal var query: Operations.openingExplorerPlayer.Input.Query + /// - Remark: Generated from `#/paths/player/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerPlayer.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerPlayer.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.openingExplorerPlayer.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.openingExplorerPlayer.Input.Query = .init(), + headers: Operations.openingExplorerPlayer.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/player/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/player/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.openingExplorerPlayer.Output.Ok.Headers + /// - Remark: Generated from `#/paths/player/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/player/GET/responses/200/content/application\/nd-json`. + case application_nd_hyphen_json(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_nd_hyphen_json`. + /// + /// - Throws: An error if `self` is not `.application_nd_hyphen_json`. + /// - SeeAlso: `.application_nd_hyphen_json`. + internal var application_nd_hyphen_json: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_nd_hyphen_json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.openingExplorerPlayer.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.openingExplorerPlayer.Output.Ok.Headers = .init(), + body: Operations.openingExplorerPlayer.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// Opening statistics and game references for the position. + /// + /// - Remark: Generated from `#/paths//player/get(openingExplorerPlayer)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.openingExplorerPlayer.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.openingExplorerPlayer.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_nd_hyphen_json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/nd-json": + self = .application_nd_hyphen_json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_nd_hyphen_json: + return "application/nd-json" + } + } + internal static var allCases: [Self] { + [ + .application_nd_hyphen_json + ] + } + } + } + /// OTB master game + /// + /// **Endpoint: `https://explorer.lichess.ovh/masters/pgn/{gameId}`** + /// Example: `curl https://explorer.lichess.ovh/masters/pgn/aAbqI4ey` + /// + /// + /// - Remark: HTTP `GET /master/pgn/{gameId}`. + /// - Remark: Generated from `#/paths//master/pgn/{gameId}/get(openingExplorerMasterGame)`. + internal enum openingExplorerMasterGame { + internal static let id: Swift.String = "openingExplorerMasterGame" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/path`. + internal struct Path: Sendable, Hashable { + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/path/gameId`. + internal var gameId: Swift.String + /// Creates a new `Path`. + /// + /// - Parameters: + /// - gameId: + internal init(gameId: Swift.String) { + self.gameId = gameId + } + } + internal var path: Operations.openingExplorerMasterGame.Input.Path + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerMasterGame.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.openingExplorerMasterGame.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.openingExplorerMasterGame.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + internal init( + path: Operations.openingExplorerMasterGame.Input.Path, + headers: Operations.openingExplorerMasterGame.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.openingExplorerMasterGame.Output.Ok.Headers + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/master/pgn/{gameId}/GET/responses/200/content/application\/x-chess-pgn`. + case application_x_hyphen_chess_hyphen_pgn(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.application_x_hyphen_chess_hyphen_pgn`. + /// + /// - Throws: An error if `self` is not `.application_x_hyphen_chess_hyphen_pgn`. + /// - SeeAlso: `.application_x_hyphen_chess_hyphen_pgn`. + internal var application_x_hyphen_chess_hyphen_pgn: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .application_x_hyphen_chess_hyphen_pgn(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.openingExplorerMasterGame.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.openingExplorerMasterGame.Output.Ok.Headers = .init(), + body: Operations.openingExplorerMasterGame.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The PGN representation of the game. + /// + /// - Remark: Generated from `#/paths//master/pgn/{gameId}/get(openingExplorerMasterGame)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.openingExplorerMasterGame.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.openingExplorerMasterGame.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case application_x_hyphen_chess_hyphen_pgn + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/x-chess-pgn": + self = .application_x_hyphen_chess_hyphen_pgn + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .application_x_hyphen_chess_hyphen_pgn: + return "application/x-chess-pgn" + } + } + internal static var allCases: [Self] { + [ + .application_x_hyphen_chess_hyphen_pgn + ] + } + } + } + /// Tablebase lookup + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// Example: `curl http://tablebase.lichess.ovh/standard?fen=4k3/6KP/8/8/8/8/7p/8_w_-_-_0_1` + /// + /// + /// - Remark: HTTP `GET /standard`. + /// - Remark: Generated from `#/paths//standard/get(tablebaseStandard)`. + internal enum tablebaseStandard { + internal static let id: Swift.String = "tablebaseStandard" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/standard/GET/query`. + internal struct Query: Sendable, Hashable { + /// FEN of the position. Underscores allowed. + /// + /// - Remark: Generated from `#/paths/standard/GET/query/fen`. + internal var fen: Swift.String + /// Creates a new `Query`. + /// + /// - Parameters: + /// - fen: FEN of the position. Underscores allowed. + internal init(fen: Swift.String) { + self.fen = fen + } + } + internal var query: Operations.tablebaseStandard.Input.Query + /// - Remark: Generated from `#/paths/standard/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tablebaseStandard.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tablebaseStandard.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tablebaseStandard.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - query: + /// - headers: + internal init( + query: Operations.tablebaseStandard.Input.Query, + headers: Operations.tablebaseStandard.Input.Headers = .init() + ) { + self.query = query + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/standard/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/standard/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.tablebaseStandard.Output.Ok.Headers + /// - Remark: Generated from `#/paths/standard/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/standard/GET/responses/200/content/application\/json`. + case json(Components.Schemas.TablebaseJson) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.TablebaseJson { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tablebaseStandard.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.tablebaseStandard.Output.Ok.Headers = .init(), + body: Operations.tablebaseStandard.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tablebase information for the position in standard chess. + /// + /// - Remark: Generated from `#/paths//standard/get(tablebaseStandard)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tablebaseStandard.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tablebaseStandard.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + internal static var allCases: [Self] { + [ + .json + ] + } + } + } + /// Tablebase lookup for Atomic chess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /atomic`. + /// - Remark: Generated from `#/paths//atomic/get(tablebaseAtomic)`. + internal enum tablebaseAtomic { + internal static let id: Swift.String = "tablebaseAtomic" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/atomic/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tablebaseAtomic.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.tablebaseAtomic.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.tablebaseAtomic.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.tablebaseAtomic.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/atomic/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/atomic/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.tablebaseAtomic.Output.Ok.Headers + /// - Remark: Generated from `#/paths/atomic/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/atomic/GET/responses/200/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.plainText`. + /// + /// - Throws: An error if `self` is not `.plainText`. + /// - SeeAlso: `.plainText`. + internal var plainText: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .plainText(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.tablebaseAtomic.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.tablebaseAtomic.Output.Ok.Headers = .init(), + body: Operations.tablebaseAtomic.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tablebase information for the position in atomic chess. + /// + /// - Remark: Generated from `#/paths//atomic/get(tablebaseAtomic)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.tablebaseAtomic.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.tablebaseAtomic.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case plainText + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "text/plain": + self = .plainText + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .plainText: + return "text/plain" + } + } + internal static var allCases: [Self] { + [ + .plainText + ] + } + } + } + /// Tablebase lookup for Antichess + /// + /// **Endpoint: <https://tablebase.lichess.ovh>** + /// + /// + /// - Remark: HTTP `GET /antichess`. + /// - Remark: Generated from `#/paths//antichess/get(antichessAtomic)`. + internal enum antichessAtomic { + internal static let id: Swift.String = "antichessAtomic" + internal struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/antichess/GET/header`. + internal struct Headers: Sendable, Hashable { + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.antichessAtomic.AcceptableContentType>] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.antichessAtomic.AcceptableContentType>] = .defaultValues()) { + self.accept = accept + } + } + internal var headers: Operations.antichessAtomic.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + internal init(headers: Operations.antichessAtomic.Input.Headers = .init()) { + self.headers = headers + } + } + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/antichess/GET/responses/200/headers`. + internal struct Headers: Sendable, Hashable { + /// - Remark: Generated from `#/paths/antichess/GET/responses/200/headers/Access-Control-Allow-Origin`. + internal var Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - Access_hyphen_Control_hyphen_Allow_hyphen_Origin: + internal init(Access_hyphen_Control_hyphen_Allow_hyphen_Origin: Swift.String? = nil) { + self.Access_hyphen_Control_hyphen_Allow_hyphen_Origin = Access_hyphen_Control_hyphen_Allow_hyphen_Origin + } + } + /// Received HTTP response headers + internal var headers: Operations.antichessAtomic.Output.Ok.Headers + /// - Remark: Generated from `#/paths/antichess/GET/responses/200/content`. + @frozen internal enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/antichess/GET/responses/200/content/text\/plain`. + case plainText(OpenAPIRuntime.HTTPBody) + /// The associated value of the enum case if `self` is `.plainText`. + /// + /// - Throws: An error if `self` is not `.plainText`. + /// - SeeAlso: `.plainText`. + internal var plainText: OpenAPIRuntime.HTTPBody { + get throws { + switch self { + case let .plainText(body): + return body + } + } + } + } + /// Received HTTP response body + internal var body: Operations.antichessAtomic.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - headers: Received HTTP response headers + /// - body: Received HTTP response body + internal init( + headers: Operations.antichessAtomic.Output.Ok.Headers = .init(), + body: Operations.antichessAtomic.Output.Ok.Body + ) { + self.headers = headers + self.body = body + } + } + /// The tablebase information for the position in antichess. + /// + /// - Remark: Generated from `#/paths//antichess/get(antichessAtomic)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.antichessAtomic.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.antichessAtomic.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen internal enum AcceptableContentType: AcceptableProtocol { + case plainText + case other(Swift.String) + internal init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "text/plain": + self = .plainText + default: + self = .other(rawValue) + } + } + internal var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .plainText: + return "text/plain" + } + } + internal static var allCases: [Self] { + [ + .plainText + ] + } + } + } +} |