diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index c1bd5e9..ed5b9e2 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,22 +1,23 @@ lockVersion: 2.0.0 id: 5d77204e-e413-4fd0-a14a-bad3aee2247a management: - docChecksum: 37654ea0982ab5e87a9a9576014c9d19 + docChecksum: e73920abd3a55e8d249592f2e3090574 docVersion: 0.0.3 - speakeasyVersion: 1.308.1 - generationVersion: 2.342.6 - releaseVersion: 0.4.0 - configChecksum: 13dc4c5ae6371accdb7e2797a7681034 + speakeasyVersion: 1.314.2 + generationVersion: 2.349.6 + releaseVersion: 0.5.0 + configChecksum: 98f5e531db8f621f48c4c6e7ad476aa1 repoURL: https://github.com/LukeHagar/plexswift.git features: swift: - core: 3.2.4 + core: 3.2.5 globalSecurity: 2.81.5 globalServerURLs: 2.82.1 globals: 2.81.3 methodServerURLs: 3.0.1 nameOverrides: 2.81.2 typeOverrides: 2.81.1 + unions: 2.81.5 generatedFiles: - Sources/Plexswift/internal/api/_ServerAPI.swift - Sources/Plexswift/internal/api/_MediaAPI.swift @@ -131,6 +132,15 @@ generatedFiles: - Sources/Plexswift/models/operations/GetAvailableClientsResponse.swift - Sources/Plexswift/models/operations/GetAvailableClientsResponseBody.swift - Sources/Plexswift/models/operations/GetAvailableClientsServerResponseBody.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsAccount.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsDevice.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsErrors.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsMediaContainer.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsRequest.swift + - Sources/Plexswift/internal/models/GetBandwidthStatisticsRequest+Serialization.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsResponse.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsResponseBody.swift + - Sources/Plexswift/models/operations/GetBandwidthStatisticsStatisticsResponseBody.swift - Sources/Plexswift/models/operations/GetButlerTasksButlerResponseBody.swift - Sources/Plexswift/models/operations/GetButlerTasksErrors.swift - Sources/Plexswift/models/operations/GetButlerTasksResponse.swift @@ -291,6 +301,13 @@ generatedFiles: - Sources/Plexswift/internal/models/GetResizedPhotoRequest+Serialization.swift - Sources/Plexswift/models/operations/GetResizedPhotoResponse.swift - Sources/Plexswift/models/operations/GetResizedPhotoResponseBody.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsErrors.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsMediaContainer.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsRequest.swift + - Sources/Plexswift/internal/models/GetResourcesStatisticsRequest+Serialization.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsResponse.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsResponseBody.swift + - Sources/Plexswift/models/operations/GetResourcesStatisticsStatisticsResponseBody.swift - Sources/Plexswift/models/operations/GetSearchResultsCountry.swift - Sources/Plexswift/models/operations/GetSearchResultsDirector.swift - Sources/Plexswift/models/operations/GetSearchResultsErrors.swift @@ -333,6 +350,8 @@ generatedFiles: - Sources/Plexswift/models/operations/GetSessionHistoryErrors.swift - Sources/Plexswift/models/operations/GetSessionHistoryMediaContainer.swift - Sources/Plexswift/models/operations/GetSessionHistoryMetadata.swift + - Sources/Plexswift/models/operations/GetSessionHistoryRequest.swift + - Sources/Plexswift/internal/models/GetSessionHistoryRequest+Serialization.swift - Sources/Plexswift/models/operations/GetSessionHistoryResponse.swift - Sources/Plexswift/models/operations/GetSessionHistoryResponseBody.swift - Sources/Plexswift/models/operations/GetSessionHistorySessionsResponseBody.swift @@ -345,6 +364,7 @@ generatedFiles: - Sources/Plexswift/models/operations/GetSessionsResponseBody.swift - Sources/Plexswift/models/operations/GetSessionsSessionsResponseBody.swift - Sources/Plexswift/models/operations/GetSessionsStream.swift + - Sources/Plexswift/models/operations/GetSessionsUser.swift - Sources/Plexswift/models/operations/GetSourceConnectionInformationErrors.swift - Sources/Plexswift/models/operations/GetSourceConnectionInformationRequest.swift - Sources/Plexswift/internal/models/GetSourceConnectionInformationRequest+Serialization.swift @@ -370,6 +390,16 @@ generatedFiles: - Sources/Plexswift/internal/models/GetTokenRequest+Serialization.swift - Sources/Plexswift/models/operations/GetTokenResponse.swift - Sources/Plexswift/models/operations/GetTokenResponseBody.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentCountry.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentGenre.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentGuids.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentMediaContainer.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentMetadata.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentRequest.swift + - Sources/Plexswift/internal/models/GetTopWatchedContentRequest+Serialization.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentResponse.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentResponseBody.swift + - Sources/Plexswift/models/operations/GetTopWatchedContentRole.swift - Sources/Plexswift/models/operations/GetTranscodeSessionsErrors.swift - Sources/Plexswift/models/operations/GetTranscodeSessionsMediaContainer.swift - Sources/Plexswift/models/operations/GetTranscodeSessionsResponse.swift @@ -404,6 +434,8 @@ generatedFiles: - Sources/Plexswift/internal/models/IncludeExternalMedia+Serialization.swift - Sources/Plexswift/models/operations/Level.swift - Sources/Plexswift/internal/models/Level+Serialization.swift + - Sources/Plexswift/models/operations/LibrarySectionID.swift + - Sources/Plexswift/internal/models/LibrarySectionID+Serialization.swift - Sources/Plexswift/models/operations/Libtype.swift - Sources/Plexswift/internal/models/Libtype+Serialization.swift - Sources/Plexswift/models/operations/Location.swift @@ -435,6 +467,8 @@ generatedFiles: - Sources/Plexswift/internal/models/OnlyTransient+Serialization.swift - Sources/Plexswift/models/operations/Operator.swift - Sources/Plexswift/models/operations/Part.swift + - Sources/Plexswift/models/operations/PathParamFilter.swift + - Sources/Plexswift/internal/models/PathParamFilter+Serialization.swift - Sources/Plexswift/models/operations/PathParamTaskName.swift - Sources/Plexswift/internal/models/PathParamTaskName+Serialization.swift - Sources/Plexswift/models/operations/PerformSearchErrors.swift @@ -499,7 +533,9 @@ generatedFiles: - Sources/Plexswift/models/operations/StartUniversalTranscodeResponseBody.swift - Sources/Plexswift/models/operations/State.swift - Sources/Plexswift/internal/models/State+Serialization.swift + - Sources/Plexswift/models/operations/StatisticsBandwidth.swift - Sources/Plexswift/models/operations/StatisticsMedia.swift + - Sources/Plexswift/models/operations/StatisticsResources.swift - Sources/Plexswift/models/operations/StopAllTasksErrors.swift - Sources/Plexswift/models/operations/StopAllTasksResponse.swift - Sources/Plexswift/models/operations/StopAllTasksResponseBody.swift diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index fde90a4..7c90dd0 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true swift: - version: 0.4.0 + version: 0.5.0 author: LukeHagar description: Swift Client SDK Generated by Speakeasy imports: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 846dfb8..c59c779 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.308.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:5624db047dbcbdea446c5bfd39647c4eeff845353f814d00a01f5591a4667a38 - sourceBlobDigest: sha256:853e4c9838e000baff90393829ccf8e6bafd9a6e6017368e04fa33f174ba0904 + sourceRevisionDigest: sha256:8a15726911f1bd51a3bb7fa71c0b97ef1ab7713e46e7e4520f7a6d0b69f0359d + sourceBlobDigest: sha256:5abcd27b0ae2eadfcc678713caeb400262c27eafaf78e30df9a05894214d8df9 tags: - latest - main @@ -11,8 +11,8 @@ targets: plexswift: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:5624db047dbcbdea446c5bfd39647c4eeff845353f814d00a01f5591a4667a38 - sourceBlobDigest: sha256:853e4c9838e000baff90393829ccf8e6bafd9a6e6017368e04fa33f174ba0904 + sourceRevisionDigest: sha256:8a15726911f1bd51a3bb7fa71c0b97ef1ab7713e46e7e4520f7a6d0b69f0359d + sourceBlobDigest: sha256:5abcd27b0ae2eadfcc678713caeb400262c27eafaf78e30df9a05894214d8df9 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index f4aa817..c492400 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ You can add `plexswift` to your project directly in Xcode `(File > Add Packages. ```bash dependencies: [ - .package(url: "https://github.com/LukeHagar/plexswift.git", .upToNextMajor(from: "0.4.0")) + .package(url: "https://github.com/LukeHagar/plexswift.git", .upToNextMajor(from: "0.5.0")) ] ``` @@ -100,18 +100,18 @@ case .empty: ## Global Parameters -A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed. +A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed. For example, you can set `X-Plex-Client-Identifier` to `"Postman"` at SDK initialization and then you do not have to pass the same value on calls to operations like `getPin`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration. ### Available Globals -The following global parameter is available. The required parameter must be set when you initialize the SDK client. +The following global parameter is available. | Name | Type | Required | Description | | ---- | ---- |:--------:| ----------- | -| xPlexClientIdentifier | String | ✔️ | The unique identifier for the client application +| xPlexClientIdentifier | String | | The unique identifier for the client application This is used to track the client application and its usage (UUID, serial number, or other number unique per device) | diff --git a/RELEASES.md b/RELEASES.md index e7d5265..14ba2c0 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -472,4 +472,14 @@ Based on: ### Generated - [swift v0.4.0] . ### Releases -- [Swift Package Manager v0.4.0] https://github.com/LukeHagar/plexswift/releases/tag/v0.4.0 - . \ No newline at end of file +- [Swift Package Manager v0.4.0] https://github.com/LukeHagar/plexswift/releases/tag/v0.4.0 - . + +## 2024-06-22 00:13:29 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.314.2 (2.349.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [swift v0.5.0] . +### Releases +- [Swift Package Manager v0.5.0] https://github.com/LukeHagar/plexswift/releases/tag/v0.5.0 - . \ No newline at end of file diff --git a/Sources/Plexswift/Plexswift.docc/Plexswift.md b/Sources/Plexswift/Plexswift.docc/Plexswift.md index 08dc55f..9180d73 100644 --- a/Sources/Plexswift/Plexswift.docc/Plexswift.md +++ b/Sources/Plexswift/Plexswift.docc/Plexswift.md @@ -88,6 +88,7 @@ case .empty: - ``Operations/DeletePlaylistResponse`` - ``Operations/EnablePaperTrailResponse`` - ``Operations/GetAvailableClientsResponse`` +- ``Operations/GetBandwidthStatisticsResponse`` - ``Operations/GetButlerTasksResponse`` - ``Operations/GetDevicesResponse`` - ``Operations/GetFileHashResponse`` @@ -107,6 +108,7 @@ case .empty: - ``Operations/GetPlaylistsResponse`` - ``Operations/GetRecentlyAddedResponse`` - ``Operations/GetResizedPhotoResponse`` +- ``Operations/GetResourcesStatisticsResponse`` - ``Operations/GetSearchResultsResponse`` - ``Operations/GetServerActivitiesResponse`` - ``Operations/GetServerCapabilitiesResponse`` @@ -119,6 +121,7 @@ case .empty: - ``Operations/GetStatisticsResponse`` - ``Operations/GetTimelineResponse`` - ``Operations/GetTokenResponse`` +- ``Operations/GetTopWatchedContentResponse`` - ``Operations/GetTranscodeSessionsResponse`` - ``Operations/GetTransientTokenResponse`` - ``Operations/GetUpdateStatusResponse`` @@ -194,6 +197,13 @@ case .empty: - ``Operations/GetAvailableClientsMediaContainer`` - ``Operations/GetAvailableClientsResponseBody`` - ``Operations/GetAvailableClientsServerResponseBody`` +- ``Operations/GetBandwidthStatisticsAccount`` +- ``Operations/GetBandwidthStatisticsDevice`` +- ``Operations/GetBandwidthStatisticsErrors`` +- ``Operations/GetBandwidthStatisticsMediaContainer`` +- ``Operations/GetBandwidthStatisticsRequest`` +- ``Operations/GetBandwidthStatisticsResponseBody`` +- ``Operations/GetBandwidthStatisticsStatisticsResponseBody`` - ``Operations/GetButlerTasksButlerResponseBody`` - ``Operations/GetButlerTasksErrors`` - ``Operations/GetButlerTasksResponseBody`` @@ -323,6 +333,11 @@ case .empty: - ``Operations/GetResizedPhotoErrors`` - ``Operations/GetResizedPhotoRequest`` - ``Operations/GetResizedPhotoResponseBody`` +- ``Operations/GetResourcesStatisticsErrors`` +- ``Operations/GetResourcesStatisticsMediaContainer`` +- ``Operations/GetResourcesStatisticsRequest`` +- ``Operations/GetResourcesStatisticsResponseBody`` +- ``Operations/GetResourcesStatisticsStatisticsResponseBody`` - ``Operations/GetSearchResultsCountry`` - ``Operations/GetSearchResultsDirector`` - ``Operations/GetSearchResultsErrors`` @@ -358,6 +373,7 @@ case .empty: - ``Operations/GetSessionHistoryErrors`` - ``Operations/GetSessionHistoryMediaContainer`` - ``Operations/GetSessionHistoryMetadata`` +- ``Operations/GetSessionHistoryRequest`` - ``Operations/GetSessionHistoryResponseBody`` - ``Operations/GetSessionHistorySessionsResponseBody`` - ``Operations/GetSessionsErrors`` @@ -368,6 +384,7 @@ case .empty: - ``Operations/GetSessionsResponseBody`` - ``Operations/GetSessionsSessionsResponseBody`` - ``Operations/GetSessionsStream`` +- ``Operations/GetSessionsUser`` - ``Operations/GetSourceConnectionInformationErrors`` - ``Operations/GetSourceConnectionInformationRequest`` - ``Operations/GetSourceConnectionInformationResponseBody`` @@ -385,6 +402,14 @@ case .empty: - ``Operations/GetTokenPlexResponseBody`` - ``Operations/GetTokenRequest`` - ``Operations/GetTokenResponseBody`` +- ``Operations/GetTopWatchedContentCountry`` +- ``Operations/GetTopWatchedContentGenre`` +- ``Operations/GetTopWatchedContentGuids`` +- ``Operations/GetTopWatchedContentMediaContainer`` +- ``Operations/GetTopWatchedContentMetadata`` +- ``Operations/GetTopWatchedContentRequest`` +- ``Operations/GetTopWatchedContentResponseBody`` +- ``Operations/GetTopWatchedContentRole`` - ``Operations/GetTranscodeSessionsErrors`` - ``Operations/GetTranscodeSessionsMediaContainer`` - ``Operations/GetTranscodeSessionsResponseBody`` @@ -408,6 +433,7 @@ case .empty: - ``Operations/IncludeDetails`` - ``Operations/IncludeExternalMedia`` - ``Operations/Level`` +- ``Operations/LibrarySectionID`` - ``Operations/Libtype`` - ``Operations/Location`` - ``Operations/LogLineErrors`` @@ -429,6 +455,7 @@ case .empty: - ``Operations/OnlyTransient`` - ``Operations/Operator`` - ``Operations/Part`` +- ``Operations/PathParamFilter`` - ``Operations/PathParamTaskName`` - ``Operations/PerformSearchErrors`` - ``Operations/PerformSearchRequest`` @@ -471,7 +498,9 @@ case .empty: - ``Operations/StartUniversalTranscodeRequest`` - ``Operations/StartUniversalTranscodeResponseBody`` - ``Operations/State`` +- ``Operations/StatisticsBandwidth`` - ``Operations/StatisticsMedia`` +- ``Operations/StatisticsResources`` - ``Operations/StopAllTasksErrors`` - ``Operations/StopAllTasksResponseBody`` - ``Operations/StopTaskErrors`` diff --git a/Sources/Plexswift/configuration/GlobalServer.swift b/Sources/Plexswift/configuration/GlobalServer.swift index e132457..16fd835 100644 --- a/Sources/Plexswift/configuration/GlobalServer.swift +++ b/Sources/Plexswift/configuration/GlobalServer.swift @@ -3,7 +3,6 @@ import Foundation -/// The protocol to use when connecting to your plex server. public enum ServerProtocol: String, Codable, APIValue { case http = "http" case https = "https" diff --git a/Sources/Plexswift/internal/api/_LibraryAPI.swift b/Sources/Plexswift/internal/api/_LibraryAPI.swift index 44ad600..9cf1edc 100644 --- a/Sources/Plexswift/internal/api/_LibraryAPI.swift +++ b/Sources/Plexswift/internal/api/_LibraryAPI.swift @@ -100,6 +100,15 @@ class _LibraryAPI: LibraryAPI { ) } + public func getTopWatchedContent(request: Operations.GetTopWatchedContentRequest) async throws -> Response { + return try await client.makeRequest( + configureRequest: { configuration in + try configureGetTopWatchedContentRequest(with: configuration, request: request) + }, + handleResponse: handleGetTopWatchedContentResponse + ) + } + public func getOnDeck() async throws -> Response { return try await client.makeRequest( configureRequest: { configuration in @@ -151,6 +160,7 @@ private func configureGetLibraryItemsRequest(with configuration: URLRequestConfi configuration.path = "/library/sections/{sectionId}/{tag}" configuration.method = .get configuration.pathParameterSerializable = request + configuration.queryParameterSerializable = request configuration.telemetryHeader = .userAgent } @@ -180,6 +190,14 @@ private func configureGetMetadataChildrenRequest(with configuration: URLRequestC configuration.path = "/library/metadata/{ratingKey}/children" configuration.method = .get configuration.pathParameterSerializable = request + configuration.queryParameterSerializable = request + configuration.telemetryHeader = .userAgent +} + +private func configureGetTopWatchedContentRequest(with configuration: URLRequestConfiguration, request: Operations.GetTopWatchedContentRequest) throws { + configuration.path = "/library/all/top" + configuration.method = .get + configuration.queryParameterSerializable = request configuration.telemetryHeader = .userAgent } @@ -427,6 +445,22 @@ private func handleGetMetadataChildrenResponse(response: Client.APIResponse) thr return .empty } +private func handleGetTopWatchedContentResponse(response: Client.APIResponse) throws -> Operations.GetTopWatchedContentResponse { + let httpResponse = response.httpResponse + + if httpResponse.statusCode == 200 { + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .object(try JSONDecoder().decode(Operations.GetTopWatchedContentResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } + + return .empty +} + private func handleGetOnDeckResponse(response: Client.APIResponse) throws -> Operations.GetOnDeckResponse { let httpResponse = response.httpResponse diff --git a/Sources/Plexswift/internal/api/_PlaylistsAPI.swift b/Sources/Plexswift/internal/api/_PlaylistsAPI.swift index 55ac345..50d0cfe 100644 --- a/Sources/Plexswift/internal/api/_PlaylistsAPI.swift +++ b/Sources/Plexswift/internal/api/_PlaylistsAPI.swift @@ -244,7 +244,7 @@ private func handleGetPlaylistResponse(response: Client.APIResponse) throws -> O private func handleDeletePlaylistResponse(response: Client.APIResponse) throws -> Operations.DeletePlaylistResponse { let httpResponse = response.httpResponse - if [200, 400].contains(httpResponse.statusCode) { + if [204, 400].contains(httpResponse.statusCode) { return .empty } else if httpResponse.statusCode == 401 { if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { diff --git a/Sources/Plexswift/internal/api/_SessionsAPI.swift b/Sources/Plexswift/internal/api/_SessionsAPI.swift index be02cdd..48c89d2 100644 --- a/Sources/Plexswift/internal/api/_SessionsAPI.swift +++ b/Sources/Plexswift/internal/api/_SessionsAPI.swift @@ -19,10 +19,10 @@ class _SessionsAPI: SessionsAPI { ) } - public func getSessionHistory() async throws -> Response { + public func getSessionHistory(request: Operations.GetSessionHistoryRequest) async throws -> Response { return try await client.makeRequest( configureRequest: { configuration in - try configureGetSessionHistoryRequest(with: configuration) + try configureGetSessionHistoryRequest(with: configuration, request: request) }, handleResponse: handleGetSessionHistoryResponse ) @@ -56,9 +56,10 @@ private func configureGetSessionsRequest(with configuration: URLRequestConfigura configuration.telemetryHeader = .userAgent } -private func configureGetSessionHistoryRequest(with configuration: URLRequestConfiguration) throws { +private func configureGetSessionHistoryRequest(with configuration: URLRequestConfiguration, request: Operations.GetSessionHistoryRequest) throws { configuration.path = "/status/sessions/history/all" configuration.method = .get + configuration.queryParameterSerializable = request configuration.telemetryHeader = .userAgent } diff --git a/Sources/Plexswift/internal/api/_StatisticsAPI.swift b/Sources/Plexswift/internal/api/_StatisticsAPI.swift index d3280bb..b624c22 100644 --- a/Sources/Plexswift/internal/api/_StatisticsAPI.swift +++ b/Sources/Plexswift/internal/api/_StatisticsAPI.swift @@ -18,6 +18,24 @@ class _StatisticsAPI: StatisticsAPI { handleResponse: handleGetStatisticsResponse ) } + + public func getResourcesStatistics(request: Operations.GetResourcesStatisticsRequest) async throws -> Response { + return try await client.makeRequest( + configureRequest: { configuration in + try configureGetResourcesStatisticsRequest(with: configuration, request: request) + }, + handleResponse: handleGetResourcesStatisticsResponse + ) + } + + public func getBandwidthStatistics(request: Operations.GetBandwidthStatisticsRequest) async throws -> Response { + return try await client.makeRequest( + configureRequest: { configuration in + try configureGetBandwidthStatisticsRequest(with: configuration, request: request) + }, + handleResponse: handleGetBandwidthStatisticsResponse + ) + } } @@ -30,6 +48,20 @@ private func configureGetStatisticsRequest(with configuration: URLRequestConfigu configuration.telemetryHeader = .userAgent } +private func configureGetResourcesStatisticsRequest(with configuration: URLRequestConfiguration, request: Operations.GetResourcesStatisticsRequest) throws { + configuration.path = "/statistics/resources" + configuration.method = .get + configuration.queryParameterSerializable = request + configuration.telemetryHeader = .userAgent +} + +private func configureGetBandwidthStatisticsRequest(with configuration: URLRequestConfiguration, request: Operations.GetBandwidthStatisticsRequest) throws { + configuration.path = "/statistics/bandwidth" + configuration.method = .get + configuration.queryParameterSerializable = request + configuration.telemetryHeader = .userAgent +} + // MARK: - Response Handlers private func handleGetStatisticsResponse(response: Client.APIResponse) throws -> Operations.GetStatisticsResponse { @@ -58,3 +90,55 @@ private func handleGetStatisticsResponse(response: Client.APIResponse) throws -> return .empty } +private func handleGetResourcesStatisticsResponse(response: Client.APIResponse) throws -> Operations.GetResourcesStatisticsResponse { + 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.GetResourcesStatisticsResponseBody.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.GetResourcesStatisticsStatisticsResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } + + return .empty +} + +private func handleGetBandwidthStatisticsResponse(response: Client.APIResponse) throws -> Operations.GetBandwidthStatisticsResponse { + 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.GetBandwidthStatisticsResponseBody.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.GetBandwidthStatisticsStatisticsResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } + + return .empty +} + diff --git a/Sources/Plexswift/internal/models/Filter+Serialization.swift b/Sources/Plexswift/internal/models/Filter+Serialization.swift index 1cbaa9c..99ae6e8 100644 --- a/Sources/Plexswift/internal/models/Filter+Serialization.swift +++ b/Sources/Plexswift/internal/models/Filter+Serialization.swift @@ -5,10 +5,6 @@ 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))] + return "" } } diff --git a/Sources/Plexswift/internal/models/GetBandwidthStatisticsRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetBandwidthStatisticsRequest+Serialization.swift new file mode 100644 index 0000000..7748c69 --- /dev/null +++ b/Sources/Plexswift/internal/models/GetBandwidthStatisticsRequest+Serialization.swift @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.GetBandwidthStatisticsRequest: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + switch format { + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .path, .header, .multipart, .form: + throw SerializationError.invalidSerializationParameter(type: "Operations.GetBandwidthStatisticsRequest", format: format.formatDescription) + } + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } +} + +extension Operations.GetBandwidthStatisticsRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: timespan, named: "Timespan", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/GetLibraryItemsRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetLibraryItemsRequest+Serialization.swift index e4f8837..b64e50c 100644 --- a/Sources/Plexswift/internal/models/GetLibraryItemsRequest+Serialization.swift +++ b/Sources/Plexswift/internal/models/GetLibraryItemsRequest+Serialization.swift @@ -8,10 +8,16 @@ extension Operations.GetLibraryItemsRequest: Serializable { switch format { case .path: return try serializePathParameterSerializable(self, with: format) - case .query, .header, .multipart, .form: + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .header, .multipart, .form: throw SerializationError.invalidSerializationParameter(type: "Operations.GetLibraryItemsRequest", format: format.formatDescription) } } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } } extension Operations.GetLibraryItemsRequest: PathParameterSerializable { @@ -22,3 +28,11 @@ extension Operations.GetLibraryItemsRequest: PathParameterSerializable { ].compactMapValues { $0 } } } + +extension Operations.GetLibraryItemsRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: includeGuids, named: "includeGuids", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/GetMetadataChildrenRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetMetadataChildrenRequest+Serialization.swift index d0d8004..3e4359f 100644 --- a/Sources/Plexswift/internal/models/GetMetadataChildrenRequest+Serialization.swift +++ b/Sources/Plexswift/internal/models/GetMetadataChildrenRequest+Serialization.swift @@ -8,10 +8,16 @@ extension Operations.GetMetadataChildrenRequest: Serializable { switch format { case .path: return try serializePathParameterSerializable(self, with: format) - case .query, .header, .multipart, .form: + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .header, .multipart, .form: throw SerializationError.invalidSerializationParameter(type: "Operations.GetMetadataChildrenRequest", format: format.formatDescription) } } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } } extension Operations.GetMetadataChildrenRequest: PathParameterSerializable { @@ -21,3 +27,11 @@ extension Operations.GetMetadataChildrenRequest: PathParameterSerializable { ].compactMapValues { $0 } } } + +extension Operations.GetMetadataChildrenRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: includeElements, named: "includeElements", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/GetResourcesStatisticsRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetResourcesStatisticsRequest+Serialization.swift new file mode 100644 index 0000000..fd5dee8 --- /dev/null +++ b/Sources/Plexswift/internal/models/GetResourcesStatisticsRequest+Serialization.swift @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.GetResourcesStatisticsRequest: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + switch format { + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .path, .header, .multipart, .form: + throw SerializationError.invalidSerializationParameter(type: "Operations.GetResourcesStatisticsRequest", format: format.formatDescription) + } + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } +} + +extension Operations.GetResourcesStatisticsRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: timespan, named: "Timespan", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/GetSessionHistoryRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetSessionHistoryRequest+Serialization.swift new file mode 100644 index 0000000..61a3688 --- /dev/null +++ b/Sources/Plexswift/internal/models/GetSessionHistoryRequest+Serialization.swift @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.GetSessionHistoryRequest: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + switch format { + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .path, .header, .multipart, .form: + throw SerializationError.invalidSerializationParameter(type: "Operations.GetSessionHistoryRequest", format: format.formatDescription) + } + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } +} + +extension Operations.GetSessionHistoryRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: accountId, named: "accountId", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: filter, named: "filter", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: librarySectionID, named: "librarySectionID", 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) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/GetTopWatchedContentRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetTopWatchedContentRequest+Serialization.swift new file mode 100644 index 0000000..69d27cc --- /dev/null +++ b/Sources/Plexswift/internal/models/GetTopWatchedContentRequest+Serialization.swift @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.GetTopWatchedContentRequest: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + switch format { + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .path, .header, .multipart, .form: + throw SerializationError.invalidSerializationParameter(type: "Operations.GetTopWatchedContentRequest", format: format.formatDescription) + } + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } +} + +extension Operations.GetTopWatchedContentRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: type, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: includeGuids, named: "includeGuids", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/LibrarySectionID+Serialization.swift b/Sources/Plexswift/internal/models/LibrarySectionID+Serialization.swift new file mode 100644 index 0000000..4b6ba60 --- /dev/null +++ b/Sources/Plexswift/internal/models/LibrarySectionID+Serialization.swift @@ -0,0 +1,10 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.LibrarySectionID: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + return "" + } +} diff --git a/Sources/Plexswift/internal/models/PathParamFilter+Serialization.swift b/Sources/Plexswift/internal/models/PathParamFilter+Serialization.swift new file mode 100644 index 0000000..58699ae --- /dev/null +++ b/Sources/Plexswift/internal/models/PathParamFilter+Serialization.swift @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.PathParamFilter: 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))] + } +} diff --git a/Sources/Plexswift/models/operations/Filter.swift b/Sources/Plexswift/models/operations/Filter.swift index 19e9f0c..14a6965 100644 --- a/Sources/Plexswift/models/operations/Filter.swift +++ b/Sources/Plexswift/models/operations/Filter.swift @@ -3,10 +3,19 @@ import Foundation extension Operations { - /// Filter - public enum Filter: String, Codable, APIValue { - case all = "all" - case available = "available" - case released = "released" + /// Filters content by field and direction/equality + /// (Unknown if viewedAt is the only supported column) + /// + public struct Filter { + + /// Creates an object + /// + /// + public init() { + } } } + +extension Operations.Filter: Codable { +} + diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsAccount.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsAccount.swift new file mode 100644 index 0000000..3719aaa --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsAccount.swift @@ -0,0 +1,45 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetBandwidthStatisticsAccount { + public let autoSelectAudio: Bool? + public let defaultAudioLanguage: String? + public let defaultSubtitleLanguage: String? + public let id: Int? + public let key: String? + public let name: String? + public let subtitleMode: Int? + public let thumb: String? + + /// Creates an object with the specified parameters + /// + /// + public init(autoSelectAudio: Bool? = nil, defaultAudioLanguage: String? = nil, defaultSubtitleLanguage: String? = nil, id: Int? = nil, key: String? = nil, name: String? = nil, subtitleMode: Int? = nil, thumb: String? = nil) { + self.autoSelectAudio = autoSelectAudio + self.defaultAudioLanguage = defaultAudioLanguage + self.defaultSubtitleLanguage = defaultSubtitleLanguage + self.id = id + self.key = key + self.name = name + self.subtitleMode = subtitleMode + self.thumb = thumb + } + } +} + +extension Operations.GetBandwidthStatisticsAccount: Codable { + enum CodingKeys: String, CodingKey { + case autoSelectAudio + case defaultAudioLanguage + case defaultSubtitleLanguage + case id + case key + case name + case subtitleMode + case thumb + } +} + diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsDevice.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsDevice.swift new file mode 100644 index 0000000..b4bee38 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsDevice.swift @@ -0,0 +1,36 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetBandwidthStatisticsDevice { + public let clientIdentifier: String? + public let createdAt: Int? + public let id: Int? + public let name: String? + public let platform: String? + + /// Creates an object with the specified parameters + /// + /// + public init(clientIdentifier: String? = nil, createdAt: Int? = nil, id: Int? = nil, name: String? = nil, platform: String? = nil) { + self.clientIdentifier = clientIdentifier + self.createdAt = createdAt + self.id = id + self.name = name + self.platform = platform + } + } +} + +extension Operations.GetBandwidthStatisticsDevice: Codable { + enum CodingKeys: String, CodingKey { + case clientIdentifier + case createdAt + case id + case name + case platform + } +} + diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsErrors.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsErrors.swift new file mode 100644 index 0000000..35836e7 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsErrors.swift @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetBandwidthStatisticsErrors { + @DecimalSerialized + public private(set) var code: Double? + public let message: String? + @DecimalSerialized + public private(set) var status: Double? + + /// Creates an object with the specified parameters + /// + /// + public init(code: Double? = nil, message: String? = nil, status: Double? = nil) { + self._code = DecimalSerialized(wrappedValue: code) + self.message = message + self._status = DecimalSerialized(wrappedValue: status) + } + } +} + +extension Operations.GetBandwidthStatisticsErrors: Codable { + enum CodingKeys: String, CodingKey { + case code + case message + case status + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self._code = try container.decodeIfPresent(DecimalSerialized.self, forKey: .code) ?? DecimalSerialized(wrappedValue: nil) + self.message = try container.decodeIfPresent(String.self, forKey: .message) + self._status = try container.decodeIfPresent(DecimalSerialized.self, forKey: .status) ?? DecimalSerialized(wrappedValue: nil) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + if self.code != nil { + try container.encode(self._code, forKey: .code) + } + try container.encodeIfPresent(self.message, forKey: .message) + if self.status != nil { + try container.encode(self._status, forKey: .status) + } + } +} + +extension Operations.GetBandwidthStatisticsErrors { + var codeWrapper: DecimalSerialized { + return _code + } + var statusWrapper: DecimalSerialized { + return _status + } +} diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsMediaContainer.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsMediaContainer.swift new file mode 100644 index 0000000..e0662dd --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsMediaContainer.swift @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetBandwidthStatisticsMediaContainer { + public let account: [Operations.GetBandwidthStatisticsAccount]? + public let device: [Operations.GetBandwidthStatisticsDevice]? + public let size: Int? + public let statisticsBandwidth: [Operations.StatisticsBandwidth]? + + /// Creates an object with the specified parameters + /// + /// + public init(account: [Operations.GetBandwidthStatisticsAccount]? = nil, device: [Operations.GetBandwidthStatisticsDevice]? = nil, size: Int? = nil, statisticsBandwidth: [Operations.StatisticsBandwidth]? = nil) { + self.account = account + self.device = device + self.size = size + self.statisticsBandwidth = statisticsBandwidth + } + } +} + +extension Operations.GetBandwidthStatisticsMediaContainer: Codable { + enum CodingKeys: String, CodingKey { + case account = "Account" + case device = "Device" + case size + case statisticsBandwidth = "StatisticsBandwidth" + } +} + diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsRequest.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsRequest.swift new file mode 100644 index 0000000..18a084f --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsRequest.swift @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetBandwidthStatisticsRequest: APIValue { + /// The timespan to retrieve statistics for + /// the exact meaning of this parameter is not known + /// + public let timespan: Int? + + /// Creates an object with the specified parameters + /// + /// - Parameter timespan: The timespan to retrieve statistics for + /// the exact meaning of this parameter is not known + /// + /// + public init(timespan: Int? = nil) { + self.timespan = timespan + } + } +} diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponse.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponse.swift new file mode 100644 index 0000000..8bb4bba --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponse.swift @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A response model + public enum GetBandwidthStatisticsResponse { + case empty + case twoHundredApplicationJsonObject(Operations.GetBandwidthStatisticsResponseBody) + case fourHundredAndOneApplicationJsonObject(Operations.GetBandwidthStatisticsStatisticsResponseBody) + + var isEmpty: Bool { + if case .empty = self { + return true + } else { + return false + } + } + + public func twoHundredApplicationJsonObject() throws -> Operations.GetBandwidthStatisticsResponseBody { + guard case .twoHundredApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + + public func fourHundredAndOneApplicationJsonObject() throws -> Operations.GetBandwidthStatisticsStatisticsResponseBody { + guard case .fourHundredAndOneApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + } +} diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponseBody.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponseBody.swift new file mode 100644 index 0000000..41259f5 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Bandwidth Statistics + public struct GetBandwidthStatisticsResponseBody { + public let mediaContainer: Operations.GetBandwidthStatisticsMediaContainer? + + /// Creates an object with the specified parameters + /// + /// + public init(mediaContainer: Operations.GetBandwidthStatisticsMediaContainer? = nil) { + self.mediaContainer = mediaContainer + } + } +} + +extension Operations.GetBandwidthStatisticsResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case mediaContainer = "MediaContainer" + } +} + diff --git a/Sources/Plexswift/models/operations/GetBandwidthStatisticsStatisticsResponseBody.swift b/Sources/Plexswift/models/operations/GetBandwidthStatisticsStatisticsResponseBody.swift new file mode 100644 index 0000000..5f9bbf7 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetBandwidthStatisticsStatisticsResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + public struct GetBandwidthStatisticsStatisticsResponseBody { + public let errors: [Operations.GetBandwidthStatisticsErrors]? + + /// Creates an object with the specified parameters + /// + /// + public init(errors: [Operations.GetBandwidthStatisticsErrors]? = nil) { + self.errors = errors + } + } +} + +extension Operations.GetBandwidthStatisticsStatisticsResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case errors + } +} + diff --git a/Sources/Plexswift/models/operations/GetLibraryItemsMediaContainer.swift b/Sources/Plexswift/models/operations/GetLibraryItemsMediaContainer.swift index 02eaa64..f1c6e5f 100644 --- a/Sources/Plexswift/models/operations/GetLibraryItemsMediaContainer.swift +++ b/Sources/Plexswift/models/operations/GetLibraryItemsMediaContainer.swift @@ -8,7 +8,7 @@ extension Operations { public let allowSync: Bool? public let art: String? public let identifier: String? - public let librarySectionID: Int? + public let librarySectionID: Operations.LibrarySectionID? public let librarySectionTitle: String? public let librarySectionUUID: String? public let mediaTagPrefix: String? @@ -25,7 +25,7 @@ extension Operations { /// Creates an object with the specified parameters /// /// - public init(allowSync: Bool? = nil, art: String? = nil, identifier: String? = nil, librarySectionID: Int? = nil, librarySectionTitle: String? = nil, librarySectionUUID: String? = nil, mediaTagPrefix: String? = nil, mediaTagVersion: Int? = nil, metadata: [Operations.GetLibraryItemsMetadata]? = nil, mixedParents: Bool? = nil, size: Int? = nil, thumb: String? = nil, title1: String? = nil, title2: String? = nil, viewGroup: String? = nil, viewMode: Int? = nil) { + public init(allowSync: Bool? = nil, art: String? = nil, identifier: String? = nil, librarySectionID: Operations.LibrarySectionID? = nil, librarySectionTitle: String? = nil, librarySectionUUID: String? = nil, mediaTagPrefix: String? = nil, mediaTagVersion: Int? = nil, metadata: [Operations.GetLibraryItemsMetadata]? = nil, mixedParents: Bool? = nil, size: Int? = nil, thumb: String? = nil, title1: String? = nil, title2: String? = nil, viewGroup: String? = nil, viewMode: Int? = nil) { self.allowSync = allowSync self.art = art self.identifier = identifier diff --git a/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift b/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift index 18783ca..c7b59e9 100644 --- a/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift +++ b/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift @@ -9,15 +9,21 @@ extension Operations { public let sectionId: AnyValue /// A key representing a specific tag within the section. public let tag: Operations.Tag + /// Adds the Guids object to the response + /// + public let includeGuids: Int? /// Creates an object with the specified parameters /// /// - Parameter sectionId: the Id of the library to query /// - Parameter tag: A key representing a specific tag within the section. + /// - Parameter includeGuids: Adds the Guids object to the response + /// /// - public init(sectionId: AnyValue, tag: Operations.Tag) { + public init(sectionId: AnyValue, tag: Operations.Tag, includeGuids: Int? = nil) { self.sectionId = sectionId self.tag = tag + self.includeGuids = includeGuids } } } diff --git a/Sources/Plexswift/models/operations/GetMetadataChildrenRequest.swift b/Sources/Plexswift/models/operations/GetMetadataChildrenRequest.swift index f13a3a1..7450f1c 100644 --- a/Sources/Plexswift/models/operations/GetMetadataChildrenRequest.swift +++ b/Sources/Plexswift/models/operations/GetMetadataChildrenRequest.swift @@ -8,13 +8,19 @@ extension Operations { /// the id of the library item to return the children of. @DecimalSerialized public private(set) var ratingKey: Double + /// Adds additional elements to the response. Supported types are (Stream) + /// + public let includeElements: String? /// Creates an object with the specified parameters /// /// - Parameter ratingKey: the id of the library item to return the children of. + /// - Parameter includeElements: Adds additional elements to the response. Supported types are (Stream) + /// /// - public init(ratingKey: Double) { + public init(ratingKey: Double, includeElements: String? = nil) { self._ratingKey = DecimalSerialized(wrappedValue: ratingKey) + self.includeElements = includeElements } } } diff --git a/Sources/Plexswift/models/operations/GetPinResponseBody.swift b/Sources/Plexswift/models/operations/GetPinResponseBody.swift index dd3385c..0a89a5c 100644 --- a/Sources/Plexswift/models/operations/GetPinResponseBody.swift +++ b/Sources/Plexswift/models/operations/GetPinResponseBody.swift @@ -18,7 +18,7 @@ extension Operations { @DecimalSerialized public private(set) var id: Double? public let location: Operations.Location? - public let newRegistration: String? + public let newRegistration: Bool? public let product: String? /// a link to a QR code hosted on plex.tv /// The QR code redirects to the relevant `plex.tv/link` authentication page @@ -35,7 +35,7 @@ extension Operations { /// Which then prompts the user for the 4 Digit Link Pin /// /// - public init(authToken: String? = nil, clientIdentifier: String? = nil, code: String? = nil, createdAt: Date? = nil, expiresAt: Date? = nil, expiresIn: Double? = nil, id: Double? = nil, location: Operations.Location? = nil, newRegistration: String? = nil, product: String? = nil, qr: String? = nil, trusted: Bool? = nil) { + public init(authToken: String? = nil, clientIdentifier: String? = nil, code: String? = nil, createdAt: Date? = nil, expiresAt: Date? = nil, expiresIn: Double? = nil, id: Double? = nil, location: Operations.Location? = nil, newRegistration: Bool? = nil, product: String? = nil, qr: String? = nil, trusted: Bool? = nil) { self.authToken = authToken self.clientIdentifier = clientIdentifier self.code = code @@ -78,7 +78,7 @@ extension Operations.GetPinResponseBody: Codable { self._expiresIn = try container.decodeIfPresent(DecimalSerialized.self, forKey: .expiresIn) ?? DecimalSerialized(wrappedValue: nil) self._id = try container.decodeIfPresent(DecimalSerialized.self, forKey: .id) ?? DecimalSerialized(wrappedValue: nil) self.location = try container.decodeIfPresent(Operations.Location.self, forKey: .location) - self.newRegistration = try container.decodeIfPresent(String.self, forKey: .newRegistration) + self.newRegistration = try container.decodeIfPresent(Bool.self, forKey: .newRegistration) self.product = try container.decodeIfPresent(String.self, forKey: .product) self.qr = try container.decodeIfPresent(String.self, forKey: .qr) self.trusted = try container.decodeIfPresent(Bool.self, forKey: .trusted) diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsErrors.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsErrors.swift new file mode 100644 index 0000000..42ec0e4 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsErrors.swift @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetResourcesStatisticsErrors { + @DecimalSerialized + public private(set) var code: Double? + public let message: String? + @DecimalSerialized + public private(set) var status: Double? + + /// Creates an object with the specified parameters + /// + /// + public init(code: Double? = nil, message: String? = nil, status: Double? = nil) { + self._code = DecimalSerialized(wrappedValue: code) + self.message = message + self._status = DecimalSerialized(wrappedValue: status) + } + } +} + +extension Operations.GetResourcesStatisticsErrors: Codable { + enum CodingKeys: String, CodingKey { + case code + case message + case status + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self._code = try container.decodeIfPresent(DecimalSerialized.self, forKey: .code) ?? DecimalSerialized(wrappedValue: nil) + self.message = try container.decodeIfPresent(String.self, forKey: .message) + self._status = try container.decodeIfPresent(DecimalSerialized.self, forKey: .status) ?? DecimalSerialized(wrappedValue: nil) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + if self.code != nil { + try container.encode(self._code, forKey: .code) + } + try container.encodeIfPresent(self.message, forKey: .message) + if self.status != nil { + try container.encode(self._status, forKey: .status) + } + } +} + +extension Operations.GetResourcesStatisticsErrors { + var codeWrapper: DecimalSerialized { + return _code + } + var statusWrapper: DecimalSerialized { + return _status + } +} diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsMediaContainer.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsMediaContainer.swift new file mode 100644 index 0000000..bfcd7e7 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsMediaContainer.swift @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetResourcesStatisticsMediaContainer { + public let size: Int? + public let statisticsResources: [Operations.StatisticsResources]? + + /// Creates an object with the specified parameters + /// + /// + public init(size: Int? = nil, statisticsResources: [Operations.StatisticsResources]? = nil) { + self.size = size + self.statisticsResources = statisticsResources + } + } +} + +extension Operations.GetResourcesStatisticsMediaContainer: Codable { + enum CodingKeys: String, CodingKey { + case size + case statisticsResources = "StatisticsResources" + } +} + diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsRequest.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsRequest.swift new file mode 100644 index 0000000..154bc54 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsRequest.swift @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetResourcesStatisticsRequest: APIValue { + /// The timespan to retrieve statistics for + /// the exact meaning of this parameter is not known + /// + public let timespan: Int? + + /// Creates an object with the specified parameters + /// + /// - Parameter timespan: The timespan to retrieve statistics for + /// the exact meaning of this parameter is not known + /// + /// + public init(timespan: Int? = nil) { + self.timespan = timespan + } + } +} diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsResponse.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsResponse.swift new file mode 100644 index 0000000..c04c42d --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsResponse.swift @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A response model + public enum GetResourcesStatisticsResponse { + case empty + case twoHundredApplicationJsonObject(Operations.GetResourcesStatisticsResponseBody) + case fourHundredAndOneApplicationJsonObject(Operations.GetResourcesStatisticsStatisticsResponseBody) + + var isEmpty: Bool { + if case .empty = self { + return true + } else { + return false + } + } + + public func twoHundredApplicationJsonObject() throws -> Operations.GetResourcesStatisticsResponseBody { + guard case .twoHundredApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + + public func fourHundredAndOneApplicationJsonObject() throws -> Operations.GetResourcesStatisticsStatisticsResponseBody { + guard case .fourHundredAndOneApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + } +} diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsResponseBody.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsResponseBody.swift new file mode 100644 index 0000000..ad4101f --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Resource Statistics + public struct GetResourcesStatisticsResponseBody { + public let mediaContainer: Operations.GetResourcesStatisticsMediaContainer? + + /// Creates an object with the specified parameters + /// + /// + public init(mediaContainer: Operations.GetResourcesStatisticsMediaContainer? = nil) { + self.mediaContainer = mediaContainer + } + } +} + +extension Operations.GetResourcesStatisticsResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case mediaContainer = "MediaContainer" + } +} + diff --git a/Sources/Plexswift/models/operations/GetResourcesStatisticsStatisticsResponseBody.swift b/Sources/Plexswift/models/operations/GetResourcesStatisticsStatisticsResponseBody.swift new file mode 100644 index 0000000..1102d83 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetResourcesStatisticsStatisticsResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + public struct GetResourcesStatisticsStatisticsResponseBody { + public let errors: [Operations.GetResourcesStatisticsErrors]? + + /// Creates an object with the specified parameters + /// + /// + public init(errors: [Operations.GetResourcesStatisticsErrors]? = nil) { + self.errors = errors + } + } +} + +extension Operations.GetResourcesStatisticsStatisticsResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case errors + } +} + diff --git a/Sources/Plexswift/models/operations/GetSessionHistoryRequest.swift b/Sources/Plexswift/models/operations/GetSessionHistoryRequest.swift new file mode 100644 index 0000000..90dadc6 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetSessionHistoryRequest.swift @@ -0,0 +1,41 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetSessionHistoryRequest: APIValue { + /// Filter results by those that are related to a specific users id + /// + public let accountId: Int? + /// Filters content by field and direction/equality + /// (Unknown if viewedAt is the only supported column) + /// + public let filter: Operations.Filter? + /// Filters the results based on the id of a valid library section + /// + public let librarySectionID: Int? + /// Sorts the results by the specified field followed by the direction (asc, desc) + /// + public let sort: String? + + /// Creates an object with the specified parameters + /// + /// - Parameter accountId: Filter results by those that are related to a specific users id + /// + /// - Parameter filter: Filters content by field and direction/equality + /// (Unknown if viewedAt is the only supported column) + /// + /// - Parameter librarySectionID: Filters the results based on the id of a valid library section + /// + /// - Parameter sort: Sorts the results by the specified field followed by the direction (asc, desc) + /// + /// + public init(accountId: Int? = nil, filter: Operations.Filter? = nil, librarySectionID: Int? = nil, sort: String? = nil) { + self.accountId = accountId + self.filter = filter + self.librarySectionID = librarySectionID + self.sort = sort + } + } +} diff --git a/Sources/Plexswift/models/operations/GetSessionsMetadata.swift b/Sources/Plexswift/models/operations/GetSessionsMetadata.swift index c3deece..0c797da 100644 --- a/Sources/Plexswift/models/operations/GetSessionsMetadata.swift +++ b/Sources/Plexswift/models/operations/GetSessionsMetadata.swift @@ -40,13 +40,13 @@ extension Operations { public let titleSort: String? public let type: String? public let updatedAt: Int? - public let user: Operations.User? + public let user: Operations.GetSessionsUser? public let viewOffset: Int? /// Creates an object with the specified parameters /// /// - public init(addedAt: Int? = nil, art: String? = nil, duration: Int? = nil, grandparentArt: String? = nil, grandparentGuid: String? = nil, grandparentKey: String? = nil, grandparentRatingKey: String? = nil, grandparentThumb: String? = nil, grandparentTitle: String? = nil, guid: String? = nil, index: Int? = nil, key: String? = nil, librarySectionID: String? = nil, librarySectionKey: String? = nil, librarySectionTitle: String? = nil, media: [Operations.GetSessionsMedia]? = nil, musicAnalysisVersion: String? = nil, parentGuid: String? = nil, parentIndex: Int? = nil, parentKey: String? = nil, parentRatingKey: String? = nil, parentStudio: String? = nil, parentThumb: String? = nil, parentTitle: String? = nil, parentYear: Int? = nil, player: Operations.Player? = nil, ratingCount: Int? = nil, ratingKey: String? = nil, session: Operations.Session? = nil, sessionKey: String? = nil, thumb: String? = nil, title: String? = nil, titleSort: String? = nil, type: String? = nil, updatedAt: Int? = nil, user: Operations.User? = nil, viewOffset: Int? = nil) { + public init(addedAt: Int? = nil, art: String? = nil, duration: Int? = nil, grandparentArt: String? = nil, grandparentGuid: String? = nil, grandparentKey: String? = nil, grandparentRatingKey: String? = nil, grandparentThumb: String? = nil, grandparentTitle: String? = nil, guid: String? = nil, index: Int? = nil, key: String? = nil, librarySectionID: String? = nil, librarySectionKey: String? = nil, librarySectionTitle: String? = nil, media: [Operations.GetSessionsMedia]? = nil, musicAnalysisVersion: String? = nil, parentGuid: String? = nil, parentIndex: Int? = nil, parentKey: String? = nil, parentRatingKey: String? = nil, parentStudio: String? = nil, parentThumb: String? = nil, parentTitle: String? = nil, parentYear: Int? = nil, player: Operations.Player? = nil, ratingCount: Int? = nil, ratingKey: String? = nil, session: Operations.Session? = nil, sessionKey: String? = nil, thumb: String? = nil, title: String? = nil, titleSort: String? = nil, type: String? = nil, updatedAt: Int? = nil, user: Operations.GetSessionsUser? = nil, viewOffset: Int? = nil) { self.addedAt = addedAt self.art = art self.duration = duration diff --git a/Sources/Plexswift/models/operations/GetSessionsUser.swift b/Sources/Plexswift/models/operations/GetSessionsUser.swift new file mode 100644 index 0000000..47c011a --- /dev/null +++ b/Sources/Plexswift/models/operations/GetSessionsUser.swift @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetSessionsUser { + public let id: String? + public let thumb: String? + public let title: String? + + /// Creates an object with the specified parameters + /// + /// + public init(id: String? = nil, thumb: String? = nil, title: String? = nil) { + self.id = id + self.thumb = thumb + self.title = title + } + } +} + +extension Operations.GetSessionsUser: Codable { + enum CodingKeys: String, CodingKey { + case id + case thumb + case title + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentCountry.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentCountry.swift new file mode 100644 index 0000000..b391739 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentCountry.swift @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentCountry { + public let filter: String? + public let id: Int? + public let tag: String? + + /// Creates an object with the specified parameters + /// + /// + public init(filter: String? = nil, id: Int? = nil, tag: String? = nil) { + self.filter = filter + self.id = id + self.tag = tag + } + } +} + +extension Operations.GetTopWatchedContentCountry: Codable { + enum CodingKeys: String, CodingKey { + case filter + case id + case tag + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentGenre.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentGenre.swift new file mode 100644 index 0000000..cad6890 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentGenre.swift @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentGenre { + public let filter: String? + public let id: Int? + public let tag: String? + + /// Creates an object with the specified parameters + /// + /// + public init(filter: String? = nil, id: Int? = nil, tag: String? = nil) { + self.filter = filter + self.id = id + self.tag = tag + } + } +} + +extension Operations.GetTopWatchedContentGenre: Codable { + enum CodingKeys: String, CodingKey { + case filter + case id + case tag + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentGuids.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentGuids.swift new file mode 100644 index 0000000..86e901d --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentGuids.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentGuids { + public let id: String? + + /// Creates an object with the specified parameters + /// + /// + public init(id: String? = nil) { + self.id = id + } + } +} + +extension Operations.GetTopWatchedContentGuids: Codable { + enum CodingKeys: String, CodingKey { + case id + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentMediaContainer.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentMediaContainer.swift new file mode 100644 index 0000000..bb9f7a2 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentMediaContainer.swift @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentMediaContainer { + public let allowSync: Bool? + public let identifier: String? + public let mediaTagPrefix: String? + public let mediaTagVersion: Int? + public let metadata: [Operations.GetTopWatchedContentMetadata]? + public let size: Int? + + /// Creates an object with the specified parameters + /// + /// + public init(allowSync: Bool? = nil, identifier: String? = nil, mediaTagPrefix: String? = nil, mediaTagVersion: Int? = nil, metadata: [Operations.GetTopWatchedContentMetadata]? = nil, size: Int? = nil) { + self.allowSync = allowSync + self.identifier = identifier + self.mediaTagPrefix = mediaTagPrefix + self.mediaTagVersion = mediaTagVersion + self.metadata = metadata + self.size = size + } + } +} + +extension Operations.GetTopWatchedContentMediaContainer: Codable { + enum CodingKeys: String, CodingKey { + case allowSync + case identifier + case mediaTagPrefix + case mediaTagVersion + case metadata = "Metadata" + case size + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentMetadata.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentMetadata.swift new file mode 100644 index 0000000..f47c5d5 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentMetadata.swift @@ -0,0 +1,203 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentMetadata { + public let addedAt: Int? + public let art: String? + @DecimalSerialized + public private(set) var audienceRating: Double? + public let audienceRatingImage: String? + public let childCount: Int? + public let contentRating: String? + public let country: [Operations.GetTopWatchedContentCountry]? + public let duration: Int? + public let genre: [Operations.GetTopWatchedContentGenre]? + public let globalViewCount: Int? + public let guid: String? + public let guids: [Operations.GetTopWatchedContentGuids]? + public let index: Int? + public let key: String? + public let leafCount: Int? + public let librarySectionID: Int? + public let librarySectionKey: String? + public let librarySectionTitle: String? + @DateOnly + public private(set) var originallyAvailableAt: Date? + public let ratingKey: String? + public let role: [Operations.GetTopWatchedContentRole]? + public let slug: String? + public let studio: String? + public let summary: String? + public let tagline: String? + public let thumb: String? + public let title: String? + public let type: String? + public let updatedAt: Int? + public let user: [Operations.User]? + public let viewedLeafCount: Int? + public let year: Int? + + /// Creates an object with the specified parameters + /// + /// + public init(addedAt: Int? = nil, art: String? = nil, audienceRating: Double? = nil, audienceRatingImage: String? = nil, childCount: Int? = nil, contentRating: String? = nil, country: [Operations.GetTopWatchedContentCountry]? = nil, duration: Int? = nil, genre: [Operations.GetTopWatchedContentGenre]? = nil, globalViewCount: Int? = nil, guid: String? = nil, guids: [Operations.GetTopWatchedContentGuids]? = nil, index: Int? = nil, key: String? = nil, leafCount: Int? = nil, librarySectionID: Int? = nil, librarySectionKey: String? = nil, librarySectionTitle: String? = nil, originallyAvailableAt: Date? = nil, ratingKey: String? = nil, role: [Operations.GetTopWatchedContentRole]? = nil, slug: String? = nil, studio: String? = nil, summary: String? = nil, tagline: String? = nil, thumb: String? = nil, title: String? = nil, type: String? = nil, updatedAt: Int? = nil, user: [Operations.User]? = nil, viewedLeafCount: Int? = nil, year: Int? = nil) { + self.addedAt = addedAt + self.art = art + self._audienceRating = DecimalSerialized(wrappedValue: audienceRating) + self.audienceRatingImage = audienceRatingImage + self.childCount = childCount + self.contentRating = contentRating + self.country = country + self.duration = duration + self.genre = genre + self.globalViewCount = globalViewCount + self.guid = guid + self.guids = guids + self.index = index + self.key = key + self.leafCount = leafCount + self.librarySectionID = librarySectionID + self.librarySectionKey = librarySectionKey + self.librarySectionTitle = librarySectionTitle + self._originallyAvailableAt = DateOnly(wrappedValue: originallyAvailableAt) + self.ratingKey = ratingKey + self.role = role + self.slug = slug + self.studio = studio + self.summary = summary + self.tagline = tagline + self.thumb = thumb + self.title = title + self.type = type + self.updatedAt = updatedAt + self.user = user + self.viewedLeafCount = viewedLeafCount + self.year = year + } + } +} + +extension Operations.GetTopWatchedContentMetadata: Codable { + enum CodingKeys: String, CodingKey { + case addedAt + case art + case audienceRating + case audienceRatingImage + case childCount + case contentRating + case country = "Country" + case duration + case genre = "Genre" + case globalViewCount + case guid + case guids = "Guid" + case index + case key + case leafCount + case librarySectionID + case librarySectionKey + case librarySectionTitle + case originallyAvailableAt + case ratingKey + case role = "Role" + case slug + case studio + case summary + case tagline + case thumb + case title + case type + case updatedAt + case user = "User" + case viewedLeafCount + case year + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.addedAt = try container.decodeIfPresent(Int.self, forKey: .addedAt) + self.art = try container.decodeIfPresent(String.self, forKey: .art) + self._audienceRating = try container.decodeIfPresent(DecimalSerialized.self, forKey: .audienceRating) ?? DecimalSerialized(wrappedValue: nil) + self.audienceRatingImage = try container.decodeIfPresent(String.self, forKey: .audienceRatingImage) + self.childCount = try container.decodeIfPresent(Int.self, forKey: .childCount) + self.contentRating = try container.decodeIfPresent(String.self, forKey: .contentRating) + self.country = try container.decodeIfPresent([Operations.GetTopWatchedContentCountry].self, forKey: .country) + self.duration = try container.decodeIfPresent(Int.self, forKey: .duration) + self.genre = try container.decodeIfPresent([Operations.GetTopWatchedContentGenre].self, forKey: .genre) + self.globalViewCount = try container.decodeIfPresent(Int.self, forKey: .globalViewCount) + self.guid = try container.decodeIfPresent(String.self, forKey: .guid) + self.guids = try container.decodeIfPresent([Operations.GetTopWatchedContentGuids].self, forKey: .guids) + self.index = try container.decodeIfPresent(Int.self, forKey: .index) + self.key = try container.decodeIfPresent(String.self, forKey: .key) + self.leafCount = try container.decodeIfPresent(Int.self, forKey: .leafCount) + self.librarySectionID = try container.decodeIfPresent(Int.self, forKey: .librarySectionID) + self.librarySectionKey = try container.decodeIfPresent(String.self, forKey: .librarySectionKey) + self.librarySectionTitle = try container.decodeIfPresent(String.self, forKey: .librarySectionTitle) + self._originallyAvailableAt = try container.decodeIfPresent(DateOnly.self, forKey: .originallyAvailableAt) ?? DateOnly(wrappedValue: nil) + self.ratingKey = try container.decodeIfPresent(String.self, forKey: .ratingKey) + self.role = try container.decodeIfPresent([Operations.GetTopWatchedContentRole].self, forKey: .role) + self.slug = try container.decodeIfPresent(String.self, forKey: .slug) + self.studio = try container.decodeIfPresent(String.self, forKey: .studio) + self.summary = try container.decodeIfPresent(String.self, forKey: .summary) + self.tagline = try container.decodeIfPresent(String.self, forKey: .tagline) + self.thumb = try container.decodeIfPresent(String.self, forKey: .thumb) + self.title = try container.decodeIfPresent(String.self, forKey: .title) + self.type = try container.decodeIfPresent(String.self, forKey: .type) + self.updatedAt = try container.decodeIfPresent(Int.self, forKey: .updatedAt) + self.user = try container.decodeIfPresent([Operations.User].self, forKey: .user) + self.viewedLeafCount = try container.decodeIfPresent(Int.self, forKey: .viewedLeafCount) + self.year = try container.decodeIfPresent(Int.self, forKey: .year) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(self.addedAt, forKey: .addedAt) + try container.encodeIfPresent(self.art, forKey: .art) + if self.audienceRating != nil { + try container.encode(self._audienceRating, forKey: .audienceRating) + } + try container.encodeIfPresent(self.audienceRatingImage, forKey: .audienceRatingImage) + try container.encodeIfPresent(self.childCount, forKey: .childCount) + try container.encodeIfPresent(self.contentRating, forKey: .contentRating) + try container.encodeIfPresent(self.country, forKey: .country) + try container.encodeIfPresent(self.duration, forKey: .duration) + try container.encodeIfPresent(self.genre, forKey: .genre) + try container.encodeIfPresent(self.globalViewCount, forKey: .globalViewCount) + try container.encodeIfPresent(self.guid, forKey: .guid) + try container.encodeIfPresent(self.guids, forKey: .guids) + try container.encodeIfPresent(self.index, forKey: .index) + try container.encodeIfPresent(self.key, forKey: .key) + try container.encodeIfPresent(self.leafCount, forKey: .leafCount) + try container.encodeIfPresent(self.librarySectionID, forKey: .librarySectionID) + try container.encodeIfPresent(self.librarySectionKey, forKey: .librarySectionKey) + try container.encodeIfPresent(self.librarySectionTitle, forKey: .librarySectionTitle) + if self.originallyAvailableAt != nil { + try container.encode(self._originallyAvailableAt, forKey: .originallyAvailableAt) + } + try container.encodeIfPresent(self.ratingKey, forKey: .ratingKey) + try container.encodeIfPresent(self.role, forKey: .role) + try container.encodeIfPresent(self.slug, forKey: .slug) + try container.encodeIfPresent(self.studio, forKey: .studio) + try container.encodeIfPresent(self.summary, forKey: .summary) + try container.encodeIfPresent(self.tagline, forKey: .tagline) + try container.encodeIfPresent(self.thumb, forKey: .thumb) + try container.encodeIfPresent(self.title, forKey: .title) + try container.encodeIfPresent(self.type, forKey: .type) + try container.encodeIfPresent(self.updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(self.user, forKey: .user) + try container.encodeIfPresent(self.viewedLeafCount, forKey: .viewedLeafCount) + try container.encodeIfPresent(self.year, forKey: .year) + } +} + +extension Operations.GetTopWatchedContentMetadata { + var audienceRatingWrapper: DecimalSerialized { + return _audienceRating + } + var originallyAvailableAtWrapper: DateOnly { + return _originallyAvailableAt + } +} diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentRequest.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentRequest.swift new file mode 100644 index 0000000..a9d9944 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentRequest.swift @@ -0,0 +1,25 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentRequest: APIValue { + /// the library type (1 - movies, 2 - shows, 3 - music) + public let type: Int + /// Adds the Guids object to the response + /// + public let includeGuids: Int? + + /// Creates an object with the specified parameters + /// + /// - Parameter type: the library type (1 - movies, 2 - shows, 3 - music) + /// - Parameter includeGuids: Adds the Guids object to the response + /// + /// + public init(type: Int, includeGuids: Int? = nil) { + self.type = type + self.includeGuids = includeGuids + } + } +} diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentResponse.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentResponse.swift new file mode 100644 index 0000000..29fb0fb --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentResponse.swift @@ -0,0 +1,26 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A response model + public enum GetTopWatchedContentResponse { + case empty + case object(Operations.GetTopWatchedContentResponseBody) + + var isEmpty: Bool { + if case .empty = self { + return true + } else { + return false + } + } + + public func object() throws -> Operations.GetTopWatchedContentResponseBody { + guard case .object(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + } +} diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentResponseBody.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentResponseBody.swift new file mode 100644 index 0000000..ecb2178 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// The metadata of the library item. + public struct GetTopWatchedContentResponseBody { + public let mediaContainer: Operations.GetTopWatchedContentMediaContainer? + + /// Creates an object with the specified parameters + /// + /// + public init(mediaContainer: Operations.GetTopWatchedContentMediaContainer? = nil) { + self.mediaContainer = mediaContainer + } + } +} + +extension Operations.GetTopWatchedContentResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case mediaContainer = "MediaContainer" + } +} + diff --git a/Sources/Plexswift/models/operations/GetTopWatchedContentRole.swift b/Sources/Plexswift/models/operations/GetTopWatchedContentRole.swift new file mode 100644 index 0000000..2d08337 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTopWatchedContentRole.swift @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTopWatchedContentRole { + public let filter: String? + public let id: Int? + public let role: String? + public let tag: String? + public let tagKey: String? + public let thumb: String? + + /// Creates an object with the specified parameters + /// + /// + public init(filter: String? = nil, id: Int? = nil, role: String? = nil, tag: String? = nil, tagKey: String? = nil, thumb: String? = nil) { + self.filter = filter + self.id = id + self.role = role + self.tag = tag + self.tagKey = tagKey + self.thumb = thumb + } + } +} + +extension Operations.GetTopWatchedContentRole: Codable { + enum CodingKeys: String, CodingKey { + case filter + case id + case role + case tag + case tagKey + case thumb + } +} + diff --git a/Sources/Plexswift/models/operations/GetWatchlistRequest.swift b/Sources/Plexswift/models/operations/GetWatchlistRequest.swift index f3084fd..2751d09 100644 --- a/Sources/Plexswift/models/operations/GetWatchlistRequest.swift +++ b/Sources/Plexswift/models/operations/GetWatchlistRequest.swift @@ -6,7 +6,7 @@ extension Operations { /// A model object public struct GetWatchlistRequest: APIValue { /// Filter - public let filter: Operations.Filter + public let filter: Operations.PathParamFilter /// User Token public let xPlexToken: String /// include collections in the results @@ -60,7 +60,7 @@ extension Operations { /// If the number of items exceeds the limit, the response will be paginated. /// /// - public init(filter: Operations.Filter, xPlexToken: String, includeCollections: Operations.IncludeCollections? = nil, includeExternalMedia: Operations.IncludeExternalMedia? = nil, libtype: Operations.Libtype? = nil, maxresults: Int? = nil, sort: String? = nil, xPlexContainerSize: Int? = nil, xPlexContainerStart: Int? = nil) { + public init(filter: Operations.PathParamFilter, xPlexToken: String, includeCollections: Operations.IncludeCollections? = nil, includeExternalMedia: Operations.IncludeExternalMedia? = nil, libtype: Operations.Libtype? = nil, maxresults: Int? = nil, sort: String? = nil, xPlexContainerSize: Int? = nil, xPlexContainerStart: Int? = nil) { self.filter = filter self.xPlexToken = xPlexToken self.includeCollections = includeCollections diff --git a/Sources/Plexswift/models/operations/LibrarySectionID.swift b/Sources/Plexswift/models/operations/LibrarySectionID.swift new file mode 100644 index 0000000..df51482 --- /dev/null +++ b/Sources/Plexswift/models/operations/LibrarySectionID.swift @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public enum LibrarySectionID { + case integer(Int) + case string(String) + } +} + +extension Operations.LibrarySectionID: Codable { + public init(from decoder: Decoder) throws { + if let value = try? Int(from: decoder) { + self = .integer(value) + } else if let value = try? String(from: decoder) { + self = .string(value) + } else { + throw PlexswiftError.failedToHandleResponse(.failedToDecodeResponse) + } + } + + public func encode(to encoder: Encoder) throws { + switch self { + case .integer(let value): + try value.encode(to: encoder) + case .string(let value): + try value.encode(to: encoder) + } + } +} + diff --git a/Sources/Plexswift/models/operations/PathParamFilter.swift b/Sources/Plexswift/models/operations/PathParamFilter.swift new file mode 100644 index 0000000..9ae6cdc --- /dev/null +++ b/Sources/Plexswift/models/operations/PathParamFilter.swift @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Filter + public enum PathParamFilter: String, Codable, APIValue { + case all = "all" + case available = "available" + case released = "released" + } +} diff --git a/Sources/Plexswift/models/operations/StatisticsBandwidth.swift b/Sources/Plexswift/models/operations/StatisticsBandwidth.swift new file mode 100644 index 0000000..ce03039 --- /dev/null +++ b/Sources/Plexswift/models/operations/StatisticsBandwidth.swift @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct StatisticsBandwidth { + public let accountID: Int? + public let at: Int? + public let bytes: Int? + public let deviceID: Int? + public let lan: Bool? + public let timespan: Int? + + /// Creates an object with the specified parameters + /// + /// + public init(accountID: Int? = nil, at: Int? = nil, bytes: Int? = nil, deviceID: Int? = nil, lan: Bool? = nil, timespan: Int? = nil) { + self.accountID = accountID + self.at = at + self.bytes = bytes + self.deviceID = deviceID + self.lan = lan + self.timespan = timespan + } + } +} + +extension Operations.StatisticsBandwidth: Codable { + enum CodingKeys: String, CodingKey { + case accountID + case at + case bytes + case deviceID + case lan + case timespan + } +} + diff --git a/Sources/Plexswift/models/operations/StatisticsResources.swift b/Sources/Plexswift/models/operations/StatisticsResources.swift new file mode 100644 index 0000000..03093c2 --- /dev/null +++ b/Sources/Plexswift/models/operations/StatisticsResources.swift @@ -0,0 +1,85 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct StatisticsResources { + public let at: Int? + @DecimalSerialized + public private(set) var hostCpuUtilization: Double? + @DecimalSerialized + public private(set) var hostMemoryUtilization: Double? + @DecimalSerialized + public private(set) var processCpuUtilization: Double? + @DecimalSerialized + public private(set) var processMemoryUtilization: Double? + public let timespan: Int? + + /// Creates an object with the specified parameters + /// + /// + public init(at: Int? = nil, hostCpuUtilization: Double? = nil, hostMemoryUtilization: Double? = nil, processCpuUtilization: Double? = nil, processMemoryUtilization: Double? = nil, timespan: Int? = nil) { + self.at = at + self._hostCpuUtilization = DecimalSerialized(wrappedValue: hostCpuUtilization) + self._hostMemoryUtilization = DecimalSerialized(wrappedValue: hostMemoryUtilization) + self._processCpuUtilization = DecimalSerialized(wrappedValue: processCpuUtilization) + self._processMemoryUtilization = DecimalSerialized(wrappedValue: processMemoryUtilization) + self.timespan = timespan + } + } +} + +extension Operations.StatisticsResources: Codable { + enum CodingKeys: String, CodingKey { + case at + case hostCpuUtilization + case hostMemoryUtilization + case processCpuUtilization + case processMemoryUtilization + case timespan + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.at = try container.decodeIfPresent(Int.self, forKey: .at) + self._hostCpuUtilization = try container.decodeIfPresent(DecimalSerialized.self, forKey: .hostCpuUtilization) ?? DecimalSerialized(wrappedValue: nil) + self._hostMemoryUtilization = try container.decodeIfPresent(DecimalSerialized.self, forKey: .hostMemoryUtilization) ?? DecimalSerialized(wrappedValue: nil) + self._processCpuUtilization = try container.decodeIfPresent(DecimalSerialized.self, forKey: .processCpuUtilization) ?? DecimalSerialized(wrappedValue: nil) + self._processMemoryUtilization = try container.decodeIfPresent(DecimalSerialized.self, forKey: .processMemoryUtilization) ?? DecimalSerialized(wrappedValue: nil) + self.timespan = try container.decodeIfPresent(Int.self, forKey: .timespan) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(self.at, forKey: .at) + if self.hostCpuUtilization != nil { + try container.encode(self._hostCpuUtilization, forKey: .hostCpuUtilization) + } + if self.hostMemoryUtilization != nil { + try container.encode(self._hostMemoryUtilization, forKey: .hostMemoryUtilization) + } + if self.processCpuUtilization != nil { + try container.encode(self._processCpuUtilization, forKey: .processCpuUtilization) + } + if self.processMemoryUtilization != nil { + try container.encode(self._processMemoryUtilization, forKey: .processMemoryUtilization) + } + try container.encodeIfPresent(self.timespan, forKey: .timespan) + } +} + +extension Operations.StatisticsResources { + var hostCpuUtilizationWrapper: DecimalSerialized { + return _hostCpuUtilization + } + var processCpuUtilizationWrapper: DecimalSerialized { + return _processCpuUtilization + } + var hostMemoryUtilizationWrapper: DecimalSerialized { + return _hostMemoryUtilization + } + var processMemoryUtilizationWrapper: DecimalSerialized { + return _processMemoryUtilization + } +} diff --git a/Sources/Plexswift/models/operations/User.swift b/Sources/Plexswift/models/operations/User.swift index 1cb3508..f0b4398 100644 --- a/Sources/Plexswift/models/operations/User.swift +++ b/Sources/Plexswift/models/operations/User.swift @@ -5,17 +5,13 @@ import Foundation extension Operations { /// A model object public struct User { - public let id: String? - public let thumb: String? - public let title: String? + public let id: Int? /// Creates an object with the specified parameters /// /// - public init(id: String? = nil, thumb: String? = nil, title: String? = nil) { + public init(id: Int? = nil) { self.id = id - self.thumb = thumb - self.title = title } } } @@ -23,8 +19,6 @@ extension Operations { extension Operations.User: Codable { enum CodingKeys: String, CodingKey { case id - case thumb - case title } } diff --git a/Sources/plexswift/PlexswiftAPI.swift b/Sources/plexswift/PlexswiftAPI.swift index ee515d9..fa40e9b 100644 --- a/Sources/plexswift/PlexswiftAPI.swift +++ b/Sources/plexswift/PlexswiftAPI.swift @@ -116,7 +116,7 @@ public protocol PlexswiftAPI { /// - ``getServerList()`` /// public protocol ServerAPI { - /// Server Capabilities + /// Get Server Capabilities /// /// - Returns: A ``Operations/GetServerCapabilitiesResponse`` object describing the result of the API operation /// - Throws: An error of type ``PlexswiftError`` @@ -535,6 +535,7 @@ public protocol SearchAPI { /// - ``searchLibrary(request:)`` /// - ``getMetadata(request:)`` /// - ``getMetadataChildren(request:)`` +/// - ``getTopWatchedContent(request:)`` /// - ``getOnDeck()`` /// public protocol LibraryAPI { @@ -693,6 +694,14 @@ public protocol LibraryAPI { /// - Throws: An error of type ``PlexswiftError`` func getMetadataChildren(request: Operations.GetMetadataChildrenRequest) async throws -> Response + /// This endpoint will return the top watched content from libraries of a certain type + /// + /// + /// - Parameter request: A ``Operations/GetTopWatchedContentRequest`` object describing the input to the API operation + /// - Returns: A ``Operations/GetTopWatchedContentResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getTopWatchedContent(request: Operations.GetTopWatchedContentRequest) async throws -> Response + /// This endpoint will return the on deck content. /// /// @@ -902,6 +911,8 @@ public protocol AuthenticationAPI { /// ### API calls /// /// - ``getStatistics(request:)`` +/// - ``getResourcesStatistics(request:)`` +/// - ``getBandwidthStatistics(request:)`` /// public protocol StatisticsAPI { /// This will return the media statistics for the server @@ -910,6 +921,20 @@ public protocol StatisticsAPI { /// - Returns: A ``Operations/GetStatisticsResponse`` object describing the result of the API operation /// - Throws: An error of type ``PlexswiftError`` func getStatistics(request: Operations.GetStatisticsRequest) async throws -> Response + + /// This will return the resources for the server + /// + /// - Parameter request: A ``Operations/GetResourcesStatisticsRequest`` object describing the input to the API operation + /// - Returns: A ``Operations/GetResourcesStatisticsResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getResourcesStatistics(request: Operations.GetResourcesStatisticsRequest) async throws -> Response + + /// This will return the bandwidth statistics for the server + /// + /// - Parameter request: A ``Operations/GetBandwidthStatisticsRequest`` object describing the input to the API operation + /// - Returns: A ``Operations/GetBandwidthStatisticsResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getBandwidthStatistics(request: Operations.GetBandwidthStatisticsRequest) async throws -> Response } // MARK: - SessionsAPI @@ -922,7 +947,7 @@ public protocol StatisticsAPI { /// ### API calls /// /// - ``getSessions()`` -/// - ``getSessionHistory()`` +/// - ``getSessionHistory(request:)`` /// - ``getTranscodeSessions()`` /// - ``stopTranscodeSession(request:)`` /// @@ -935,9 +960,10 @@ public protocol SessionsAPI { /// This will Retrieve a listing of all history views. /// + /// - Parameter request: A ``Operations/GetSessionHistoryRequest`` object describing the input to the API operation /// - Returns: A ``Operations/GetSessionHistoryResponse`` object describing the result of the API operation /// - Throws: An error of type ``PlexswiftError`` - func getSessionHistory() async throws -> Response + func getSessionHistory(request: Operations.GetSessionHistoryRequest) async throws -> Response /// Get Transcode Sessions /// diff --git a/Sources/plexswift/internal/client/URLRequestBuilder.swift b/Sources/plexswift/internal/client/URLRequestBuilder.swift index 068f46f..615d0fc 100644 --- a/Sources/plexswift/internal/client/URLRequestBuilder.swift +++ b/Sources/plexswift/internal/client/URLRequestBuilder.swift @@ -62,7 +62,7 @@ final class URLRequestBuilder: URLRequestConfiguration { urlRequest.setValue(contentType, forHTTPHeaderField: "Content-Type") } - urlRequest.setValue("speakeasy-sdk/swift 0.4.0 2.342.6 0.0.3 plexswift", forHTTPHeaderField: telemetryHeader.headerName) + urlRequest.setValue("speakeasy-sdk/swift 0.5.0 2.349.6 0.0.3 plexswift", forHTTPHeaderField: telemetryHeader.headerName) addSecurityParameters(to: &urlRequest) diff --git a/codeSamples.yaml b/codeSamples.yaml index 670604e..e88f621 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -3,12 +3,161 @@ info: title: CodeSamples overlay for swift target version: 0.0.0 actions: - - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] + - target: $["paths"]["/activities"]["get"] update: x-codeSamples: - lang: swift - label: startUniversalTranscode - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.startUniversalTranscode(\n request: Operations.StartUniversalTranscodeRequest(\n hasMDE: 1, \n mediaIndex: 0, \n partIndex: 0, \n path: \"/library/metadata/23409\", \n `protocol`: \"hls\", \n addDebugOverlay: 0, \n audioBoost: 100, \n autoAdjustQuality: 0, \n directPlay: 0, \n directStream: 0, \n fastSeek: 0, \n location: \"lan\", \n mediaBufferSize: 102400, \n session: \"zvcage8b7rkioqcm8f4uns4c\", \n subtites: \"burn\", \n subtitleSize: 100\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + label: getServerActivities + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.activities.getServerActivities() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] + update: + x-codeSamples: + - lang: swift + label: refreshLibrary + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.refreshLibrary( + request: Operations.RefreshLibraryRequest( + sectionId: 934.16 + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/security/token"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTransientToken + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.authentication.getTransientToken(\n request: Operations.GetTransientTokenRequest(\n scope: .all, \n type: .delegation\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/onDeck"]["get"] + update: + x-codeSamples: + - lang: swift + label: getOnDeck + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.getOnDeck() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/playlists/{playlistID}/items"]["get"] + update: + x-codeSamples: + - lang: swift + label: getPlaylistContents + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylistContents(\n request: Operations.GetPlaylistContentsRequest(\n playlistID: 5004.46, \n type: 9403.59\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/servers"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerList + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerList() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/activities/{activityUUID}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: cancelServerActivities + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.activities.cancelServerActivities( + request: Operations.CancelServerActivitiesRequest( + activityUUID: "25b71ed5-0f9d-461c-baa7-d404e9e10d3e" + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/butler"]["post"] + update: + x-codeSamples: + - lang: swift + label: startAllTasks + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.startAllTasks() + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } - target: $["paths"]["/library/recentlyAdded"]["get"] update: x-codeSamples: @@ -22,6 +171,201 @@ actions: let response = try await client.library.getRecentlyAdded() + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] + update: + x-codeSamples: + - lang: swift + label: searchLibrary + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.searchLibrary(\n request: Operations.SearchLibraryRequest(\n sectionId: 933505, \n type: .four\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}/items"]["put"] + update: + x-codeSamples: + - lang: swift + label: addPlaylistContents + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.addPlaylistContents(\n request: Operations.AddPlaylistContentsRequest(\n playlistID: 8502.01, \n uri: \"server://12345/com.plexapp.plugins.library/library/metadata/1\", \n playQueueID: 123\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/transcode/sessions"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTranscodeSessions + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.sessions.getTranscodeSessions() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/identity"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerIdentity + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerIdentity() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] + update: + x-codeSamples: + - lang: swift + label: startUniversalTranscode + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.startUniversalTranscode(\n request: Operations.StartUniversalTranscodeRequest(\n hasMDE: 1, \n mediaIndex: 0, \n partIndex: 0, \n path: \"/library/metadata/23409\", \n `protocol`: \"hls\", \n addDebugOverlay: 0, \n audioBoost: 100, \n autoAdjustQuality: 0, \n directPlay: 0, \n directStream: 0, \n fastSeek: 0, \n location: \"lan\", \n mediaBufferSize: 102400, \n session: \"zvcage8b7rkioqcm8f4uns4c\", \n subtites: \"burn\", \n subtitleSize: 100\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/hubs/search/voice"]["get"] + update: + x-codeSamples: + - lang: swift + label: performVoiceSearch + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performVoiceSearch(\n request: Operations.PerformVoiceSearchRequest(\n query: \"dead+poop\", \n limit: 5, \n sectionId: 4094.8\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/statistics/resources"]["get"] + update: + x-codeSamples: + - lang: swift + label: getResourcesStatistics + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.statistics.getResourcesStatistics( + request: Operations.GetResourcesStatisticsRequest( + timespan: 4 + ) + ) + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/photo/:/transcode"]["get"] + update: + x-codeSamples: + - lang: swift + label: getResizedPhoto + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.server.getResizedPhoto(\n request: Operations.GetResizedPhotoRequest(\n blur: 20, \n height: 165, \n minSize: .one, \n opacity: 96541, \n upscale: .zero, \n url: \"/library/metadata/49564/thumb/1654258204\", \n width: 110\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/:/unscrobble"]["get"] + update: + x-codeSamples: + - lang: swift + label: markUnplayed + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.media.markUnplayed( + request: Operations.MarkUnplayedRequest( + key: 59398 + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/all/top"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTopWatchedContent + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getTopWatchedContent(\n request: Operations.GetTopWatchedContentRequest(\n type: 505531, \n includeGuids: 1\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/sections/watchlist/{filter}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getWatchlist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.watchlist.getWatchlist(\n request: Operations.GetWatchlistRequest(\n filter: .released, \n xPlexToken: \"\", \n includeCollections: .one, \n includeExternalMedia: .one, \n libtype: .show, \n maxresults: 346553, \n sort: \"\", \n xPlexContainerSize: 406911, \n xPlexContainerStart: 958629\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/clients"]["get"] + update: + x-codeSamples: + - lang: swift + label: getAvailableClients + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getAvailableClients() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getMetadata + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.getMetadata( + request: Operations.GetMetadataRequest( + ratingKey: 8382.31 + ) + ) + switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): // Handle response @@ -50,372 +394,6 @@ actions: ) ) - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: stopTranscodeSession - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.sessions.stopTranscodeSession( - request: Operations.StopTranscodeSessionRequest( - sessionKey: "zz7llzqlx8w9vnrsbnwhbmep" - ) - ) - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/updater/apply"]["put"] - update: - x-codeSamples: - - lang: swift - label: applyUpdates - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.updater.applyUpdates(\n request: Operations.ApplyUpdatesRequest(\n skip: .one, \n tonight: .zero\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/activities"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerActivities - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.activities.getServerActivities() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/{sectionId}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: deleteLibrary - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.deleteLibrary( - request: Operations.DeleteLibraryRequest( - sectionId: 1000 - ) - ) - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists/{playlistID}"]["put"] - update: - x-codeSamples: - - lang: swift - label: updatePlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.updatePlaylist(\n request: Operations.UpdatePlaylistRequest(\n playlistID: 3915, \n summary: \"\", \n title: \"\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/security/token"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTransientToken - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.authentication.getTransientToken(\n request: Operations.GetTransientTokenRequest(\n scope: .all, \n type: .delegation\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists/{playlistID}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getPlaylist - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.playlists.getPlaylist( - request: Operations.GetPlaylistRequest( - playlistID: 4109.48 - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists/{playlistID}/items"]["get"] - update: - x-codeSamples: - - lang: swift - label: getPlaylistContents - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylistContents(\n request: Operations.GetPlaylistContentsRequest(\n playlistID: 5004.46, \n type: 9403.59\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/status/sessions"]["get"] - update: - x-codeSamples: - - lang: swift - label: getSessions - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.sessions.getSessions() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/updater/status"]["get"] - update: - x-codeSamples: - - lang: swift - label: getUpdateStatus - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.updater.getUpdateStatus() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/butler"]["get"] - update: - x-codeSamples: - - lang: swift - label: getButlerTasks - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.butler.getButlerTasks() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getLibraryItems - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibraryItems(\n request: Operations.GetLibraryItemsRequest(\n sectionId: AnyValue(\"\"), \n tag: .genre\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getMetadata - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getMetadata( - request: Operations.GetMetadataRequest( - ratingKey: 8382.31 - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists"]["post"] - update: - x-codeSamples: - - lang: swift - label: createPlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.createPlaylist(\n request: Operations.CreatePlaylistRequest(\n smart: .one, \n title: \"\", \n type: .photo, \n uri: \"https://inborn-brochure.biz\", \n playQueueID: 3686.33\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/:/timeline"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTimeline - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.getTimeline(\n request: Operations.GetTimelineRequest(\n context: \"home:hub.continueWatching\", \n duration: 10000, \n hasMDE: 1, \n key: \"/library/metadata/23409\", \n playBackTime: 2000, \n playQueueItemID: 1, \n ratingKey: 23409, \n row: 1, \n state: .playing, \n time: 2000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/myplex/account"]["get"] - update: - x-codeSamples: - - lang: swift - label: getMyPlexAccount - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getMyPlexAccount() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/hubs/sections/{sectionId}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getLibraryHubs - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getLibraryHubs(\n request: Operations.GetLibraryHubsRequest(\n sectionId: 6728.76, \n count: 9010.22, \n onlyTransient: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/onDeck"]["get"] - update: - x-codeSamples: - - lang: swift - label: getOnDeck - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getOnDeck() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/:/unscrobble"]["get"] - update: - x-codeSamples: - - lang: swift - label: markUnplayed - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.media.markUnplayed( - request: Operations.MarkUnplayedRequest( - key: 59398 - ) - ) - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] - update: - x-codeSamples: - - lang: swift - label: searchLibrary - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.searchLibrary(\n request: Operations.SearchLibraryRequest(\n sectionId: 933505, \n type: .four\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists/{playlistID}/items"]["put"] - update: - x-codeSamples: - - lang: swift - label: addPlaylistContents - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.addPlaylistContents(\n request: Operations.AddPlaylistContentsRequest(\n playlistID: 8502.01, \n uri: \"server://12345/com.plexapp.plugins.library/library/metadata/1\", \n playQueueID: 123\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/hashes"]["get"] - update: - x-codeSamples: - - lang: swift - label: getFileHash - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getFileHash(\n request: Operations.GetFileHashRequest(\n url: \"file://C:\\Image.png&type=13\", \n type: 4462.17\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists/{playlistID}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: deletePlaylist - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.playlists.deletePlaylist( - request: Operations.DeletePlaylistRequest( - playlistID: 216.22 - ) - ) - switch response.data { case .object(let object): // Handle response @@ -448,66 +426,12 @@ actions: // Handle empty response break } - - target: $["paths"]["/:/progress"]["post"] + - target: $["paths"]["/library/sections/{sectionId}"]["get"] update: x-codeSamples: - lang: swift - label: updatePlayProgress - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.media.updatePlayProgress(\n request: Operations.UpdatePlayProgressRequest(\n key: \"\", \n state: \"played\", \n time: 90000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/pins"]["post"] - update: - x-codeSamples: - - lang: swift - label: getPin - source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getPin(\n request: Operations.GetPinRequest(\n xPlexProduct: \"Postman\", \n strong: false, \n )\n)\n\nswitch response.data {\ncase .twoHundredAndOneApplicationJsonObject(let twoHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/identity"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerIdentity - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getServerIdentity() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/servers"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerList - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getServerList() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } + label: getLibrary + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibrary(\n request: Operations.GetLibraryRequest(\n sectionId: 1000, \n includeDetails: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - target: $["paths"]["/log"]["post"] update: x-codeSamples: @@ -521,113 +445,6 @@ actions: let response = try await client.log.logMultiLine() - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/watchlist/{filter}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getWatchlist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.watchlist.getWatchlist(\n request: Operations.GetWatchlistRequest(\n filter: .released, \n xPlexToken: \"\", \n includeCollections: .one, \n includeExternalMedia: .one, \n libtype: .show, \n maxresults: 346553, \n sort: \"\", \n xPlexContainerSize: 406911, \n xPlexContainerStart: 958629\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerCapabilities - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getServerCapabilities() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections"]["get"] - update: - x-codeSamples: - - lang: swift - label: getLibraries - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getLibraries() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] - update: - x-codeSamples: - - lang: swift - label: getMetadataChildren - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getMetadataChildren( - request: Operations.GetMetadataChildrenRequest( - ratingKey: 1539.14 - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] - update: - x-codeSamples: - - lang: swift - label: clearPlaylistContents - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.playlists.clearPlaylistContents( - request: Operations.ClearPlaylistContentsRequest( - playlistID: 1893.18 - ) - ) - switch response.data { case .object(let object): // Handle response @@ -664,41 +481,50 @@ actions: // Handle empty response break } - - target: $["paths"]["/butler"]["post"] + - target: $["paths"]["/:/progress"]["post"] update: x-codeSamples: - lang: swift - label: startAllTasks + label: updatePlayProgress + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.media.updatePlayProgress(\n request: Operations.UpdatePlayProgressRequest(\n key: \"\", \n state: \"played\", \n time: 90000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}"]["put"] + update: + x-codeSamples: + - lang: swift + label: updatePlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.updatePlaylist(\n request: Operations.UpdatePlaylistRequest(\n playlistID: 3915, \n summary: \"\", \n title: \"\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/upload"]["post"] + update: + x-codeSamples: + - lang: swift + label: uploadPlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.uploadPlaylist(\n request: Operations.UploadPlaylistRequest(\n force: .zero, \n path: \"/home/barkley/playlist.m3u\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/status/sessions/history/all"]["get"] + update: + x-codeSamples: + - lang: swift + label: getSessionHistory + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.sessions.getSessionHistory(\n request: Operations.GetSessionHistoryRequest(\n accountId: 1, \n filter: Operations.Filter(), \n librarySectionID: 12, \n sort: \"\"\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/pins/{pinID}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getToken + source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getToken(\n request: Operations.GetTokenRequest(\n pinID: \"\", \n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] + update: + x-codeSamples: + - lang: swift + label: clearPlaylistContents source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.butler.startAllTasks() - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/butler/{taskName}"]["post"] - update: - x-codeSamples: - - lang: swift - label: startTask - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.butler.startTask( - request: Operations.StartTaskRequest( - taskName: .cleanOldBundles + let response = try await client.playlists.clearPlaylistContents( + request: Operations.ClearPlaylistContentsRequest( + playlistID: 1893.18 ) ) @@ -710,18 +536,118 @@ actions: // Handle empty response break } - - target: $["paths"]["/log/networked"]["get"] + - target: $["paths"]["/pins"]["post"] update: x-codeSamples: - lang: swift - label: enablePaperTrail + label: getPin + source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getPin(\n request: Operations.GetPinRequest(\n xPlexProduct: \"Postman\", \n strong: false, \n )\n)\n\nswitch response.data {\ncase .twoHundredAndOneApplicationJsonObject(let twoHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] + update: + x-codeSamples: + - lang: swift + label: getMetadataChildren + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getMetadataChildren(\n request: Operations.GetMetadataChildrenRequest(\n ratingKey: 1539.14, \n includeElements: \"\"\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/log"]["get"] + update: + x-codeSamples: + - lang: swift + label: logLine + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.log.logLine(\n request: Operations.LogLineRequest(\n level: .three, \n message: \"Test log message\", \n source: \"Postman\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists"]["get"] + update: + x-codeSamples: + - lang: swift + label: getPlaylists + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylists(\n request: Operations.GetPlaylistsRequest(\n playlistType: .audio, \n smart: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/statistics/bandwidth"]["get"] + update: + x-codeSamples: + - lang: swift + label: getBandwidthStatistics source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.log.enablePaperTrail() + let response = try await client.statistics.getBandwidthStatistics( + request: Operations.GetBandwidthStatisticsRequest( + timespan: 4 + ) + ) + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/devices"]["get"] + update: + x-codeSamples: + - lang: swift + label: getDevices + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getDevices() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/myplex/account"]["get"] + update: + x-codeSamples: + - lang: swift + label: getMyPlexAccount + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getMyPlexAccount() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/butler"]["delete"] + update: + x-codeSamples: + - lang: swift + label: stopAllTasks + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.stopAllTasks() switch response.data { case .object(let object): @@ -731,72 +657,6 @@ actions: // Handle empty response break } - - target: $["paths"]["/playlists/upload"]["post"] - update: - x-codeSamples: - - lang: swift - label: uploadPlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.uploadPlaylist(\n request: Operations.UploadPlaylistRequest(\n force: .zero, \n path: \"/home/barkley/playlist.m3u\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/hubs"]["get"] - update: - x-codeSamples: - - lang: swift - label: getGlobalHubs - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getGlobalHubs(\n request: Operations.GetGlobalHubsRequest(\n count: 1262.49, \n onlyTransient: .one\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/hubs/search/voice"]["get"] - update: - x-codeSamples: - - lang: swift - label: performVoiceSearch - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performVoiceSearch(\n request: Operations.PerformVoiceSearchRequest(\n query: \"dead+poop\", \n limit: 5, \n sectionId: 4094.8\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/status/sessions/history/all"]["get"] - update: - x-codeSamples: - - lang: swift - label: getSessionHistory - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.sessions.getSessionHistory() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/clients"]["get"] - update: - x-codeSamples: - - lang: swift - label: getAvailableClients - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getAvailableClients() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - target: $["paths"]["/:/scrobble"]["get"] update: x-codeSamples: @@ -814,6 +674,144 @@ actions: ) ) + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/butler"]["get"] + update: + x-codeSamples: + - lang: swift + label: getButlerTasks + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.getButlerTasks() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/updater/apply"]["put"] + update: + x-codeSamples: + - lang: swift + label: applyUpdates + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.updater.applyUpdates(\n request: Operations.ApplyUpdatesRequest(\n skip: .one, \n tonight: .zero\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: deletePlaylist + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.playlists.deletePlaylist( + request: Operations.DeletePlaylistRequest( + playlistID: 216.22 + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/status/sessions"]["get"] + update: + x-codeSamples: + - lang: swift + label: getSessions + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.sessions.getSessions() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/search"]["get"] + update: + x-codeSamples: + - lang: swift + label: getSearchResults + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.search.getSearchResults( + request: Operations.GetSearchResultsRequest( + query: "110" + ) + ) + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/hashes"]["get"] + update: + x-codeSamples: + - lang: swift + label: getFileHash + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getFileHash(\n request: Operations.GetFileHashRequest(\n url: \"file://C:\\Image.png&type=13\", \n type: 4462.17\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/butler/{taskName}"]["post"] + update: + x-codeSamples: + - lang: swift + label: startTask + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.startTask( + request: Operations.StartTaskRequest( + taskName: .cleanOldBundles + ) + ) + switch response.data { case .object(let object): // Handle response @@ -871,20 +869,48 @@ actions: // Handle empty response break } - - target: $["paths"]["/activities/{activityUUID}"]["delete"] + - target: $["paths"]["/playlists/{playlistID}"]["get"] update: x-codeSamples: - lang: swift - label: cancelServerActivities + label: getPlaylist source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.activities.cancelServerActivities( - request: Operations.CancelServerActivitiesRequest( - activityUUID: "25b71ed5-0f9d-461c-baa7-d404e9e10d3e" + let response = try await client.playlists.getPlaylist( + request: Operations.GetPlaylistRequest( + playlistID: 4109.48 + ) + ) + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: stopTranscodeSession + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.sessions.stopTranscodeSession( + request: Operations.StopTranscodeSessionRequest( + sessionKey: "zz7llzqlx8w9vnrsbnwhbmep" ) ) @@ -902,30 +928,24 @@ actions: - lang: swift label: performSearch source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performSearch(\n request: Operations.PerformSearchRequest(\n query: \"dylan\", \n limit: 5, \n sectionId: 1516.53\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/sections/{sectionId}"]["get"] + - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] update: x-codeSamples: - lang: swift - label: getLibrary - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibrary(\n request: Operations.GetLibraryRequest(\n sectionId: 1000, \n includeDetails: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/log"]["get"] + label: getLibraryItems + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibraryItems(\n request: Operations.GetLibraryItemsRequest(\n sectionId: AnyValue(\"\"), \n tag: .genre, \n includeGuids: 1\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/log/networked"]["get"] update: x-codeSamples: - lang: swift - label: logLine - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.log.logLine(\n request: Operations.LogLineRequest(\n level: .three, \n message: \"Test log message\", \n source: \"Postman\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/butler"]["delete"] - update: - x-codeSamples: - - lang: swift - label: stopAllTasks + label: enablePaperTrail source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.butler.stopAllTasks() + let response = try await client.log.enablePaperTrail() switch response.data { case .object(let object): @@ -935,12 +955,54 @@ actions: // Handle empty response break } - - target: $["paths"]["/pins/{pinID}"]["get"] + - target: $["paths"]["/library/sections"]["get"] update: x-codeSamples: - lang: swift - label: getToken - source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getToken(\n request: Operations.GetTokenRequest(\n pinID: \"\", \n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + label: getLibraries + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.getLibraries() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/updater/status"]["get"] + update: + x-codeSamples: + - lang: swift + label: getUpdateStatus + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.updater.getUpdateStatus() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } - target: $["paths"]["/updater/check"]["put"] update: x-codeSamples: @@ -966,30 +1028,18 @@ actions: // Handle empty response break } - - target: $["paths"]["/photo/:/transcode"]["get"] + - target: $["paths"]["/"]["get"] update: x-codeSamples: - lang: swift - label: getResizedPhoto - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.server.getResizedPhoto(\n request: Operations.GetResizedPhotoRequest(\n blur: 20, \n height: 165, \n minSize: .one, \n opacity: 96541, \n upscale: .zero, \n url: \"/library/metadata/49564/thumb/1654258204\", \n width: 110\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists"]["get"] - update: - x-codeSamples: - - lang: swift - label: getPlaylists - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylists(\n request: Operations.GetPlaylistsRequest(\n playlistType: .audio, \n smart: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/transcode/sessions"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTranscodeSessions + label: getServerCapabilities source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.sessions.getTranscodeSessions() + let response = try await client.server.getServerCapabilities() switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): @@ -1002,72 +1052,38 @@ actions: // Handle empty response break } - - target: $["paths"]["/devices"]["get"] + - target: $["paths"]["/hubs"]["get"] update: x-codeSamples: - lang: swift - label: getDevices + label: getGlobalHubs + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getGlobalHubs(\n request: Operations.GetGlobalHubsRequest(\n count: 1262.49, \n onlyTransient: .one\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/hubs/sections/{sectionId}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getLibraryHubs + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getLibraryHubs(\n request: Operations.GetLibraryHubsRequest(\n sectionId: 6728.76, \n count: 9010.22, \n onlyTransient: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/:/timeline"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTimeline + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.getTimeline(\n request: Operations.GetTimelineRequest(\n context: \"home:hub.continueWatching\", \n duration: 10000, \n hasMDE: 1, \n key: \"/library/metadata/23409\", \n playBackTime: 2000, \n playQueueItemID: 1, \n ratingKey: 23409, \n row: 1, \n state: .playing, \n time: 2000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/sections/{sectionId}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: deleteLibrary source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.server.getDevices() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/search"]["get"] - update: - x-codeSamples: - - lang: swift - label: getSearchResults - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.search.getSearchResults( - request: Operations.GetSearchResultsRequest( - query: "110" - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] - update: - x-codeSamples: - - lang: swift - label: refreshLibrary - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.refreshLibrary( - request: Operations.RefreshLibraryRequest( - sectionId: 934.16 + let response = try await client.library.deleteLibrary( + request: Operations.DeleteLibraryRequest( + sectionId: 1000 ) ) @@ -1079,3 +1095,9 @@ actions: // Handle empty response break } + - target: $["paths"]["/playlists"]["post"] + update: + x-codeSamples: + - lang: swift + label: createPlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.createPlaylist(\n request: Operations.CreatePlaylistRequest(\n smart: .one, \n title: \"\", \n type: .photo, \n uri: \"https://inborn-brochure.biz\", \n playQueueID: 3686.33\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}"