mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 20:47:45 +00:00
1276 lines
59 KiB
Java
1276 lines
59 KiB
Java
/*
|
|
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
*/
|
|
|
|
package lukehagar.plexapi.plexapi;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import java.io.InputStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.net.http.HttpRequest;
|
|
import java.net.http.HttpResponse;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.Optional;
|
|
import lukehagar.plexapi.plexapi.models.errors.SDKError;
|
|
import lukehagar.plexapi.plexapi.models.operations.SDKMethodInterfaces.*;
|
|
import lukehagar.plexapi.plexapi.utils.HTTPClient;
|
|
import lukehagar.plexapi.plexapi.utils.HTTPRequest;
|
|
import lukehagar.plexapi.plexapi.utils.Hook.AfterErrorContextImpl;
|
|
import lukehagar.plexapi.plexapi.utils.Hook.AfterSuccessContextImpl;
|
|
import lukehagar.plexapi.plexapi.utils.Hook.BeforeRequestContextImpl;
|
|
import lukehagar.plexapi.plexapi.utils.JSON;
|
|
import lukehagar.plexapi.plexapi.utils.Retries.NonRetryableException;
|
|
import lukehagar.plexapi.plexapi.utils.Utils;
|
|
import org.apache.http.NameValuePair;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
|
|
/**
|
|
* Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017").
|
|
* They can be organized in (optionally nesting) folders.
|
|
* Retrieving a playlist, or its items, will trigger a refresh of its metadata.
|
|
* This may cause the duration and number of items to change.
|
|
*
|
|
*/
|
|
public class Playlists implements
|
|
MethodCallCreatePlaylist,
|
|
MethodCallGetPlaylists,
|
|
MethodCallGetPlaylist,
|
|
MethodCallDeletePlaylist,
|
|
MethodCallUpdatePlaylist,
|
|
MethodCallGetPlaylistContents,
|
|
MethodCallClearPlaylistContents,
|
|
MethodCallAddPlaylistContents,
|
|
MethodCallUploadPlaylist {
|
|
|
|
private final SDKConfiguration sdkConfiguration;
|
|
|
|
Playlists(SDKConfiguration sdkConfiguration) {
|
|
this.sdkConfiguration = sdkConfiguration;
|
|
}
|
|
|
|
|
|
/**
|
|
* Create a Playlist
|
|
* Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
|
|
* - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
|
|
* - `playQueueID` - To create a playlist from an existing play queue.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.CreatePlaylistRequestBuilder createPlaylist() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.CreatePlaylistRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Create a Playlist
|
|
* Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
|
|
* - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
|
|
* - `playQueueID` - To create a playlist from an existing play queue.
|
|
*
|
|
* @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 lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponse createPlaylist(
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistRequest request) throws Exception {
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
_baseUrl,
|
|
"/playlists");
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "POST");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("createPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("createPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("createPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("createPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.operations.CreatePlaylistResponseBody>() {});
|
|
_res.withObject(java.util.Optional.ofNullable(_out));
|
|
return _res;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.CreatePlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.CreatePlaylistResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Get All Playlists
|
|
* Get All Playlists given the specified filters.
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistsRequestBuilder getPlaylists() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.GetPlaylistsRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Get All Playlists
|
|
* Get All Playlists given the specified filters.
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponse getPlaylistsDirect() throws Exception {
|
|
return getPlaylists(Optional.empty(), Optional.empty());
|
|
}
|
|
/**
|
|
* Get All Playlists
|
|
* Get All Playlists given the specified filters.
|
|
* @param playlistType limit to a type of playlist.
|
|
* @param smart type of playlists to return (default is all).
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponse getPlaylists(
|
|
Optional<? extends lukehagar.plexapi.plexapi.models.operations.PlaylistType> playlistType,
|
|
Optional<? extends lukehagar.plexapi.plexapi.models.operations.QueryParamSmart> smart) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsRequest
|
|
.builder()
|
|
.playlistType(playlistType)
|
|
.smart(smart)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
_baseUrl,
|
|
"/playlists");
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "GET");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("getPlaylists", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("getPlaylists", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("getPlaylists", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("getPlaylists", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.operations.GetPlaylistsResponseBody>() {});
|
|
_res.withObject(java.util.Optional.ofNullable(_out));
|
|
return _res;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.GetPlaylistsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.GetPlaylistsResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Retrieve Playlist
|
|
* Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
|
|
* Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistRequestBuilder getPlaylist() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.GetPlaylistRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Playlist
|
|
* Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
|
|
* Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponse getPlaylist(
|
|
double playlistID) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "GET");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("getPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("getPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("getPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("getPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.operations.GetPlaylistResponseBody>() {});
|
|
_res.withObject(java.util.Optional.ofNullable(_out));
|
|
return _res;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.GetPlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.GetPlaylistResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Deletes a Playlist
|
|
* This endpoint will delete a playlist
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.DeletePlaylistRequestBuilder deletePlaylist() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.DeletePlaylistRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Deletes a Playlist
|
|
* This endpoint will delete a playlist
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.DeletePlaylistResponse deletePlaylist(
|
|
double playlistID) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "DELETE");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("deletePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("deletePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("deletePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("deletePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.DeletePlaylistResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "204")) {
|
|
// no content
|
|
return _res;
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.DeletePlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.DeletePlaylistResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Update a Playlist
|
|
* From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequestBuilder updatePlaylist() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Update a Playlist
|
|
* From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistResponse updatePlaylist(
|
|
double playlistID) throws Exception {
|
|
return updatePlaylist(playlistID, Optional.empty(), Optional.empty());
|
|
}
|
|
/**
|
|
* Update a Playlist
|
|
* From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @param title name of the playlist
|
|
* @param summary summary description of the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistResponse updatePlaylist(
|
|
double playlistID,
|
|
Optional<? extends String> title,
|
|
Optional<? extends String> summary) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.title(title)
|
|
.summary(summary)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "PUT");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("updatePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("updatePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("updatePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("updatePlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.UpdatePlaylistResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
// no content
|
|
return _res;
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.UpdatePlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.UpdatePlaylistResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Retrieve Playlist Contents
|
|
* Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
|
|
* By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
|
|
* For example, you could use this to display a list of recently added albums vis a smart playlist.
|
|
* Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequestBuilder getPlaylistContents() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Playlist Contents
|
|
* Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
|
|
* By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
|
|
* For example, you could use this to display a list of recently added albums vis a smart playlist.
|
|
* Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @param type the metadata type of the item to return
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponse getPlaylistContents(
|
|
double playlistID,
|
|
double type) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.type(type)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}/items",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "GET");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("getPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("getPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("getPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("getPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.operations.GetPlaylistContentsResponseBody>() {});
|
|
_res.withObject(java.util.Optional.ofNullable(_out));
|
|
return _res;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.GetPlaylistContentsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.GetPlaylistContentsResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Delete Playlist Contents
|
|
* Clears a playlist, only works with dumb playlists. Returns the playlist.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsRequestBuilder clearPlaylistContents() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Delete Playlist Contents
|
|
* Clears a playlist, only works with dumb playlists. Returns the playlist.
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsResponse clearPlaylistContents(
|
|
double playlistID) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}/items",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "DELETE");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("clearPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("clearPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("clearPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("clearPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.ClearPlaylistContentsResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
// no content
|
|
return _res;
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.ClearPlaylistContentsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.ClearPlaylistContentsResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Adding to a Playlist
|
|
* Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
|
|
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequestBuilder addPlaylistContents() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Adding to a Playlist
|
|
* Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
|
|
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @param uri the content URI for the playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponse addPlaylistContents(
|
|
double playlistID,
|
|
String uri) throws Exception {
|
|
return addPlaylistContents(playlistID, uri, Optional.empty());
|
|
}
|
|
/**
|
|
* Adding to a Playlist
|
|
* Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
|
|
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
|
*
|
|
* @param playlistID the ID of the playlist
|
|
* @param uri the content URI for the playlist
|
|
* @param playQueueID the play queue to add to a playlist
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponse addPlaylistContents(
|
|
double playlistID,
|
|
String uri,
|
|
Optional<? extends Double> playQueueID) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequest
|
|
.builder()
|
|
.playlistID(playlistID)
|
|
.uri(uri)
|
|
.playQueueID(playQueueID)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequest.class,
|
|
_baseUrl,
|
|
"/playlists/{playlistID}/items",
|
|
request, this.sdkConfiguration.globals);
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "PUT");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("addPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("addPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("addPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("addPlaylistContents", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.operations.AddPlaylistContentsResponseBody>() {});
|
|
_res.withObject(java.util.Optional.ofNullable(_out));
|
|
return _res;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.AddPlaylistContentsResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.AddPlaylistContentsResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Upload Playlist
|
|
* Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
|
|
*
|
|
* @return The call builder
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.UploadPlaylistRequestBuilder uploadPlaylist() {
|
|
return new lukehagar.plexapi.plexapi.models.operations.UploadPlaylistRequestBuilder(this);
|
|
}
|
|
|
|
/**
|
|
* Upload Playlist
|
|
* Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
|
|
*
|
|
* @param path absolute path to a directory on the server where m3u files are stored, or the absolute path to a playlist file on the server.
|
|
If the `path` argument is a directory, that path will be scanned for playlist files to be processed.
|
|
Each file in that directory creates a separate playlist, with a name based on the filename of the file that created it.
|
|
The GUID of each playlist is based on the filename.
|
|
If the `path` argument is a file, that file will be used to create a new playlist, with the name based on the filename of the file that created it.
|
|
The GUID of each playlist is based on the filename.
|
|
|
|
* @param force Force overwriting of duplicate playlists.
|
|
By default, a playlist file uploaded with the same path will overwrite the existing playlist.
|
|
The `force` argument is used to disable overwriting.
|
|
If the `force` argument is set to 0, a new playlist will be created suffixed with the date and time that the duplicate was uploaded.
|
|
|
|
* @return The response from the API call
|
|
* @throws Exception if the API call fails
|
|
*/
|
|
public lukehagar.plexapi.plexapi.models.operations.UploadPlaylistResponse uploadPlaylist(
|
|
String path,
|
|
lukehagar.plexapi.plexapi.models.operations.Force force) throws Exception {
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistRequest request =
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistRequest
|
|
.builder()
|
|
.path(path)
|
|
.force(force)
|
|
.build();
|
|
|
|
String _baseUrl = Utils.templateUrl(
|
|
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
|
String _url = Utils.generateURL(
|
|
_baseUrl,
|
|
"/playlists/upload");
|
|
|
|
HTTPRequest _req = new HTTPRequest(_url, "POST");
|
|
_req.addHeader("Accept", "application/json")
|
|
.addHeader("user-agent",
|
|
this.sdkConfiguration.userAgent);
|
|
|
|
_req.addQueryParams(Utils.getQueryParams(
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistRequest.class,
|
|
request,
|
|
this.sdkConfiguration.globals));
|
|
|
|
Utils.configureSecurity(_req,
|
|
this.sdkConfiguration.securitySource.getSecurity());
|
|
|
|
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
|
HttpRequest _r =
|
|
sdkConfiguration.hooks()
|
|
.beforeRequest(
|
|
new BeforeRequestContextImpl("uploadPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_req.build());
|
|
HttpResponse<InputStream> _httpRes;
|
|
try {
|
|
_httpRes = _client.send(_r);
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(
|
|
new AfterErrorContextImpl("uploadPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.of(_httpRes),
|
|
Optional.empty());
|
|
} else {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterSuccess(
|
|
new AfterSuccessContextImpl("uploadPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
_httpRes);
|
|
}
|
|
} catch (Exception _e) {
|
|
_httpRes = sdkConfiguration.hooks()
|
|
.afterError(new AfterErrorContextImpl("uploadPlaylist", Optional.of(java.util.List.of()), sdkConfiguration.securitySource()),
|
|
Optional.empty(),
|
|
Optional.of(_e));
|
|
}
|
|
String _contentType = _httpRes
|
|
.headers()
|
|
.firstValue("Content-Type")
|
|
.orElse("application/octet-stream");
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistResponse.Builder _resBuilder =
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistResponse
|
|
.builder()
|
|
.contentType(_contentType)
|
|
.statusCode(_httpRes.statusCode())
|
|
.rawResponse(_httpRes);
|
|
|
|
lukehagar.plexapi.plexapi.models.operations.UploadPlaylistResponse _res = _resBuilder.build();
|
|
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
|
// no content
|
|
return _res;
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
|
|
// no content
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"API error occurred",
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
|
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
|
lukehagar.plexapi.plexapi.models.errors.UploadPlaylistResponseBody _out = Utils.mapper().readValue(
|
|
Utils.toUtf8AndClose(_httpRes.body()),
|
|
new TypeReference<lukehagar.plexapi.plexapi.models.errors.UploadPlaylistResponseBody>() {});
|
|
_out.withRawResponse(java.util.Optional.ofNullable(_httpRes));
|
|
|
|
throw _out;
|
|
} else {
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected content-type received: " + _contentType,
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
}
|
|
throw new SDKError(
|
|
_httpRes,
|
|
_httpRes.statusCode(),
|
|
"Unexpected status code received: " + _httpRes.statusCode(),
|
|
Utils.toByteArrayAndClose(_httpRes.body()));
|
|
}
|
|
|
|
}
|