Files
plexcsharp/LukeHagar/PlexAPI/SDK/PlayQueue.cs

1091 lines
55 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace LukeHagar.PlexAPI.SDK
{
using LukeHagar.PlexAPI.SDK.Hooks;
using LukeHagar.PlexAPI.SDK.Models.Components;
using LukeHagar.PlexAPI.SDK.Models.Errors;
using LukeHagar.PlexAPI.SDK.Models.Requests;
using LukeHagar.PlexAPI.SDK.Utils;
using LukeHagar.PlexAPI.SDK.Utils.Retries;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
/// <summary>
/// The playqueue feature within a media provider<br/>
///
/// <remarks>
/// A play queue represents the current list of media for playback. Although queues are persisted by the server, they should be regarded by the user as a fairly lightweight, an ephemeral list of items queued up for playback in a session. There is generally one active queue for each type of media (music, video, photos) that can be added to or destroyed and replaced with a fresh queue.<br/>
/// Play Queues has a region, which we refer to in this doc (partially for historical reasons) as &quot;Up Next&quot;. This region is defined by `playQueueLastAddedItemID` existing on the media container. This follows iTunes&apos; terminology. It is a special region after the currently playing item but before the originally-played items. This enables &quot;Party Mode&quot; listening/viewing, where items can be added on-the-fly, and normal queue playback resumed when completed. <br/>
/// You can visualize the play queue as a sliding window in the complete list of media queued for playback. This model is important when scaling to larger play queues (e.g. shuffling 40,000 audio tracks). The client only needs visibility into small areas of the queue at any given time, and the server can optimize access in this fashion.<br/>
/// All created play queues will have an empty &quot;Up Next&quot; area - unless the item is an album and no `key` is provided. In this case the &quot;Up Next&quot; area will be populated by the contents of the album. This is to allow queueing of multiple albums - since the &apos;Add to Up Next&apos; will insert after all the tracks. This means that If you&apos;re creating a PQ from an album, you can only shuffle it if you set `key`. This is due to the above implicit queueing of albums when no `key` is provided as well as the current limitation that you cannot shuffle a PQ with an &quot;Up Next&quot; area.<br/>
/// The play queue window advances as the server receives timeline requests. The client needs to retrieve the play queue as the “now playing” item changes. There is no play queue API to update the playing item.
/// </remarks>
/// </summary>
public interface IPlayQueue
{
/// <summary>
/// Create a play queue
///
/// <remarks>
/// Makes a new play queue for a device. The source of the playqueue can either be a URI, or a playlist. The response is a media container with the initial items in the queue. Each item in the queue will be a regular item but with `playQueueItemID` - a unique ID since the queue could have repeated items with the same `ratingKey`.<br/>
/// Note: Either `uri` or `playlistID` must be specified
/// </remarks>
/// </summary>
Task<CreatePlayQueueResponse> CreatePlayQueueAsync(CreatePlayQueueRequest request);
/// <summary>
/// Retrieve a play queue
///
/// <remarks>
/// Retrieves the play queue, centered at current item. This can be treated as a regular container by play queue-oblivious clients, but they may wish to request a large window onto the queue since they won&apos;t know to refresh.
/// </remarks>
/// </summary>
Task<GetPlayQueueResponse> GetPlayQueueAsync(GetPlayQueueRequest request);
/// <summary>
/// Add a generator or playlist to a play queue
///
/// <remarks>
/// Adds an item to a play queue (e.g. party mode). Increments the version of the play queue. Takes the following parameters (`uri` and `playlistID` are mutually exclusive). Returns the modified play queue.
/// </remarks>
/// </summary>
Task<AddToPlayQueueResponse> AddToPlayQueueAsync(AddToPlayQueueRequest request);
/// <summary>
/// Clear a play queue
///
/// <remarks>
/// Deletes all items in the play queue, and increases the version of the play queue.
/// </remarks>
/// </summary>
Task<ClearPlayQueueResponse> ClearPlayQueueAsync(ClearPlayQueueRequest request);
/// <summary>
/// Reset a play queue
///
/// <remarks>
/// Reset a play queue to the first item being the current item
/// </remarks>
/// </summary>
Task<ResetPlayQueueResponse> ResetPlayQueueAsync(ResetPlayQueueRequest request);
/// <summary>
/// Shuffle a play queue
///
/// <remarks>
/// Shuffle a play queue (or reshuffles if already shuffled). The currently selected item is maintained. Note that this is currently only supported for play queues *without* an Up Next area. Returns the modified play queue.
/// </remarks>
/// </summary>
Task<ShuffleResponse> ShuffleAsync(ShuffleRequest request);
/// <summary>
/// Unshuffle a play queue
///
/// <remarks>
/// Unshuffles a play queue and restores &quot;natural order&quot;. Note that this is currently only supported for play queues *without* an Up Next area. Returns the modified play queue.
/// </remarks>
/// </summary>
Task<UnshuffleResponse> UnshuffleAsync(UnshuffleRequest request);
/// <summary>
/// Delete an item from a play queue
///
/// <remarks>
/// Deletes an item in a play queue. Increments the version of the play queue. Returns the modified play queue.
/// </remarks>
/// </summary>
Task<DeletePlayQueueItemResponse> DeletePlayQueueItemAsync(DeletePlayQueueItemRequest request);
/// <summary>
/// Move an item in a play queue
///
/// <remarks>
/// Moves an item in a play queue, and increases the version of the play queue. Returns the modified play queue.
/// </remarks>
/// </summary>
Task<MovePlayQueueItemResponse> MovePlayQueueItemAsync(MovePlayQueueItemRequest request);
}
/// <summary>
/// The playqueue feature within a media provider<br/>
///
/// <remarks>
/// A play queue represents the current list of media for playback. Although queues are persisted by the server, they should be regarded by the user as a fairly lightweight, an ephemeral list of items queued up for playback in a session. There is generally one active queue for each type of media (music, video, photos) that can be added to or destroyed and replaced with a fresh queue.<br/>
/// Play Queues has a region, which we refer to in this doc (partially for historical reasons) as &quot;Up Next&quot;. This region is defined by `playQueueLastAddedItemID` existing on the media container. This follows iTunes&apos; terminology. It is a special region after the currently playing item but before the originally-played items. This enables &quot;Party Mode&quot; listening/viewing, where items can be added on-the-fly, and normal queue playback resumed when completed. <br/>
/// You can visualize the play queue as a sliding window in the complete list of media queued for playback. This model is important when scaling to larger play queues (e.g. shuffling 40,000 audio tracks). The client only needs visibility into small areas of the queue at any given time, and the server can optimize access in this fashion.<br/>
/// All created play queues will have an empty &quot;Up Next&quot; area - unless the item is an album and no `key` is provided. In this case the &quot;Up Next&quot; area will be populated by the contents of the album. This is to allow queueing of multiple albums - since the &apos;Add to Up Next&apos; will insert after all the tracks. This means that If you&apos;re creating a PQ from an album, you can only shuffle it if you set `key`. This is due to the above implicit queueing of albums when no `key` is provided as well as the current limitation that you cannot shuffle a PQ with an &quot;Up Next&quot; area.<br/>
/// The play queue window advances as the server receives timeline requests. The client needs to retrieve the play queue as the “now playing” item changes. There is no play queue API to update the playing item.
/// </remarks>
/// </summary>
public class PlayQueue: IPlayQueue
{
public SDKConfig SDKConfiguration { get; private set; }
private const string _language = "csharp";
private const string _sdkVersion = "0.19.0";
private const string _sdkGenVersion = "2.743.2";
private const string _openapiDocVersion = "1.1.1";
public PlayQueue(SDKConfig config)
{
SDKConfiguration = config;
}
public async Task<CreatePlayQueueResponse> CreatePlayQueueAsync(CreatePlayQueueRequest request)
{
if (request == null)
{
request = new CreatePlayQueueRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "createPlayQueue", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
CreatePlayQueueResponseBody obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<CreatePlayQueueResponseBody>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into CreatePlayQueueResponseBody.", httpResponse, httpResponseBody, ex);
}
var response = new CreatePlayQueueResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.Object = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<GetPlayQueueResponse> GetPlayQueueAsync(GetPlayQueueRequest request)
{
if (request == null)
{
request = new GetPlayQueueRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getPlayQueue", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new GetPlayQueueResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<AddToPlayQueueResponse> AddToPlayQueueAsync(AddToPlayQueueRequest request)
{
if (request == null)
{
request = new AddToPlayQueueRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "addToPlayQueue", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new AddToPlayQueueResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<ClearPlayQueueResponse> ClearPlayQueueAsync(ClearPlayQueueRequest request)
{
if (request == null)
{
request = new ClearPlayQueueRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/items", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "clearPlayQueue", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new ClearPlayQueueResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<ResetPlayQueueResponse> ResetPlayQueueAsync(ResetPlayQueueRequest request)
{
if (request == null)
{
request = new ResetPlayQueueRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/reset", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "resetPlayQueue", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new ResetPlayQueueResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<ShuffleResponse> ShuffleAsync(ShuffleRequest request)
{
if (request == null)
{
request = new ShuffleRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/shuffle", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "shuffle", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new ShuffleResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<UnshuffleResponse> UnshuffleAsync(UnshuffleRequest request)
{
if (request == null)
{
request = new UnshuffleRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/unshuffle", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "unshuffle", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new UnshuffleResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<DeletePlayQueueItemResponse> DeletePlayQueueItemAsync(DeletePlayQueueItemRequest request)
{
if (request == null)
{
request = new DeletePlayQueueItemRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/items/{playQueueItemId}", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "deletePlayQueueItem", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new DeletePlayQueueItemResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
public async Task<MovePlayQueueItemResponse> MovePlayQueueItemAsync(MovePlayQueueItemRequest request)
{
if (request == null)
{
request = new MovePlayQueueItemRequest();
}
request.Accepts ??= SDKConfiguration.Accepts;
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
request.Product ??= SDKConfiguration.Product;
request.Version ??= SDKConfiguration.Version;
request.Platform ??= SDKConfiguration.Platform;
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
request.Device ??= SDKConfiguration.Device;
request.Model ??= SDKConfiguration.Model;
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
request.DeviceName ??= SDKConfiguration.DeviceName;
request.Marketplace ??= SDKConfiguration.Marketplace;
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
var urlString = URLBuilder.Build(baseUrl, "/playQueues/{playQueueId}/items/{playQueueItemId}/move", request);
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
if (SDKConfiguration.SecuritySource != null)
{
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
}
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "movePlayQueueItem", null, SDKConfiguration.SecuritySource);
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
HttpResponseMessage httpResponse;
try
{
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
int _statusCode = (int)httpResponse.StatusCode;
if (_statusCode == 400 || _statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
}
}
catch (Exception error)
{
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
if (_httpResponse != null)
{
httpResponse = _httpResponse;
}
else
{
throw;
}
}
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
int responseStatusCode = (int)httpResponse.StatusCode;
if(responseStatusCode == 200)
{
if(Utilities.IsContentTypeMatch("application/json", contentType))
{
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
MediaContainerWithPlaylistMetadata obj;
try
{
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithPlaylistMetadata>(httpResponseBody, NullValueHandling.Ignore);
}
catch (Exception ex)
{
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithPlaylistMetadata.", httpResponse, httpResponseBody, ex);
}
var response = new MovePlayQueueItemResponse()
{
StatusCode = responseStatusCode,
ContentType = contentType,
RawResponse = httpResponse
};
response.MediaContainerWithPlaylistMetadata = obj;
return response;
}
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode == 400 || responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
else if(responseStatusCode >= 500 && responseStatusCode < 600)
{
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
}
}
}