mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 04:20:46 +00:00
1201 lines
38 KiB
Go
1201 lines
38 KiB
Go
/*
|
|
Plex-API
|
|
|
|
An Open API Spec for interacting with Plex.tv and Plex Servers
|
|
|
|
API version: 0.0.3
|
|
Contact: Lukeslakemail@gmail.com
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package pms
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
|
|
// PlaylistsApiService PlaylistsApi service
|
|
type PlaylistsApiService service
|
|
|
|
type ApiAddPlaylistContentsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
uri *interface{}
|
|
playQueueID *interface{}
|
|
}
|
|
|
|
// the content URI for the playlist
|
|
func (r ApiAddPlaylistContentsRequest) Uri(uri interface{}) ApiAddPlaylistContentsRequest {
|
|
r.uri = &uri
|
|
return r
|
|
}
|
|
|
|
// the play queue to add to a playlist
|
|
func (r ApiAddPlaylistContentsRequest) PlayQueueID(playQueueID interface{}) ApiAddPlaylistContentsRequest {
|
|
r.playQueueID = &playQueueID
|
|
return r
|
|
}
|
|
|
|
func (r ApiAddPlaylistContentsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.AddPlaylistContentsExecute(r)
|
|
}
|
|
|
|
/*
|
|
AddPlaylistContents Adding to a Playlist
|
|
|
|
Adds a generator to a playlist, same parameters as the POST above. 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiAddPlaylistContentsRequest
|
|
*/
|
|
func (a *PlaylistsApiService) AddPlaylistContents(ctx context.Context, playlistID interface{}) ApiAddPlaylistContentsRequest {
|
|
return ApiAddPlaylistContentsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) AddPlaylistContentsExecute(r ApiAddPlaylistContentsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.AddPlaylistContents")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}/items"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.uri == nil {
|
|
return nil, reportError("uri is required and must be specified")
|
|
}
|
|
if r.playQueueID == nil {
|
|
return nil, reportError("playQueueID is required and must be specified")
|
|
}
|
|
|
|
parameterAddToQuery(localVarQueryParams, "uri", r.uri, "")
|
|
parameterAddToQuery(localVarQueryParams, "playQueueID", r.playQueueID, "")
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiClearPlaylistContentsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
}
|
|
|
|
func (r ApiClearPlaylistContentsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.ClearPlaylistContentsExecute(r)
|
|
}
|
|
|
|
/*
|
|
ClearPlaylistContents Delete Playlist Contents
|
|
|
|
Clears a playlist, only works with dumb playlists. Returns the playlist.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiClearPlaylistContentsRequest
|
|
*/
|
|
func (a *PlaylistsApiService) ClearPlaylistContents(ctx context.Context, playlistID interface{}) ApiClearPlaylistContentsRequest {
|
|
return ApiClearPlaylistContentsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) ClearPlaylistContentsExecute(r ApiClearPlaylistContentsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.ClearPlaylistContents")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}/items"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiCreatePlaylistRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
title *interface{}
|
|
type_ *interface{}
|
|
smart *interface{}
|
|
uri *interface{}
|
|
playQueueID *interface{}
|
|
}
|
|
|
|
// name of the playlist
|
|
func (r ApiCreatePlaylistRequest) Title(title interface{}) ApiCreatePlaylistRequest {
|
|
r.title = &title
|
|
return r
|
|
}
|
|
|
|
// type of playlist to create
|
|
func (r ApiCreatePlaylistRequest) Type_(type_ interface{}) ApiCreatePlaylistRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
// whether the playlist is smart or not
|
|
func (r ApiCreatePlaylistRequest) Smart(smart interface{}) ApiCreatePlaylistRequest {
|
|
r.smart = &smart
|
|
return r
|
|
}
|
|
|
|
// the content URI for the playlist
|
|
func (r ApiCreatePlaylistRequest) Uri(uri interface{}) ApiCreatePlaylistRequest {
|
|
r.uri = &uri
|
|
return r
|
|
}
|
|
|
|
// the play queue to copy to a playlist
|
|
func (r ApiCreatePlaylistRequest) PlayQueueID(playQueueID interface{}) ApiCreatePlaylistRequest {
|
|
r.playQueueID = &playQueueID
|
|
return r
|
|
}
|
|
|
|
func (r ApiCreatePlaylistRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.CreatePlaylistExecute(r)
|
|
}
|
|
|
|
/*
|
|
CreatePlaylist 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. `library://...`).
|
|
- `playQueueID` - To create a playlist from an existing play queue.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiCreatePlaylistRequest
|
|
*/
|
|
func (a *PlaylistsApiService) CreatePlaylist(ctx context.Context) ApiCreatePlaylistRequest {
|
|
return ApiCreatePlaylistRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) CreatePlaylistExecute(r ApiCreatePlaylistRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.CreatePlaylist")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.title == nil {
|
|
return nil, reportError("title is required and must be specified")
|
|
}
|
|
if r.type_ == nil {
|
|
return nil, reportError("type_ is required and must be specified")
|
|
}
|
|
if r.smart == nil {
|
|
return nil, reportError("smart is required and must be specified")
|
|
}
|
|
|
|
parameterAddToQuery(localVarQueryParams, "title", r.title, "")
|
|
parameterAddToQuery(localVarQueryParams, "type", r.type_, "")
|
|
parameterAddToQuery(localVarQueryParams, "smart", r.smart, "")
|
|
if r.uri != nil {
|
|
parameterAddToQuery(localVarQueryParams, "uri", r.uri, "")
|
|
}
|
|
if r.playQueueID != nil {
|
|
parameterAddToQuery(localVarQueryParams, "playQueueID", r.playQueueID, "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiDeletePlaylistRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
}
|
|
|
|
func (r ApiDeletePlaylistRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.DeletePlaylistExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeletePlaylist Deletes a Playlist
|
|
|
|
This endpoint will delete a playlist
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiDeletePlaylistRequest
|
|
*/
|
|
func (a *PlaylistsApiService) DeletePlaylist(ctx context.Context, playlistID interface{}) ApiDeletePlaylistRequest {
|
|
return ApiDeletePlaylistRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) DeletePlaylistExecute(r ApiDeletePlaylistRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.DeletePlaylist")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetPlaylistRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
}
|
|
|
|
func (r ApiGetPlaylistRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetPlaylistExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetPlaylist 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiGetPlaylistRequest
|
|
*/
|
|
func (a *PlaylistsApiService) GetPlaylist(ctx context.Context, playlistID interface{}) ApiGetPlaylistRequest {
|
|
return ApiGetPlaylistRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) GetPlaylistExecute(r ApiGetPlaylistRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.GetPlaylist")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetPlaylistContentsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
type_ *interface{}
|
|
}
|
|
|
|
// the metadata type of the item to return
|
|
func (r ApiGetPlaylistContentsRequest) Type_(type_ interface{}) ApiGetPlaylistContentsRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetPlaylistContentsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetPlaylistContentsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetPlaylistContents 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiGetPlaylistContentsRequest
|
|
*/
|
|
func (a *PlaylistsApiService) GetPlaylistContents(ctx context.Context, playlistID interface{}) ApiGetPlaylistContentsRequest {
|
|
return ApiGetPlaylistContentsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) GetPlaylistContentsExecute(r ApiGetPlaylistContentsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.GetPlaylistContents")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}/items"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.type_ == nil {
|
|
return nil, reportError("type_ is required and must be specified")
|
|
}
|
|
|
|
parameterAddToQuery(localVarQueryParams, "type", r.type_, "")
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetPlaylistsRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistType *interface{}
|
|
smart *interface{}
|
|
}
|
|
|
|
// limit to a type of playlist.
|
|
func (r ApiGetPlaylistsRequest) PlaylistType(playlistType interface{}) ApiGetPlaylistsRequest {
|
|
r.playlistType = &playlistType
|
|
return r
|
|
}
|
|
|
|
// type of playlists to return (default is all).
|
|
func (r ApiGetPlaylistsRequest) Smart(smart interface{}) ApiGetPlaylistsRequest {
|
|
r.smart = &smart
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetPlaylistsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetPlaylistsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetPlaylists Get All Playlists
|
|
|
|
Get All Playlists given the specified filters.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiGetPlaylistsRequest
|
|
*/
|
|
func (a *PlaylistsApiService) GetPlaylists(ctx context.Context) ApiGetPlaylistsRequest {
|
|
return ApiGetPlaylistsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) GetPlaylistsExecute(r ApiGetPlaylistsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.GetPlaylists")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/all"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.playlistType != nil {
|
|
parameterAddToQuery(localVarQueryParams, "playlistType", r.playlistType, "")
|
|
}
|
|
if r.smart != nil {
|
|
parameterAddToQuery(localVarQueryParams, "smart", r.smart, "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiUpdatePlaylistRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
playlistID interface{}
|
|
}
|
|
|
|
func (r ApiUpdatePlaylistRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.UpdatePlaylistExecute(r)
|
|
}
|
|
|
|
/*
|
|
UpdatePlaylist 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param playlistID the ID of the playlist
|
|
@return ApiUpdatePlaylistRequest
|
|
*/
|
|
func (a *PlaylistsApiService) UpdatePlaylist(ctx context.Context, playlistID interface{}) ApiUpdatePlaylistRequest {
|
|
return ApiUpdatePlaylistRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
playlistID: playlistID,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) UpdatePlaylistExecute(r ApiUpdatePlaylistRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.UpdatePlaylist")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/{playlistID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"playlistID"+"}", url.PathEscape(parameterValueToString(r.playlistID, "playlistID")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiUploadPlaylistRequest struct {
|
|
ctx context.Context
|
|
ApiService *PlaylistsApiService
|
|
path *interface{}
|
|
force *interface{}
|
|
}
|
|
|
|
// 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.
|
|
func (r ApiUploadPlaylistRequest) Path(path interface{}) ApiUploadPlaylistRequest {
|
|
r.path = &path
|
|
return r
|
|
}
|
|
|
|
// 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.
|
|
func (r ApiUploadPlaylistRequest) Force(force interface{}) ApiUploadPlaylistRequest {
|
|
r.force = &force
|
|
return r
|
|
}
|
|
|
|
func (r ApiUploadPlaylistRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.UploadPlaylistExecute(r)
|
|
}
|
|
|
|
/*
|
|
UploadPlaylist 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiUploadPlaylistRequest
|
|
*/
|
|
func (a *PlaylistsApiService) UploadPlaylist(ctx context.Context) ApiUploadPlaylistRequest {
|
|
return ApiUploadPlaylistRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *PlaylistsApiService) UploadPlaylistExecute(r ApiUploadPlaylistRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlaylistsApiService.UploadPlaylist")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/playlists/upload"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.path == nil {
|
|
return nil, reportError("path is required and must be specified")
|
|
}
|
|
if r.force == nil {
|
|
return nil, reportError("force is required and must be specified")
|
|
}
|
|
|
|
parameterAddToQuery(localVarQueryParams, "path", r.path, "")
|
|
parameterAddToQuery(localVarQueryParams, "force", r.force, "")
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.ctx != nil {
|
|
// API Key Authentication
|
|
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
|
if apiKey, ok := auth["accessToken"]; ok {
|
|
var key string
|
|
if apiKey.Prefix != "" {
|
|
key = apiKey.Prefix + " " + apiKey.Key
|
|
} else {
|
|
key = apiKey.Key
|
|
}
|
|
localVarHeaderParams["X-Plex-Token"] = key
|
|
}
|
|
}
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v GetServerCapabilities401Response
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|