mirror of
https://github.com/LukeHagar/plexswift.git
synced 2025-12-06 12:47:44 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.209.2
This commit is contained in:
123
Sources/Plexswift/internal/api/_LogAPI.swift
Normal file
123
Sources/Plexswift/internal/api/_LogAPI.swift
Normal file
@@ -0,0 +1,123 @@
|
||||
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
||||
|
||||
|
||||
import Foundation
|
||||
|
||||
class _LogAPI: LogAPI {
|
||||
private let client: Client
|
||||
|
||||
init(client: Client) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
public func logLine(request: Operations.LogLineRequest) async throws -> Response<Operations.LogLineResponse> {
|
||||
return try await client.makeRequest(
|
||||
configureRequest: { configuration in
|
||||
try configureLogLineRequest(with: configuration, request: request)
|
||||
},
|
||||
handleResponse: handleLogLineResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func logMultiLine(request: String) async throws -> Response<Operations.LogMultiLineResponse> {
|
||||
return try await client.makeRequest(
|
||||
configureRequest: { configuration in
|
||||
try configureLogMultiLineRequest(with: configuration, request: request)
|
||||
},
|
||||
handleResponse: handleLogMultiLineResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func enablePaperTrail() async throws -> Response<Operations.EnablePaperTrailResponse> {
|
||||
return try await client.makeRequest(
|
||||
configureRequest: { configuration in
|
||||
try configureEnablePaperTrailRequest(with: configuration)
|
||||
},
|
||||
handleResponse: handleEnablePaperTrailResponse
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Request Configuration
|
||||
|
||||
private func configureLogLineRequest(with configuration: URLRequestConfiguration, request: Operations.LogLineRequest) throws {
|
||||
configuration.path = "/log"
|
||||
configuration.method = .get
|
||||
configuration.queryParameterSerializable = request
|
||||
configuration.telemetryHeader = .userAgent
|
||||
}
|
||||
|
||||
private func configureLogMultiLineRequest(with configuration: URLRequestConfiguration, request: String) throws {
|
||||
configuration.path = "/log"
|
||||
configuration.method = .post
|
||||
configuration.contentType = "text/plain"
|
||||
configuration.body = request.data(using: .utf8)
|
||||
if configuration.body == nil {
|
||||
throw SerializationError.missingRequiredRequestBody
|
||||
}
|
||||
configuration.telemetryHeader = .userAgent
|
||||
}
|
||||
|
||||
private func configureEnablePaperTrailRequest(with configuration: URLRequestConfiguration) throws {
|
||||
configuration.path = "/log/networked"
|
||||
configuration.method = .get
|
||||
configuration.telemetryHeader = .userAgent
|
||||
}
|
||||
|
||||
// MARK: - Response Handlers
|
||||
|
||||
private func handleLogLineResponse(response: Client.APIResponse) throws -> Operations.LogLineResponse {
|
||||
let httpResponse = response.httpResponse
|
||||
|
||||
if [200, 400].contains(httpResponse.statusCode) {
|
||||
return .empty
|
||||
} else if httpResponse.statusCode == 401 {
|
||||
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
|
||||
do {
|
||||
return .object(try JSONDecoder().decode(Operations.LogLineResponseBody.self, from: data))
|
||||
} catch {
|
||||
throw ResponseHandlerError.failedToDecodeJSON(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return .empty
|
||||
}
|
||||
|
||||
private func handleLogMultiLineResponse(response: Client.APIResponse) throws -> Operations.LogMultiLineResponse {
|
||||
let httpResponse = response.httpResponse
|
||||
|
||||
if [200, 400].contains(httpResponse.statusCode) {
|
||||
return .empty
|
||||
} else if httpResponse.statusCode == 401 {
|
||||
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
|
||||
do {
|
||||
return .object(try JSONDecoder().decode(Operations.LogMultiLineResponseBody.self, from: data))
|
||||
} catch {
|
||||
throw ResponseHandlerError.failedToDecodeJSON(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return .empty
|
||||
}
|
||||
|
||||
private func handleEnablePaperTrailResponse(response: Client.APIResponse) throws -> Operations.EnablePaperTrailResponse {
|
||||
let httpResponse = response.httpResponse
|
||||
|
||||
if [200, 400, 403].contains(httpResponse.statusCode) {
|
||||
return .empty
|
||||
} else if httpResponse.statusCode == 401 {
|
||||
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
|
||||
do {
|
||||
return .object(try JSONDecoder().decode(Operations.EnablePaperTrailResponseBody.self, from: data))
|
||||
} catch {
|
||||
throw ResponseHandlerError.failedToDecodeJSON(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return .empty
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user