mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 04:20:46 +00:00
1551 lines
49 KiB
Go
1551 lines
49 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"
|
|
)
|
|
|
|
|
|
// LibraryApiService LibraryApi service
|
|
type LibraryApiService service
|
|
|
|
type ApiDeleteLibraryRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
}
|
|
|
|
func (r ApiDeleteLibraryRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.DeleteLibraryExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteLibrary Delete Library Section
|
|
|
|
Delate a library using a specific section
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to query
|
|
@return ApiDeleteLibraryRequest
|
|
*/
|
|
func (a *LibraryApiService) DeleteLibrary(ctx context.Context, sectionId interface{}) ApiDeleteLibraryRequest {
|
|
return ApiDeleteLibraryRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) DeleteLibraryExecute(r ApiDeleteLibraryRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.DeleteLibrary")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -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 ApiGetCommonLibraryItemsRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
type_ *interface{}
|
|
filter *interface{}
|
|
}
|
|
|
|
// item type
|
|
func (r ApiGetCommonLibraryItemsRequest) Type_(type_ interface{}) ApiGetCommonLibraryItemsRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
// the filter parameter
|
|
func (r ApiGetCommonLibraryItemsRequest) Filter(filter interface{}) ApiGetCommonLibraryItemsRequest {
|
|
r.filter = &filter
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetCommonLibraryItemsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetCommonLibraryItemsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCommonLibraryItems Get Common Library Items
|
|
|
|
Represents a "Common" item. It contains only the common attributes of the items selected by the provided filter
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to query
|
|
@return ApiGetCommonLibraryItemsRequest
|
|
*/
|
|
func (a *LibraryApiService) GetCommonLibraryItems(ctx context.Context, sectionId interface{}) ApiGetCommonLibraryItemsRequest {
|
|
return ApiGetCommonLibraryItemsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetCommonLibraryItemsExecute(r ApiGetCommonLibraryItemsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetCommonLibraryItems")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}/common"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -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_, "")
|
|
if r.filter != nil {
|
|
parameterAddToQuery(localVarQueryParams, "filter", r.filter, "")
|
|
}
|
|
// 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, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetFileHashRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
url *interface{}
|
|
type_ *interface{}
|
|
}
|
|
|
|
// This is the path to the local file, must be prefixed by `file://`
|
|
func (r ApiGetFileHashRequest) Url(url interface{}) ApiGetFileHashRequest {
|
|
r.url = &url
|
|
return r
|
|
}
|
|
|
|
// Item type
|
|
func (r ApiGetFileHashRequest) Type_(type_ interface{}) ApiGetFileHashRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetFileHashRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetFileHashExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetFileHash Get Hash Value
|
|
|
|
This resource returns hash values for local files
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiGetFileHashRequest
|
|
*/
|
|
func (a *LibraryApiService) GetFileHash(ctx context.Context) ApiGetFileHashRequest {
|
|
return ApiGetFileHashRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetFileHashExecute(r ApiGetFileHashRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetFileHash")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/hashes"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.url == nil {
|
|
return nil, reportError("url is required and must be specified")
|
|
}
|
|
|
|
parameterAddToQuery(localVarQueryParams, "url", r.url, "")
|
|
if r.type_ != nil {
|
|
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 ApiGetLatestLibraryItemsRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
type_ *interface{}
|
|
filter *interface{}
|
|
}
|
|
|
|
// item type
|
|
func (r ApiGetLatestLibraryItemsRequest) Type_(type_ interface{}) ApiGetLatestLibraryItemsRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
// the filter parameter
|
|
func (r ApiGetLatestLibraryItemsRequest) Filter(filter interface{}) ApiGetLatestLibraryItemsRequest {
|
|
r.filter = &filter
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetLatestLibraryItemsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetLatestLibraryItemsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetLatestLibraryItems Get Latest Library Items
|
|
|
|
This endpoint will return a list of the latest library items filtered by the filter and type provided
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to query
|
|
@return ApiGetLatestLibraryItemsRequest
|
|
*/
|
|
func (a *LibraryApiService) GetLatestLibraryItems(ctx context.Context, sectionId interface{}) ApiGetLatestLibraryItemsRequest {
|
|
return ApiGetLatestLibraryItemsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetLatestLibraryItemsExecute(r ApiGetLatestLibraryItemsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetLatestLibraryItems")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}/latest"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -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_, "")
|
|
if r.filter != nil {
|
|
parameterAddToQuery(localVarQueryParams, "filter", r.filter, "")
|
|
}
|
|
// 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 ApiGetLibrariesRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
}
|
|
|
|
func (r ApiGetLibrariesRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetLibrariesExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetLibraries Get All Libraries
|
|
|
|
A library section (commonly referred to as just a library) is a collection of media.
|
|
Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media.
|
|
For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat.
|
|
|
|
Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts.
|
|
This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiGetLibrariesRequest
|
|
*/
|
|
func (a *LibraryApiService) GetLibraries(ctx context.Context) ApiGetLibrariesRequest {
|
|
return ApiGetLibrariesRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetLibrariesExecute(r ApiGetLibrariesRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetLibraries")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections"
|
|
|
|
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 ApiGetLibraryRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
includeDetails *interface{}
|
|
}
|
|
|
|
// Whether or not to include details for a section (types, filters, and sorts). Only exists for backwards compatibility, media providers other than the server libraries have it on always.
|
|
func (r ApiGetLibraryRequest) IncludeDetails(includeDetails interface{}) ApiGetLibraryRequest {
|
|
r.includeDetails = &includeDetails
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetLibraryRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetLibraryExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetLibrary Get Library Details
|
|
|
|
Returns details for the library. This can be thought of as an interstitial endpoint because it contains information about the library, rather than content itself. These details are:
|
|
|
|
- A list of `Directory` objects: These used to be used by clients to build a menuing system. There are four flavors of directory found here:
|
|
- Primary: (e.g. all, On Deck) These are still used in some clients to provide "shortcuts" to subsets of media. However, with the exception of On Deck, all of them can be created by media queries, and the desire is to allow these to be customized by users.
|
|
- Secondary: These are marked with `secondary="1"` and were used by old clients to provide nested menus allowing for primative (but structured) navigation.
|
|
- Special: There is a By Folder entry which allows browsing the media by the underlying filesystem structure, and there's a completely obsolete entry marked `search="1"` which used to be used to allow clients to build search dialogs on the fly.
|
|
- A list of `Type` objects: These represent the types of things found in this library, and for each one, a list of `Filter` and `Sort` objects. These can be used to build rich controls around a grid of media to allow filtering and organizing. Note that these filters and sorts are optional, and without them, the client won't render any filtering controls. The `Type` object contains:
|
|
- `key`: This provides the root endpoint returning the actual media list for the type.
|
|
- `type`: This is the metadata type for the type (if a standard Plex type).
|
|
- `title`: The title for for the content of this type (e.g. "Movies").
|
|
- Each `Filter` object contains a description of the filter. Note that it is not an exhaustive list of the full media query language, but an inportant subset useful for top-level API.
|
|
- `filter`: This represents the filter name used for the filter, which can be used to construct complex media queries with.
|
|
- `filterType`: This is either `string`, `integer`, or `boolean`, and describes the type of values used for the filter.
|
|
- `key`: This provides the endpoint where the possible range of values for the filter can be retrieved (e.g. for a "Genre" filter, it returns a list of all the genres in the library). This will include a `type` argument that matches the metadata type of the Type element.
|
|
- `title`: The title for the filter.
|
|
- Each `Sort` object contains a description of the sort field.
|
|
- `defaultDirection`: Can be either `asc` or `desc`, and specifies the default direction for the sort field (e.g. titles default to alphabetically ascending).
|
|
- `descKey` and `key`: Contains the parameters passed to the `sort=...` media query for each direction of the sort.
|
|
- `title`: The title of the field.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to query
|
|
@return ApiGetLibraryRequest
|
|
*/
|
|
func (a *LibraryApiService) GetLibrary(ctx context.Context, sectionId interface{}) ApiGetLibraryRequest {
|
|
return ApiGetLibraryRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetLibraryExecute(r ApiGetLibraryRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetLibrary")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.includeDetails != nil {
|
|
parameterAddToQuery(localVarQueryParams, "includeDetails", r.includeDetails, "")
|
|
}
|
|
// 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 ApiGetLibraryItemsRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
type_ *interface{}
|
|
filter *interface{}
|
|
}
|
|
|
|
// item type
|
|
func (r ApiGetLibraryItemsRequest) Type_(type_ interface{}) ApiGetLibraryItemsRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
// the filter parameter
|
|
func (r ApiGetLibraryItemsRequest) Filter(filter interface{}) ApiGetLibraryItemsRequest {
|
|
r.filter = &filter
|
|
return r
|
|
}
|
|
|
|
func (r ApiGetLibraryItemsRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetLibraryItemsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetLibraryItems Get Library Items
|
|
|
|
This endpoint will return a list of library items filtered by the filter and type provided
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to query
|
|
@return ApiGetLibraryItemsRequest
|
|
*/
|
|
func (a *LibraryApiService) GetLibraryItems(ctx context.Context, sectionId interface{}) ApiGetLibraryItemsRequest {
|
|
return ApiGetLibraryItemsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetLibraryItemsExecute(r ApiGetLibraryItemsRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetLibraryItems")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}/all"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.type_ != nil {
|
|
parameterAddToQuery(localVarQueryParams, "type", r.type_, "")
|
|
}
|
|
if r.filter != nil {
|
|
parameterAddToQuery(localVarQueryParams, "filter", r.filter, "")
|
|
}
|
|
// 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 ApiGetMetadataRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
ratingKey interface{}
|
|
}
|
|
|
|
func (r ApiGetMetadataRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetMetadataExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetMetadata Get Items Metadata
|
|
|
|
This endpoint will return the metadata of a library item specified with the ratingKey.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param ratingKey the id of the library item to return the children of.
|
|
@return ApiGetMetadataRequest
|
|
*/
|
|
func (a *LibraryApiService) GetMetadata(ctx context.Context, ratingKey interface{}) ApiGetMetadataRequest {
|
|
return ApiGetMetadataRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
ratingKey: ratingKey,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetMetadataExecute(r ApiGetMetadataRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetMetadata")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/metadata/{ratingKey}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"ratingKey"+"}", url.PathEscape(parameterValueToString(r.ratingKey, "ratingKey")), -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 ApiGetMetadataChildrenRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
ratingKey interface{}
|
|
}
|
|
|
|
func (r ApiGetMetadataChildrenRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.GetMetadataChildrenExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetMetadataChildren Get Items Children
|
|
|
|
This endpoint will return the children of of a library item specified with the ratingKey.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param ratingKey the id of the library item to return the children of.
|
|
@return ApiGetMetadataChildrenRequest
|
|
*/
|
|
func (a *LibraryApiService) GetMetadataChildren(ctx context.Context, ratingKey interface{}) ApiGetMetadataChildrenRequest {
|
|
return ApiGetMetadataChildrenRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
ratingKey: ratingKey,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) GetMetadataChildrenExecute(r ApiGetMetadataChildrenRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetMetadataChildren")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/metadata/{ratingKey}/children"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"ratingKey"+"}", url.PathEscape(parameterValueToString(r.ratingKey, "ratingKey")), -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 ApiGetOnDeckRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
}
|
|
|
|
func (r ApiGetOnDeckRequest) Execute() (*GetOnDeck200Response, *http.Response, error) {
|
|
return r.ApiService.GetOnDeckExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetOnDeck Get On Deck
|
|
|
|
This endpoint will return the on deck content.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiGetOnDeckRequest
|
|
*/
|
|
func (a *LibraryApiService) GetOnDeck(ctx context.Context) ApiGetOnDeckRequest {
|
|
return ApiGetOnDeckRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
// @return GetOnDeck200Response
|
|
func (a *LibraryApiService) GetOnDeckExecute(r ApiGetOnDeckRequest) (*GetOnDeck200Response, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *GetOnDeck200Response
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetOnDeck")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/onDeck"
|
|
|
|
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 localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, 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 localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetRecentlyAddedRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
}
|
|
|
|
func (r ApiGetRecentlyAddedRequest) Execute() (*GetRecentlyAdded200Response, *http.Response, error) {
|
|
return r.ApiService.GetRecentlyAddedExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetRecentlyAdded Get Recently Added
|
|
|
|
This endpoint will return the recently added content.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiGetRecentlyAddedRequest
|
|
*/
|
|
func (a *LibraryApiService) GetRecentlyAdded(ctx context.Context) ApiGetRecentlyAddedRequest {
|
|
return ApiGetRecentlyAddedRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
// @return GetRecentlyAdded200Response
|
|
func (a *LibraryApiService) GetRecentlyAddedExecute(r ApiGetRecentlyAddedRequest) (*GetRecentlyAdded200Response, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *GetRecentlyAdded200Response
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.GetRecentlyAdded")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/recentlyAdded"
|
|
|
|
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 localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, 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 localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiRefreshLibraryRequest struct {
|
|
ctx context.Context
|
|
ApiService *LibraryApiService
|
|
sectionId interface{}
|
|
}
|
|
|
|
func (r ApiRefreshLibraryRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.RefreshLibraryExecute(r)
|
|
}
|
|
|
|
/*
|
|
RefreshLibrary Refresh Library
|
|
|
|
This endpoint Refreshes the library.
|
|
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param sectionId the Id of the library to refresh
|
|
@return ApiRefreshLibraryRequest
|
|
*/
|
|
func (a *LibraryApiService) RefreshLibrary(ctx context.Context, sectionId interface{}) ApiRefreshLibraryRequest {
|
|
return ApiRefreshLibraryRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
sectionId: sectionId,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *LibraryApiService) RefreshLibraryExecute(r ApiRefreshLibraryRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryApiService.RefreshLibrary")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/library/sections/{sectionId}/refresh"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"sectionId"+"}", url.PathEscape(parameterValueToString(r.sectionId, "sectionId")), -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
|
|
}
|