/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ package dev.plexapi.sdk; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.models.errors.GetAvailableClientsBadRequest; import dev.plexapi.sdk.models.errors.GetAvailableClientsUnauthorized; import dev.plexapi.sdk.models.errors.GetDevicesBadRequest; import dev.plexapi.sdk.models.errors.GetDevicesUnauthorized; import dev.plexapi.sdk.models.errors.GetMediaProvidersBadRequest; import dev.plexapi.sdk.models.errors.GetMediaProvidersUnauthorized; import dev.plexapi.sdk.models.errors.GetMyPlexAccountBadRequest; import dev.plexapi.sdk.models.errors.GetMyPlexAccountUnauthorized; import dev.plexapi.sdk.models.errors.GetResizedPhotoBadRequest; import dev.plexapi.sdk.models.errors.GetResizedPhotoUnauthorized; import dev.plexapi.sdk.models.errors.GetServerCapabilitiesBadRequest; import dev.plexapi.sdk.models.errors.GetServerCapabilitiesUnauthorized; import dev.plexapi.sdk.models.errors.GetServerIdentityRequestTimeout; import dev.plexapi.sdk.models.errors.GetServerListBadRequest; import dev.plexapi.sdk.models.errors.GetServerListUnauthorized; import dev.plexapi.sdk.models.errors.GetServerPreferencesBadRequest; import dev.plexapi.sdk.models.errors.GetServerPreferencesUnauthorized; import dev.plexapi.sdk.models.errors.SDKError; import dev.plexapi.sdk.models.operations.GetAvailableClientsRequestBuilder; import dev.plexapi.sdk.models.operations.GetAvailableClientsResponse; import dev.plexapi.sdk.models.operations.GetAvailableClientsResponseBody; import dev.plexapi.sdk.models.operations.GetDevicesRequestBuilder; import dev.plexapi.sdk.models.operations.GetDevicesResponse; import dev.plexapi.sdk.models.operations.GetDevicesResponseBody; import dev.plexapi.sdk.models.operations.GetMediaProvidersRequest; import dev.plexapi.sdk.models.operations.GetMediaProvidersRequestBuilder; import dev.plexapi.sdk.models.operations.GetMediaProvidersResponse; import dev.plexapi.sdk.models.operations.GetMediaProvidersResponseBody; import dev.plexapi.sdk.models.operations.GetMyPlexAccountRequestBuilder; import dev.plexapi.sdk.models.operations.GetMyPlexAccountResponse; import dev.plexapi.sdk.models.operations.GetMyPlexAccountResponseBody; import dev.plexapi.sdk.models.operations.GetResizedPhotoRequest; import dev.plexapi.sdk.models.operations.GetResizedPhotoRequestBuilder; import dev.plexapi.sdk.models.operations.GetResizedPhotoResponse; import dev.plexapi.sdk.models.operations.GetServerCapabilitiesRequestBuilder; import dev.plexapi.sdk.models.operations.GetServerCapabilitiesResponse; import dev.plexapi.sdk.models.operations.GetServerCapabilitiesResponseBody; import dev.plexapi.sdk.models.operations.GetServerIdentityRequestBuilder; import dev.plexapi.sdk.models.operations.GetServerIdentityResponse; import dev.plexapi.sdk.models.operations.GetServerIdentityResponseBody; import dev.plexapi.sdk.models.operations.GetServerListRequestBuilder; import dev.plexapi.sdk.models.operations.GetServerListResponse; import dev.plexapi.sdk.models.operations.GetServerListResponseBody; import dev.plexapi.sdk.models.operations.GetServerPreferencesRequestBuilder; import dev.plexapi.sdk.models.operations.GetServerPreferencesResponse; import dev.plexapi.sdk.models.operations.GetServerPreferencesResponseBody; import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*; import dev.plexapi.sdk.utils.HTTPClient; import dev.plexapi.sdk.utils.HTTPRequest; import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl; import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl; import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl; import dev.plexapi.sdk.utils.Utils; import java.io.InputStream; import java.lang.Exception; import java.lang.String; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.List; import java.util.Optional; /** * Operations against the Plex Media Server System. */ public class Server implements MethodCallGetServerCapabilities, MethodCallGetServerPreferences, MethodCallGetAvailableClients, MethodCallGetDevices, MethodCallGetServerIdentity, MethodCallGetMyPlexAccount, MethodCallGetResizedPhoto, MethodCallGetMediaProviders, MethodCallGetServerList { private final SDKConfiguration sdkConfiguration; Server(SDKConfiguration sdkConfiguration) { this.sdkConfiguration = sdkConfiguration; } /** * Get Server Capabilities * *

Get Server Capabilities * * @return The call builder */ public GetServerCapabilitiesRequestBuilder getServerCapabilities() { return new GetServerCapabilitiesRequestBuilder(this); } /** * Get Server Capabilities * *

Get Server Capabilities * * @return The response from the API call * @throws Exception if the API call fails */ public GetServerCapabilitiesResponse getServerCapabilitiesDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getServerCapabilities", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerCapabilities", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getServerCapabilities", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerCapabilities", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetServerCapabilitiesResponse.Builder _resBuilder = GetServerCapabilitiesResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetServerCapabilitiesResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerCapabilitiesResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerCapabilitiesBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerCapabilitiesUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Server Preferences * *

Get Server Preferences * * @return The call builder */ public GetServerPreferencesRequestBuilder getServerPreferences() { return new GetServerPreferencesRequestBuilder(this); } /** * Get Server Preferences * *

Get Server Preferences * * @return The response from the API call * @throws Exception if the API call fails */ public GetServerPreferencesResponse getServerPreferencesDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/:/prefs"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getServerPreferences", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerPreferences", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getServerPreferences", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerPreferences", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetServerPreferencesResponse.Builder _resBuilder = GetServerPreferencesResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetServerPreferencesResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerPreferencesResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerPreferencesBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerPreferencesUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Available Clients * *

Get Available Clients * * @return The call builder */ public GetAvailableClientsRequestBuilder getAvailableClients() { return new GetAvailableClientsRequestBuilder(this); } /** * Get Available Clients * *

Get Available Clients * * @return The response from the API call * @throws Exception if the API call fails */ public GetAvailableClientsResponse getAvailableClientsDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/clients"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getAvailableClients", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getAvailableClients", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getAvailableClients", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getAvailableClients", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetAvailableClientsResponse.Builder _resBuilder = GetAvailableClientsResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetAvailableClientsResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetAvailableClientsResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetAvailableClientsBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetAvailableClientsUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Devices * *

Get Devices * * @return The call builder */ public GetDevicesRequestBuilder getDevices() { return new GetDevicesRequestBuilder(this); } /** * Get Devices * *

Get Devices * * @return The response from the API call * @throws Exception if the API call fails */ public GetDevicesResponse getDevicesDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/devices"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getDevices", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getDevices", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getDevices", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getDevices", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetDevicesResponse.Builder _resBuilder = GetDevicesResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetDevicesResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetDevicesResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetDevicesBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetDevicesUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Server Identity * *

This request is useful to determine if the server is online or offline * * @return The call builder */ public GetServerIdentityRequestBuilder getServerIdentity() { return new GetServerIdentityRequestBuilder(this); } /** * Get Server Identity * *

This request is useful to determine if the server is online or offline * * @return The response from the API call * @throws Exception if the API call fails */ public GetServerIdentityResponse getServerIdentityDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/identity"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = Optional.empty(); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "get-server-identity", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "408", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "get-server-identity", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "get-server-identity", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "get-server-identity", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetServerIdentityResponse.Builder _resBuilder = GetServerIdentityResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetServerIdentityResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerIdentityResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "408")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerIdentityRequestTimeout _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get MyPlex Account * *

Returns MyPlex Account Information * * @return The call builder */ public GetMyPlexAccountRequestBuilder getMyPlexAccount() { return new GetMyPlexAccountRequestBuilder(this); } /** * Get MyPlex Account * *

Returns MyPlex Account Information * * @return The response from the API call * @throws Exception if the API call fails */ public GetMyPlexAccountResponse getMyPlexAccountDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/myplex/account"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getMyPlexAccount", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getMyPlexAccount", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getMyPlexAccount", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getMyPlexAccount", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetMyPlexAccountResponse.Builder _resBuilder = GetMyPlexAccountResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetMyPlexAccountResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMyPlexAccountResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMyPlexAccountBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMyPlexAccountUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get a Resized Photo * *

Plex's Photo transcoder is used throughout the service to serve images at specified sizes. * * @return The call builder */ public GetResizedPhotoRequestBuilder getResizedPhoto() { return new GetResizedPhotoRequestBuilder(this); } /** * Get a Resized Photo * *

Plex's Photo transcoder is used throughout the service to serve images at specified sizes. * * @param request The request object containing all of the parameters for the API call. * @return The response from the API call * @throws Exception if the API call fails */ public GetResizedPhotoResponse getResizedPhoto( GetResizedPhotoRequest request) throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/photo/:/transcode"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); _req.addQueryParams(Utils.getQueryParams( GetResizedPhotoRequest.class, request, null)); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getResizedPhoto", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getResizedPhoto", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getResizedPhoto", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getResizedPhoto", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetResizedPhotoResponse.Builder _resBuilder = GetResizedPhotoResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetResizedPhotoResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { // no content return _res; } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetResizedPhotoBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetResizedPhotoUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Media Providers * *

Retrieves media providers and their features from the Plex server. * * @return The call builder */ public GetMediaProvidersRequestBuilder getMediaProviders() { return new GetMediaProvidersRequestBuilder(this); } /** * Get Media Providers * *

Retrieves media providers and their features from the Plex server. * * @param xPlexToken An authentication token, obtained from plex.tv * @return The response from the API call * @throws Exception if the API call fails */ public GetMediaProvidersResponse getMediaProviders( String xPlexToken) throws Exception { GetMediaProvidersRequest request = GetMediaProvidersRequest .builder() .xPlexToken(xPlexToken) .build(); String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/media/providers"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); _req.addHeaders(Utils.getHeadersFromMetadata(request, null)); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "get-media-providers", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "get-media-providers", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "get-media-providers", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "get-media-providers", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetMediaProvidersResponse.Builder _resBuilder = GetMediaProvidersResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetMediaProvidersResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMediaProvidersResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMediaProvidersBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetMediaProvidersUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } /** * Get Server List * *

Get Server List * * @return The call builder */ public GetServerListRequestBuilder getServerList() { return new GetServerListRequestBuilder(this); } /** * Get Server List * *

Get Server List * * @return The response from the API call * @throws Exception if the API call fails */ public GetServerListResponse getServerListDirect() throws Exception { String _baseUrl = Utils.templateUrl( this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults()); String _url = Utils.generateURL( _baseUrl, "/servers"); HTTPRequest _req = new HTTPRequest(_url, "GET"); _req.addHeader("Accept", "application/json") .addHeader("user-agent", SDKConfiguration.USER_AGENT); Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); Utils.configureSecurity(_req, this.sdkConfiguration.securitySource.getSecurity()); HTTPClient _client = this.sdkConfiguration.defaultClient; HttpRequest _r = sdkConfiguration.hooks() .beforeRequest( new BeforeRequestContextImpl( _baseUrl, "getServerList", Optional.of(List.of()), _hookSecuritySource), _req.build()); HttpResponse _httpRes; try { _httpRes = _client.send(_r); if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerList", Optional.of(List.of()), _hookSecuritySource), Optional.of(_httpRes), Optional.empty()); } else { _httpRes = sdkConfiguration.hooks() .afterSuccess( new AfterSuccessContextImpl( _baseUrl, "getServerList", Optional.of(List.of()), _hookSecuritySource), _httpRes); } } catch (Exception _e) { _httpRes = sdkConfiguration.hooks() .afterError( new AfterErrorContextImpl( _baseUrl, "getServerList", Optional.of(List.of()), _hookSecuritySource), Optional.empty(), Optional.of(_e)); } String _contentType = _httpRes .headers() .firstValue("Content-Type") .orElse("application/octet-stream"); GetServerListResponse.Builder _resBuilder = GetServerListResponse .builder() .contentType(_contentType) .statusCode(_httpRes.statusCode()) .rawResponse(_httpRes); GetServerListResponse _res = _resBuilder.build(); if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerListResponseBody _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _res.withObject(Optional.ofNullable(_out)); return _res; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerListBadRequest _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) { if (Utils.contentTypeMatches(_contentType, "application/json")) { GetServerListUnauthorized _out = Utils.mapper().readValue( Utils.toUtf8AndClose(_httpRes.body()), new TypeReference() {}); _out.withRawResponse(Optional.ofNullable(_httpRes)); throw _out; } else { throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected content-type received: " + _contentType, Utils.extractByteArrayFromBody(_httpRes)); } } if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) { // no content throw new SDKError( _httpRes, _httpRes.statusCode(), "API error occurred", Utils.extractByteArrayFromBody(_httpRes)); } throw new SDKError( _httpRes, _httpRes.statusCode(), "Unexpected status code received: " + _httpRes.statusCode(), Utils.extractByteArrayFromBody(_httpRes)); } }