ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.308.1

This commit is contained in:
speakeasybot
2024-06-15 00:13:58 +00:00
parent 2e61d70eb2
commit 3c7871adc5
46 changed files with 2104 additions and 858 deletions

View File

@@ -10,6 +10,15 @@ class _PlexAPI: PlexAPI {
self.client = client
}
public func getHomeData() async throws -> Response<Operations.GetHomeDataResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetHomeDataRequest(with: configuration)
},
handleResponse: handleGetHomeDataResponse
)
}
public func getPin(request: Operations.GetPinRequest, server: PlexServers.GetPin?) async throws -> Response<Operations.GetPinResponse> {
return try await client.makeRequest(
with: try server?.server() ?? PlexServers.GetPin.default(),
@@ -34,6 +43,12 @@ class _PlexAPI: PlexAPI {
// MARK: - Request Configuration
private func configureGetHomeDataRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/home"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetPinRequest(with configuration: URLRequestConfiguration, request: Operations.GetPinRequest) throws {
configuration.path = "/pins"
configuration.method = .post
@@ -52,13 +67,39 @@ private func configureGetTokenRequest(with configuration: URLRequestConfiguratio
// MARK: - Response Handlers
private func handleGetPinResponse(response: Client.APIResponse) throws -> Operations.GetPinResponse {
private func handleGetHomeDataResponse(response: Client.APIResponse) throws -> Operations.GetHomeDataResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetPinResponseBody.self, from: data))
return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetHomeDataResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
} else if httpResponse.statusCode == 400 {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .fourHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetHomeDataPlexResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetPinResponse(response: Client.APIResponse) throws -> Operations.GetPinResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 201 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .twoHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetPinResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
@@ -80,11 +121,17 @@ private func handleGetTokenResponse(response: Client.APIResponse) throws -> Oper
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
return .empty
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetTokenResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
} else if httpResponse.statusCode == 400 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetTokenResponseBody.self, from: data))
return .fourHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetTokenPlexResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}

View File

@@ -0,0 +1,62 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _WatchlistAPI: WatchlistAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getWatchlist(request: Operations.GetWatchlistRequest, server: WatchlistServers.GetWatchlist?) async throws -> Response<Operations.GetWatchlistResponse> {
return try await client.makeRequest(
with: try server?.server() ?? WatchlistServers.GetWatchlist.default(),
configureRequest: { configuration in
try configureGetWatchlistRequest(with: configuration, request: request)
},
handleResponse: handleGetWatchlistResponse
)
}
}
// MARK: - Request Configuration
private func configureGetWatchlistRequest(with configuration: URLRequestConfiguration, request: Operations.GetWatchlistRequest) throws {
configuration.path = "/library/sections/watchlist/{filter}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetWatchlistResponse(response: Client.APIResponse) throws -> Operations.GetWatchlistResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetWatchlistResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
} else if httpResponse.statusCode == 400 {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .fourHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetWatchlistWatchlistResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Filter: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try rawValue.serialize(with: format)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}

View File

@@ -31,6 +31,7 @@ extension Operations.GetPinRequest: QueryParameterSerializable {
extension Operations.GetPinRequest: HeaderParameterSerializable {
func serializedHeaderParameters() throws -> [SerializedParameter] {
return [
SerializedParameter(name: "X-Plex-Product", serialized: try xPlexProduct.serialize(with: .header(explode: false))),
SerializedParameter(name: "X-Plex-Client-Identifier", serialized: try xPlexClientIdentifier?.serialize(with: .header(explode: false)))
]
}

View File

@@ -0,0 +1,44 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetWatchlistRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetWatchlistRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetWatchlistRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"filter": try filter.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.GetWatchlistRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: xPlexToken, named: "X-Plex-Token", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: includeCollections, named: "includeCollections", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: includeExternalMedia, named: "includeExternalMedia", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: libtype, named: "libtype", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: maxresults, named: "maxresults", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: sort, named: "sort", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: xPlexContainerSize, named: "X-Plex-Container-Size", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: xPlexContainerStart, named: "X-Plex-Container-Start", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.IncludeCollections: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try rawValue.serialize(with: format)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.IncludeExternalMedia: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try rawValue.serialize(with: format)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Libtype: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try rawValue.serialize(with: format)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}