Files
plexswift/Sources/Plexswift/configuration/GlobalServer.swift

52 lines
1.9 KiB
Swift

// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
/// The protocol to use when connecting to your plex server.
public enum ServerProtocol: String, Codable, APIValue {
case http = "http"
case https = "https"
}
/// Describes the available servers that can be used when connecting to the API.
///
/// These can be passed to ``Client/use(server:)`` to configure the server that is connected to when making API requests.
///
/// > Note: Some API operations may support further customization of the server that is connected to when making calls to their respective endpoints. See the corresponding documentation for each API operation method to see if this is the case.
public enum GlobalServers: Servers, ServerConvertible {
/// Supported server value.
///
/// Corresponds to `http://10.10.10.47:32400`
case server1
/// Supported server value with substituted variables
///
/// Corresponds to `{protocol}://{ip}:{port}`
case server2(`protocol`: ServerProtocol = .http, ip: String = "10.10.10.47", port: String = "32400")
/// Defines the raw URL strings for each server option.
///
/// > Note: You do not need to use these values directly.
///
/// The available URL strings are defined as:
/// ```swift
/// public static let urlStrings = [
/// "http://10.10.10.47:32400",
/// "{protocol}://{ip}:{port}"
/// ]
/// ```
public static let urlStrings = [
"http://10.10.10.47:32400",
"{protocol}://{ip}:{port}"
]
func server() throws -> Server {
switch self {
case .server1:
return try type(of: self).server(at: 0, substituting: nil)
case .server2(let `protocol`, let ip, let port):
return try type(of: self).server(at: 1, substituting: ["protocol": `protocol`.rawValue, "ip": ip, "port": port])
}
}
}