mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-07 20:47:44 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.205.0
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -70,71 +71,76 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Activities(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Activities(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetServerActivitiesResponse> GetServerActivitiesAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/activities";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetServerActivitiesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetServerActivitiesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetServerActivitiesActivitiesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<CancelServerActivitiesResponse> CancelServerActivitiesAsync(string activityUUID)
|
||||
{
|
||||
@@ -144,40 +150,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/activities/{activityUUID}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new CancelServerActivitiesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<CancelServerActivitiesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -19,13 +20,13 @@ namespace PlexAPI
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// API Calls against Security for Plex Media Server<br/>
|
||||
/// API Calls regarding authentication for Plex Media Server<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public interface ISecurity
|
||||
public interface IAuthentication
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +37,7 @@ namespace PlexAPI
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetTransientTokenResponse> GetTransientTokenAsync(QueryParamType type, Scope scope);
|
||||
Task<GetTransientTokenResponse> GetTransientTokenAsync(GetTransientTokenQueryParamType type, Scope scope);
|
||||
|
||||
/// <summary>
|
||||
/// Get Source Connection Information
|
||||
@@ -51,34 +52,33 @@ namespace PlexAPI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Calls against Security for Plex Media Server<br/>
|
||||
/// API Calls regarding authentication for Plex Media Server<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class Security: ISecurity
|
||||
public class Authentication: IAuthentication
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Security(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Authentication(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetTransientTokenResponse> GetTransientTokenAsync(QueryParamType type, Scope scope)
|
||||
public async Task<GetTransientTokenResponse> GetTransientTokenAsync(GetTransientTokenQueryParamType type, Scope scope)
|
||||
{
|
||||
var request = new GetTransientTokenRequest()
|
||||
{
|
||||
@@ -87,41 +87,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/security/token", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetTransientTokenResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetTransientTokenResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetSourceConnectionInformationResponse> GetSourceConnectionInformationAsync(string source)
|
||||
{
|
||||
@@ -131,40 +135,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/security/resources", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetSourceConnectionInformationResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetSourceConnectionInformationResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -97,151 +98,166 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Butler(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Butler(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetButlerTasksResponse> GetButlerTasksAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/butler";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetButlerTasksResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetButlerTasksResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetButlerTasksButlerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StartAllTasksResponse> StartAllTasksAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/butler";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new StartAllTasksResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StartAllTasksResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StopAllTasksResponse> StopAllTasksAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/butler";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new StopAllTasksResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StopAllTasksResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StartTaskResponse> StartTaskAsync(TaskName taskName)
|
||||
{
|
||||
@@ -251,41 +267,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/butler/{taskName}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new StartTaskResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 202) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StartTaskResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StopTaskResponse> StopTaskAsync(PathParamTaskName taskName)
|
||||
{
|
||||
@@ -295,40 +315,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/butler/{taskName}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new StopTaskResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400) || (response.StatusCode == 404))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StopTaskResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -59,22 +60,21 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Hubs(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Hubs(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetGlobalHubsResponse> GetGlobalHubsAsync(double? count = null, OnlyTransient? onlyTransient = null)
|
||||
{
|
||||
@@ -85,50 +85,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/hubs", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetGlobalHubsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetGlobalHubsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetGlobalHubsHubsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetLibraryHubsResponse> GetLibraryHubsAsync(double sectionId, double? count = null, QueryParamOnlyTransient? onlyTransient = null)
|
||||
{
|
||||
@@ -140,49 +145,54 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/hubs/sections/{sectionId}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetLibraryHubsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetLibraryHubsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetLibraryHubsHubsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -143,7 +144,6 @@ namespace PlexAPI
|
||||
/// - `resolution`: Items categorized by resolution.<br/>
|
||||
/// - `firstCharacter`: Items categorized by the first letter.<br/>
|
||||
/// - `folder`: Items categorized by folder.<br/>
|
||||
/// - `search?type=1`: Search functionality within the section.<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
@@ -159,6 +159,33 @@ namespace PlexAPI
|
||||
/// </summary>
|
||||
Task<RefreshLibraryResponse> RefreshLibraryAsync(double sectionId);
|
||||
|
||||
/// <summary>
|
||||
/// Search Library
|
||||
///
|
||||
/// <remarks>
|
||||
/// Search for content within a specific section of the library.<br/>
|
||||
/// <br/>
|
||||
/// ### Types<br/>
|
||||
/// Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:<br/>
|
||||
/// <br/>
|
||||
/// - **Type Object Attributes**:<br/>
|
||||
/// - `type`: Metadata type (if standard Plex type). <br/>
|
||||
/// - `title`: Title for this content type (e.g., "Movies").<br/>
|
||||
/// <br/>
|
||||
/// - **Filter Objects**:<br/>
|
||||
/// - Subset of the media query language.<br/>
|
||||
/// - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.<br/>
|
||||
/// <br/>
|
||||
/// - **Sort Objects**:<br/>
|
||||
/// - Description of sort fields.<br/>
|
||||
/// - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.<br/>
|
||||
/// <br/>
|
||||
/// > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<SearchLibraryResponse> SearchLibraryAsync(long sectionId, Type type);
|
||||
|
||||
/// <summary>
|
||||
/// Get Items Metadata
|
||||
///
|
||||
@@ -201,22 +228,21 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Library(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Library(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetFileHashResponse> GetFileHashAsync(string url, double? type = null)
|
||||
{
|
||||
@@ -227,139 +253,155 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/hashes", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetFileHashResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetFileHashResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetRecentlyAddedResponse> GetRecentlyAddedAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/library/recentlyAdded";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetRecentlyAddedResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetRecentlyAddedResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetRecentlyAddedLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetLibrariesResponse> GetLibrariesAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/library/sections";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetLibrariesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetLibrariesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetLibrariesLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetLibraryResponse> GetLibraryAsync(double sectionId, IncludeDetails? includeDetails = null)
|
||||
{
|
||||
@@ -370,50 +412,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetLibraryResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetLibraryLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<DeleteLibraryResponse> DeleteLibraryAsync(double sectionId)
|
||||
{
|
||||
@@ -423,41 +470,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new DeleteLibraryResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<DeleteLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetLibraryItemsResponse> GetLibraryItemsAsync(long sectionId, Tag tag)
|
||||
{
|
||||
@@ -468,36 +519,39 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/{tag}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetLibraryItemsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetLibraryItemsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<RefreshLibraryResponse> RefreshLibraryAsync(double sectionId)
|
||||
{
|
||||
@@ -507,41 +561,88 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/refresh", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new RefreshLibraryResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<RefreshLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<SearchLibraryResponse> SearchLibraryAsync(long sectionId, Type type)
|
||||
{
|
||||
var request = new SearchLibraryRequest()
|
||||
{
|
||||
SectionId = sectionId,
|
||||
Type = type,
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/search", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new SearchLibraryResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<SearchLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetMetadataResponse> GetMetadataAsync(double ratingKey)
|
||||
{
|
||||
@@ -551,50 +652,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/metadata/{ratingKey}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetMetadataResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetMetadataResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetMetadataLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetMetadataChildrenResponse> GetMetadataChildrenAsync(double ratingKey)
|
||||
{
|
||||
@@ -604,98 +710,109 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/library/metadata/{ratingKey}/children", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetMetadataChildrenResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetMetadataChildrenResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetMetadataChildrenLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetOnDeckResponse> GetOnDeckAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/library/onDeck";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetOnDeckResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetOnDeckResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetOnDeckLibraryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -90,22 +91,21 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Log(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Log(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<LogLineResponse> LogLineAsync(Level level, string message, string source)
|
||||
{
|
||||
@@ -117,129 +117,140 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/log", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new LogLineResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<LogLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<LogMultiLineResponse> LogMultiLineAsync(string request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/log";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
var serializedBody = RequestBodySerializer.Serialize(request, "Request", "string");
|
||||
if (serializedBody == null)
|
||||
{
|
||||
throw new ArgumentNullException("request body is required");
|
||||
}
|
||||
else
|
||||
|
||||
var serializedBody = RequestBodySerializer.Serialize(request, "Request", "string", false, false);
|
||||
if (serializedBody != null)
|
||||
{
|
||||
httpRequest.Content = serializedBody;
|
||||
}
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new LogMultiLineResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<LogMultiLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<EnablePaperTrailResponse> EnablePaperTrailAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/log/networked";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new EnablePaperTrailResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400) || (response.StatusCode == 403))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<EnablePaperTrailResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -68,22 +69,21 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Media(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Media(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<MarkPlayedResponse> MarkPlayedAsync(double key)
|
||||
{
|
||||
@@ -93,41 +93,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/:/scrobble", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new MarkPlayedResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<MarkPlayedResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<MarkUnplayedResponse> MarkUnplayedAsync(double key)
|
||||
{
|
||||
@@ -137,41 +141,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/:/unscrobble", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new MarkUnplayedResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<MarkUnplayedResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<UpdatePlayProgressResponse> UpdatePlayProgressAsync(string key, double time, string state)
|
||||
{
|
||||
@@ -183,40 +191,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/:/progress", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new UpdatePlayProgressResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<UpdatePlayProgressResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
42
PlexAPI/Models/Requests/Account.cs
Normal file
42
PlexAPI/Models/Requests/Account.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class Account
|
||||
{
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int? Id { get; set; }
|
||||
|
||||
[JsonProperty("key")]
|
||||
public string? Key { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonProperty("defaultAudioLanguage")]
|
||||
public string? DefaultAudioLanguage { get; set; }
|
||||
|
||||
[JsonProperty("autoSelectAudio")]
|
||||
public bool? AutoSelectAudio { get; set; }
|
||||
|
||||
[JsonProperty("defaultSubtitleLanguage")]
|
||||
public string? DefaultSubtitleLanguage { get; set; }
|
||||
|
||||
[JsonProperty("subtitleMode")]
|
||||
public int? SubtitleMode { get; set; }
|
||||
|
||||
[JsonProperty("thumb")]
|
||||
public string? Thumb { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace PlexAPI.Models.Requests
|
||||
/// type of playlist to create
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("queryParam:style=form,explode=true,name=type")]
|
||||
public Type Type { get; set; } = default!;
|
||||
public QueryParamType Type { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// whether the playlist is smart or not
|
||||
|
||||
@@ -77,6 +77,6 @@ namespace PlexAPI.Models.Requests
|
||||
public int? Hidden { get; set; }
|
||||
|
||||
[JsonProperty("Location")]
|
||||
public List<Location>? Location { get; set; }
|
||||
public List<GetLibrariesLocation>? Location { get; set; }
|
||||
}
|
||||
}
|
||||
24
PlexAPI/Models/Requests/GetLibrariesLocation.cs
Normal file
24
PlexAPI/Models/Requests/GetLibrariesLocation.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GetLibrariesLocation
|
||||
{
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int? Id { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string? Path { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,9 @@ namespace PlexAPI.Models.Requests
|
||||
[JsonProperty("viewMode")]
|
||||
public int? ViewMode { get; set; }
|
||||
|
||||
[JsonProperty("mixedParents")]
|
||||
public bool? MixedParents { get; set; }
|
||||
|
||||
[JsonProperty("Metadata")]
|
||||
public List<GetLibraryItemsMetadata>? Metadata { get; set; }
|
||||
}
|
||||
|
||||
@@ -83,6 +83,27 @@ namespace PlexAPI.Models.Requests
|
||||
[JsonProperty("ratingImage")]
|
||||
public string? RatingImage { get; set; }
|
||||
|
||||
[JsonProperty("grandparentRatingKey")]
|
||||
public string? GrandparentRatingKey { get; set; }
|
||||
|
||||
[JsonProperty("grandparentGuid")]
|
||||
public string? GrandparentGuid { get; set; }
|
||||
|
||||
[JsonProperty("grandparentKey")]
|
||||
public string? GrandparentKey { get; set; }
|
||||
|
||||
[JsonProperty("grandparentTitle")]
|
||||
public string? GrandparentTitle { get; set; }
|
||||
|
||||
[JsonProperty("grandparentThumb")]
|
||||
public string? GrandparentThumb { get; set; }
|
||||
|
||||
[JsonProperty("grandparentArt")]
|
||||
public string? GrandparentArt { get; set; }
|
||||
|
||||
[JsonProperty("grandparentTheme")]
|
||||
public string? GrandparentTheme { get; set; }
|
||||
|
||||
[JsonProperty("Media")]
|
||||
public List<GetLibraryItemsMedia>? Media { get; set; }
|
||||
|
||||
@@ -118,5 +139,53 @@ namespace PlexAPI.Models.Requests
|
||||
|
||||
[JsonProperty("skipCount")]
|
||||
public int? SkipCount { get; set; }
|
||||
|
||||
[JsonProperty("index")]
|
||||
public int? Index { get; set; }
|
||||
|
||||
[JsonProperty("theme")]
|
||||
public string? Theme { get; set; }
|
||||
|
||||
[JsonProperty("leafCount")]
|
||||
public int? LeafCount { get; set; }
|
||||
|
||||
[JsonProperty("viewedLeafCount")]
|
||||
public int? ViewedLeafCount { get; set; }
|
||||
|
||||
[JsonProperty("childCount")]
|
||||
public int? ChildCount { get; set; }
|
||||
|
||||
[JsonProperty("hasPremiumExtras")]
|
||||
public string? HasPremiumExtras { get; set; }
|
||||
|
||||
[JsonProperty("hasPremiumPrimaryExtra")]
|
||||
public string? HasPremiumPrimaryExtra { get; set; }
|
||||
|
||||
[JsonProperty("parentRatingKey")]
|
||||
public string? ParentRatingKey { get; set; }
|
||||
|
||||
[JsonProperty("parentGuid")]
|
||||
public string? ParentGuid { get; set; }
|
||||
|
||||
[JsonProperty("parentStudio")]
|
||||
public string? ParentStudio { get; set; }
|
||||
|
||||
[JsonProperty("parentKey")]
|
||||
public string? ParentKey { get; set; }
|
||||
|
||||
[JsonProperty("parentTitle")]
|
||||
public string? ParentTitle { get; set; }
|
||||
|
||||
[JsonProperty("parentIndex")]
|
||||
public int? ParentIndex { get; set; }
|
||||
|
||||
[JsonProperty("parentYear")]
|
||||
public int? ParentYear { get; set; }
|
||||
|
||||
[JsonProperty("parentThumb")]
|
||||
public string? ParentThumb { get; set; }
|
||||
|
||||
[JsonProperty("parentTheme")]
|
||||
public string? ParentTheme { get; set; }
|
||||
}
|
||||
}
|
||||
27
PlexAPI/Models/Requests/GetPinErrors.cs
Normal file
27
PlexAPI/Models/Requests/GetPinErrors.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GetPinErrors
|
||||
{
|
||||
|
||||
[JsonProperty("code")]
|
||||
public double? Code { get; set; }
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public double? Status { get; set; }
|
||||
}
|
||||
}
|
||||
25
PlexAPI/Models/Requests/GetPinPlexResponseBody.cs
Normal file
25
PlexAPI/Models/Requests/GetPinPlexResponseBody.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// X-Plex-Client-Identifier is missing
|
||||
/// </summary>
|
||||
public class GetPinPlexResponseBody
|
||||
{
|
||||
|
||||
[JsonProperty("errors")]
|
||||
public List<GetPinErrors>? Errors { get; set; }
|
||||
}
|
||||
}
|
||||
42
PlexAPI/Models/Requests/GetPinRequest.cs
Normal file
42
PlexAPI/Models/Requests/GetPinRequest.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using PlexAPI.Utils;
|
||||
|
||||
public class GetPinRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier for the client application<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This is used to track the client application and its usage<br/>
|
||||
/// (UUID, serial number, or other number unique per device)<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("header:style=simple,explode=false,name=X-Plex-Client-Identifier")]
|
||||
public string XPlexClientIdentifier { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Determines the kind of code returned by the API call<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Strong codes are used for Pin authentication flows<br/>
|
||||
/// Non-Strong codes are used for `Plex.tv/link`<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("queryParam:style=form,explode=true,name=strong")]
|
||||
public bool? Strong { get; set; }
|
||||
}
|
||||
}
|
||||
44
PlexAPI/Models/Requests/GetPinResponse.cs
Normal file
44
PlexAPI/Models/Requests/GetPinResponse.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using System.Net.Http;
|
||||
using System;
|
||||
|
||||
public class GetPinResponse
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response content type for this operation
|
||||
/// </summary>
|
||||
public string? ContentType { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response status code for this operation
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Raw HTTP response; suitable for custom response parsing
|
||||
/// </summary>
|
||||
public HttpResponseMessage RawResponse { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The Pin
|
||||
/// </summary>
|
||||
public GetPinResponseBody? TwoHundredApplicationJsonObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// X-Plex-Client-Identifier is missing
|
||||
/// </summary>
|
||||
public GetPinPlexResponseBody? FourHundredApplicationJsonObject { get; set; }
|
||||
}
|
||||
}
|
||||
70
PlexAPI/Models/Requests/GetPinResponseBody.cs
Normal file
70
PlexAPI/Models/Requests/GetPinResponseBody.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// The Pin
|
||||
/// </summary>
|
||||
public class GetPinResponseBody
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// PinID for use with authentication
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
public double? Id { get; set; }
|
||||
|
||||
[JsonProperty("code")]
|
||||
public string? Code { get; set; }
|
||||
|
||||
[JsonProperty("product")]
|
||||
public string? Product { get; set; }
|
||||
|
||||
[JsonProperty("trusted")]
|
||||
public bool? Trusted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// a link to a QR code hosted on plex.tv <br/>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The QR code redirects to the relevant `plex.tv/link` authentication page<br/>
|
||||
/// Which then prompts the user for the 4 Digit Link Pin<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
[JsonProperty("qr")]
|
||||
public string? Qr { get; set; }
|
||||
|
||||
[JsonProperty("clientIdentifier")]
|
||||
public string? ClientIdentifier { get; set; }
|
||||
|
||||
[JsonProperty("location")]
|
||||
public Location? Location { get; set; }
|
||||
|
||||
[JsonProperty("expiresIn")]
|
||||
public double? ExpiresIn { get; set; }
|
||||
|
||||
[JsonProperty("createdAt")]
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("expiresAt")]
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
|
||||
[JsonProperty("authToken")]
|
||||
public string? AuthToken { get; set; }
|
||||
|
||||
[JsonProperty("newRegistration")]
|
||||
public string? NewRegistration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,6 @@ namespace PlexAPI.Models.Requests
|
||||
public int? Size { get; set; }
|
||||
|
||||
[JsonProperty("Setting")]
|
||||
public List<object>? Setting { get; set; }
|
||||
public List<Setting>? Setting { get; set; }
|
||||
}
|
||||
}
|
||||
33
PlexAPI/Models/Requests/GetStatisticsDevice.cs
Normal file
33
PlexAPI/Models/Requests/GetStatisticsDevice.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GetStatisticsDevice
|
||||
{
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int? Id { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonProperty("platform")]
|
||||
public string? Platform { get; set; }
|
||||
|
||||
[JsonProperty("clientIdentifier")]
|
||||
public string? ClientIdentifier { get; set; }
|
||||
|
||||
[JsonProperty("createdAt")]
|
||||
public int? CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
27
PlexAPI/Models/Requests/GetStatisticsErrors.cs
Normal file
27
PlexAPI/Models/Requests/GetStatisticsErrors.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GetStatisticsErrors
|
||||
{
|
||||
|
||||
[JsonProperty("code")]
|
||||
public double? Code { get; set; }
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public double? Status { get; set; }
|
||||
}
|
||||
}
|
||||
31
PlexAPI/Models/Requests/GetStatisticsMediaContainer.cs
Normal file
31
PlexAPI/Models/Requests/GetStatisticsMediaContainer.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GetStatisticsMediaContainer
|
||||
{
|
||||
|
||||
[JsonProperty("size")]
|
||||
public int? Size { get; set; }
|
||||
|
||||
[JsonProperty("Device")]
|
||||
public List<GetStatisticsDevice>? Device { get; set; }
|
||||
|
||||
[JsonProperty("Account")]
|
||||
public List<Account>? Account { get; set; }
|
||||
|
||||
[JsonProperty("StatisticsMedia")]
|
||||
public List<StatisticsMedia>? StatisticsMedia { get; set; }
|
||||
}
|
||||
}
|
||||
29
PlexAPI/Models/Requests/GetStatisticsRequest.cs
Normal file
29
PlexAPI/Models/Requests/GetStatisticsRequest.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using PlexAPI.Utils;
|
||||
|
||||
public class GetStatisticsRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The timespan to retrieve statistics for<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
/// the exact meaning of this parameter is not known<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("queryParam:style=form,explode=true,name=Timespan")]
|
||||
public long? Timespan { get; set; }
|
||||
}
|
||||
}
|
||||
44
PlexAPI/Models/Requests/GetStatisticsResponse.cs
Normal file
44
PlexAPI/Models/Requests/GetStatisticsResponse.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using System.Net.Http;
|
||||
using System;
|
||||
|
||||
public class GetStatisticsResponse
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response content type for this operation
|
||||
/// </summary>
|
||||
public string? ContentType { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response status code for this operation
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Raw HTTP response; suitable for custom response parsing
|
||||
/// </summary>
|
||||
public HttpResponseMessage RawResponse { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Media Statistics
|
||||
/// </summary>
|
||||
public GetStatisticsResponseBody? TwoHundredApplicationJsonObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
|
||||
/// </summary>
|
||||
public GetStatisticsStatisticsResponseBody? FourHundredAndOneApplicationJsonObject { get; set; }
|
||||
}
|
||||
}
|
||||
24
PlexAPI/Models/Requests/GetStatisticsResponseBody.cs
Normal file
24
PlexAPI/Models/Requests/GetStatisticsResponseBody.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
/// <summary>
|
||||
/// Media Statistics
|
||||
/// </summary>
|
||||
public class GetStatisticsResponseBody
|
||||
{
|
||||
|
||||
[JsonProperty("MediaContainer")]
|
||||
public GetStatisticsMediaContainer? MediaContainer { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
|
||||
/// </summary>
|
||||
public class GetStatisticsStatisticsResponseBody
|
||||
{
|
||||
|
||||
[JsonProperty("errors")]
|
||||
public List<GetStatisticsErrors>? Errors { get; set; }
|
||||
}
|
||||
}
|
||||
27
PlexAPI/Models/Requests/GetTokenErrors.cs
Normal file
27
PlexAPI/Models/Requests/GetTokenErrors.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GetTokenErrors
|
||||
{
|
||||
|
||||
[JsonProperty("code")]
|
||||
public double? Code { get; set; }
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public double? Status { get; set; }
|
||||
}
|
||||
}
|
||||
36
PlexAPI/Models/Requests/GetTokenRequest.cs
Normal file
36
PlexAPI/Models/Requests/GetTokenRequest.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using PlexAPI.Utils;
|
||||
|
||||
public class GetTokenRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The PinID to retrieve an access token for
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("pathParam:style=simple,explode=false,name=pinID")]
|
||||
public string PinID { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier for the client application<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This is used to track the client application and its usage<br/>
|
||||
/// (UUID, serial number, or other number unique per device)<br/>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("header:style=simple,explode=false,name=X-Plex-Client-Identifier")]
|
||||
public string XPlexClientIdentifier { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
39
PlexAPI/Models/Requests/GetTokenResponse.cs
Normal file
39
PlexAPI/Models/Requests/GetTokenResponse.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using System.Net.Http;
|
||||
using System;
|
||||
|
||||
public class GetTokenResponse
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response content type for this operation
|
||||
/// </summary>
|
||||
public string? ContentType { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response status code for this operation
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Raw HTTP response; suitable for custom response parsing
|
||||
/// </summary>
|
||||
public HttpResponseMessage RawResponse { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// X-Plex-Client-Identifier is missing
|
||||
/// </summary>
|
||||
public GetTokenResponseBody? Object { get; set; }
|
||||
}
|
||||
}
|
||||
25
PlexAPI/Models/Requests/GetTokenResponseBody.cs
Normal file
25
PlexAPI/Models/Requests/GetTokenResponseBody.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// X-Plex-Client-Identifier is missing
|
||||
/// </summary>
|
||||
public class GetTokenResponseBody
|
||||
{
|
||||
|
||||
[JsonProperty("errors")]
|
||||
public List<GetTokenErrors>? Errors { get; set; }
|
||||
}
|
||||
}
|
||||
58
PlexAPI/Models/Requests/GetTransientTokenQueryParamType.cs
Normal file
58
PlexAPI/Models/Requests/GetTransientTokenQueryParamType.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// `delegation` - This is the only supported `type` parameter.
|
||||
/// </summary>
|
||||
public enum GetTransientTokenQueryParamType
|
||||
{
|
||||
[JsonProperty("delegation")]
|
||||
Delegation,
|
||||
}
|
||||
|
||||
public static class GetTransientTokenQueryParamTypeExtension
|
||||
{
|
||||
public static string Value(this GetTransientTokenQueryParamType value)
|
||||
{
|
||||
return ((JsonPropertyAttribute)value.GetType().GetMember(value.ToString())[0].GetCustomAttributes(typeof(JsonPropertyAttribute), false)[0]).PropertyName ?? value.ToString();
|
||||
}
|
||||
|
||||
public static GetTransientTokenQueryParamType ToEnum(this string value)
|
||||
{
|
||||
foreach(var field in typeof(GetTransientTokenQueryParamType).GetFields())
|
||||
{
|
||||
var attributes = field.GetCustomAttributes(typeof(JsonPropertyAttribute), false);
|
||||
if (attributes.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var attribute = attributes[0] as JsonPropertyAttribute;
|
||||
if (attribute != null && attribute.PropertyName == value)
|
||||
{
|
||||
var enumVal = field.GetValue(null);
|
||||
|
||||
if (enumVal is GetTransientTokenQueryParamType)
|
||||
{
|
||||
return (GetTransientTokenQueryParamType)enumVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"Unknown value {value} for enum GetTransientTokenQueryParamType");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace PlexAPI.Models.Requests
|
||||
/// `delegation` - This is the only supported `type` parameter.
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("queryParam:style=form,explode=true,name=type")]
|
||||
public QueryParamType Type { get; set; } = default!;
|
||||
public GetTransientTokenQueryParamType Type { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// `all` - This is the only supported `scope` parameter.
|
||||
|
||||
@@ -15,10 +15,34 @@ namespace PlexAPI.Models.Requests
|
||||
public class Location
|
||||
{
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int? Id { get; set; }
|
||||
[JsonProperty("code")]
|
||||
public string? Code { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string? Path { get; set; }
|
||||
[JsonProperty("european_union_member")]
|
||||
public bool? EuropeanUnionMember { get; set; }
|
||||
|
||||
[JsonProperty("continent_code")]
|
||||
public string? ContinentCode { get; set; }
|
||||
|
||||
[JsonProperty("country")]
|
||||
public string? Country { get; set; }
|
||||
|
||||
[JsonProperty("city")]
|
||||
public string? City { get; set; }
|
||||
|
||||
[JsonProperty("time_zone")]
|
||||
public string? TimeZone { get; set; }
|
||||
|
||||
[JsonProperty("postal_code")]
|
||||
public double? PostalCode { get; set; }
|
||||
|
||||
[JsonProperty("in_privacy_restricted_country")]
|
||||
public bool? InPrivacyRestrictedCountry { get; set; }
|
||||
|
||||
[JsonProperty("subdivisions")]
|
||||
public string? Subdivisions { get; set; }
|
||||
|
||||
[JsonProperty("coordinates")]
|
||||
public string? Coordinates { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,16 @@ namespace PlexAPI.Models.Requests
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// `delegation` - This is the only supported `type` parameter.
|
||||
/// type of playlist to create
|
||||
/// </summary>
|
||||
public enum QueryParamType
|
||||
{
|
||||
[JsonProperty("delegation")]
|
||||
Delegation,
|
||||
[JsonProperty("audio")]
|
||||
Audio,
|
||||
[JsonProperty("video")]
|
||||
Video,
|
||||
[JsonProperty("photo")]
|
||||
Photo,
|
||||
}
|
||||
|
||||
public static class QueryParamTypeExtension
|
||||
|
||||
58
PlexAPI/Models/Requests/SearchLibraryMediaContainer.cs
Normal file
58
PlexAPI/Models/Requests/SearchLibraryMediaContainer.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class SearchLibraryMediaContainer
|
||||
{
|
||||
|
||||
[JsonProperty("size")]
|
||||
public int? Size { get; set; }
|
||||
|
||||
[JsonProperty("allowSync")]
|
||||
public bool? AllowSync { get; set; }
|
||||
|
||||
[JsonProperty("art")]
|
||||
public string? Art { get; set; }
|
||||
|
||||
[JsonProperty("identifier")]
|
||||
public string? Identifier { get; set; }
|
||||
|
||||
[JsonProperty("mediaTagPrefix")]
|
||||
public string? MediaTagPrefix { get; set; }
|
||||
|
||||
[JsonProperty("mediaTagVersion")]
|
||||
public int? MediaTagVersion { get; set; }
|
||||
|
||||
[JsonProperty("nocache")]
|
||||
public bool? Nocache { get; set; }
|
||||
|
||||
[JsonProperty("thumb")]
|
||||
public string? Thumb { get; set; }
|
||||
|
||||
[JsonProperty("title1")]
|
||||
public string? Title1 { get; set; }
|
||||
|
||||
[JsonProperty("title2")]
|
||||
public string? Title2 { get; set; }
|
||||
|
||||
[JsonProperty("viewGroup")]
|
||||
public string? ViewGroup { get; set; }
|
||||
|
||||
[JsonProperty("viewMode")]
|
||||
public int? ViewMode { get; set; }
|
||||
|
||||
[JsonProperty("Metadata")]
|
||||
public List<SearchLibraryMetadata>? Metadata { get; set; }
|
||||
}
|
||||
}
|
||||
78
PlexAPI/Models/Requests/SearchLibraryMetadata.cs
Normal file
78
PlexAPI/Models/Requests/SearchLibraryMetadata.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class SearchLibraryMetadata
|
||||
{
|
||||
|
||||
[JsonProperty("ratingKey")]
|
||||
public string? RatingKey { get; set; }
|
||||
|
||||
[JsonProperty("key")]
|
||||
public string? Key { get; set; }
|
||||
|
||||
[JsonProperty("parentRatingKey")]
|
||||
public string? ParentRatingKey { get; set; }
|
||||
|
||||
[JsonProperty("guid")]
|
||||
public string? Guid { get; set; }
|
||||
|
||||
[JsonProperty("parentGuid")]
|
||||
public string? ParentGuid { get; set; }
|
||||
|
||||
[JsonProperty("parentStudio")]
|
||||
public string? ParentStudio { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string? Type { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonProperty("parentKey")]
|
||||
public string? ParentKey { get; set; }
|
||||
|
||||
[JsonProperty("parentTitle")]
|
||||
public string? ParentTitle { get; set; }
|
||||
|
||||
[JsonProperty("summary")]
|
||||
public string? Summary { get; set; }
|
||||
|
||||
[JsonProperty("index")]
|
||||
public int? Index { get; set; }
|
||||
|
||||
[JsonProperty("parentIndex")]
|
||||
public int? ParentIndex { get; set; }
|
||||
|
||||
[JsonProperty("parentYear")]
|
||||
public int? ParentYear { get; set; }
|
||||
|
||||
[JsonProperty("thumb")]
|
||||
public string? Thumb { get; set; }
|
||||
|
||||
[JsonProperty("art")]
|
||||
public string? Art { get; set; }
|
||||
|
||||
[JsonProperty("parentThumb")]
|
||||
public string? ParentThumb { get; set; }
|
||||
|
||||
[JsonProperty("parentTheme")]
|
||||
public string? ParentTheme { get; set; }
|
||||
|
||||
[JsonProperty("addedAt")]
|
||||
public int? AddedAt { get; set; }
|
||||
|
||||
[JsonProperty("updatedAt")]
|
||||
public int? UpdatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
30
PlexAPI/Models/Requests/SearchLibraryRequest.cs
Normal file
30
PlexAPI/Models/Requests/SearchLibraryRequest.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using PlexAPI.Utils;
|
||||
|
||||
public class SearchLibraryRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// the Id of the library to query
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("pathParam:style=simple,explode=false,name=sectionId")]
|
||||
public long SectionId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Plex content type to search for
|
||||
/// </summary>
|
||||
[SpeakeasyMetadata("queryParam:style=form,explode=true,name=type")]
|
||||
public Type Type { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
39
PlexAPI/Models/Requests/SearchLibraryResponse.cs
Normal file
39
PlexAPI/Models/Requests/SearchLibraryResponse.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using System.Net.Http;
|
||||
using System;
|
||||
|
||||
public class SearchLibraryResponse
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response content type for this operation
|
||||
/// </summary>
|
||||
public string? ContentType { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response status code for this operation
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Raw HTTP response; suitable for custom response parsing
|
||||
/// </summary>
|
||||
public HttpResponseMessage RawResponse { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The contents of the library by section and type
|
||||
/// </summary>
|
||||
public SearchLibraryResponseBody? Object { get; set; }
|
||||
}
|
||||
}
|
||||
24
PlexAPI/Models/Requests/SearchLibraryResponseBody.cs
Normal file
24
PlexAPI/Models/Requests/SearchLibraryResponseBody.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
/// <summary>
|
||||
/// The contents of the library by section and type
|
||||
/// </summary>
|
||||
public class SearchLibraryResponseBody
|
||||
{
|
||||
|
||||
[JsonProperty("MediaContainer")]
|
||||
public SearchLibraryMediaContainer? MediaContainer { get; set; }
|
||||
}
|
||||
}
|
||||
48
PlexAPI/Models/Requests/Setting.cs
Normal file
48
PlexAPI/Models/Requests/Setting.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class Setting
|
||||
{
|
||||
|
||||
[JsonProperty("id")]
|
||||
public string? Id { get; set; }
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string? Label { get; set; }
|
||||
|
||||
[JsonProperty("summary")]
|
||||
public string? Summary { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string? Type { get; set; }
|
||||
|
||||
[JsonProperty("default")]
|
||||
public bool? Default { get; set; }
|
||||
|
||||
[JsonProperty("value")]
|
||||
public bool? Value { get; set; }
|
||||
|
||||
[JsonProperty("hidden")]
|
||||
public bool? Hidden { get; set; }
|
||||
|
||||
[JsonProperty("advanced")]
|
||||
public bool? Advanced { get; set; }
|
||||
|
||||
[JsonProperty("group")]
|
||||
public string? Group { get; set; }
|
||||
|
||||
[JsonProperty("enumValues")]
|
||||
public string? EnumValues { get; set; }
|
||||
}
|
||||
}
|
||||
39
PlexAPI/Models/Requests/StatisticsMedia.cs
Normal file
39
PlexAPI/Models/Requests/StatisticsMedia.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class StatisticsMedia
|
||||
{
|
||||
|
||||
[JsonProperty("accountID")]
|
||||
public int? AccountID { get; set; }
|
||||
|
||||
[JsonProperty("deviceID")]
|
||||
public int? DeviceID { get; set; }
|
||||
|
||||
[JsonProperty("timespan")]
|
||||
public int? Timespan { get; set; }
|
||||
|
||||
[JsonProperty("at")]
|
||||
public int? At { get; set; }
|
||||
|
||||
[JsonProperty("metadataType")]
|
||||
public int? MetadataType { get; set; }
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int? Count { get; set; }
|
||||
|
||||
[JsonProperty("duration")]
|
||||
public int? Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,6 @@ namespace PlexAPI.Models.Requests
|
||||
FirstCharacter,
|
||||
[JsonProperty("folder")]
|
||||
Folder,
|
||||
[JsonProperty("search?type=1")]
|
||||
SearchTypeEqual1,
|
||||
}
|
||||
|
||||
public static class TagExtension
|
||||
|
||||
@@ -10,53 +10,16 @@
|
||||
#nullable enable
|
||||
namespace PlexAPI.Models.Requests
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// type of playlist to create
|
||||
/// Plex content type to search for
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
[JsonProperty("audio")]
|
||||
Audio,
|
||||
[JsonProperty("video")]
|
||||
Video,
|
||||
[JsonProperty("photo")]
|
||||
Photo,
|
||||
}
|
||||
|
||||
public static class TypeExtension
|
||||
{
|
||||
public static string Value(this Type value)
|
||||
{
|
||||
return ((JsonPropertyAttribute)value.GetType().GetMember(value.ToString())[0].GetCustomAttributes(typeof(JsonPropertyAttribute), false)[0]).PropertyName ?? value.ToString();
|
||||
}
|
||||
|
||||
public static Type ToEnum(this string value)
|
||||
{
|
||||
foreach(var field in typeof(Type).GetFields())
|
||||
{
|
||||
var attributes = field.GetCustomAttributes(typeof(JsonPropertyAttribute), false);
|
||||
if (attributes.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var attribute = attributes[0] as JsonPropertyAttribute;
|
||||
if (attribute != null && attribute.PropertyName == value)
|
||||
{
|
||||
var enumVal = field.GetValue(null);
|
||||
|
||||
if (enumVal is Type)
|
||||
{
|
||||
return (Type)enumVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"Unknown value {value} for enum Type");
|
||||
}
|
||||
One = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -41,7 +42,7 @@ namespace PlexAPI
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<CreatePlaylistResponse> CreatePlaylistAsync(CreatePlaylistRequest? request = null);
|
||||
Task<CreatePlaylistResponse> CreatePlaylistAsync(CreatePlaylistRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Get All Playlists
|
||||
@@ -142,71 +143,75 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Playlists(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Playlists(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<CreatePlaylistResponse> CreatePlaylistAsync(CreatePlaylistRequest? request = null)
|
||||
public async Task<CreatePlaylistResponse> CreatePlaylistAsync(CreatePlaylistRequest request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new CreatePlaylistResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<CreatePlaylistResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<CreatePlaylistPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetPlaylistsResponse> GetPlaylistsAsync(PlaylistType? playlistType = null, QueryParamSmart? smart = null)
|
||||
{
|
||||
@@ -217,50 +222,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetPlaylistsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistsPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetPlaylistResponse> GetPlaylistAsync(double playlistID)
|
||||
{
|
||||
@@ -270,50 +280,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetPlaylistResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<DeletePlaylistResponse> DeletePlaylistAsync(double playlistID)
|
||||
{
|
||||
@@ -323,41 +338,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new DeletePlaylistResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<DeletePlaylistResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<UpdatePlaylistResponse> UpdatePlaylistAsync(double playlistID, string? title = null, string? summary = null)
|
||||
{
|
||||
@@ -369,41 +388,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new UpdatePlaylistResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<UpdatePlaylistResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetPlaylistContentsResponse> GetPlaylistContentsAsync(double playlistID, double type)
|
||||
{
|
||||
@@ -414,50 +437,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}/items", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetPlaylistContentsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistContentsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetPlaylistContentsPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<ClearPlaylistContentsResponse> ClearPlaylistContentsAsync(double playlistID)
|
||||
{
|
||||
@@ -467,41 +495,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}/items", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new ClearPlaylistContentsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<ClearPlaylistContentsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<AddPlaylistContentsResponse> AddPlaylistContentsAsync(double playlistID, string uri, double? playQueueID = null)
|
||||
{
|
||||
@@ -513,50 +545,55 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/{playlistID}/items", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new AddPlaylistContentsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<AddPlaylistContentsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<AddPlaylistContentsPlaylistsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<UploadPlaylistResponse> UploadPlaylistAsync(string path, Force force)
|
||||
{
|
||||
@@ -567,40 +604,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/playlists/upload", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new UploadPlaylistResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<UploadPlaylistResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
197
PlexAPI/Plex.cs
Normal file
197
PlexAPI/Plex.cs
Normal file
@@ -0,0 +1,197 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations directly against https://Plex.tv<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public interface IPlex
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get a Pin
|
||||
///
|
||||
/// <remarks>
|
||||
/// Retrieve a Pin from Plex.tv for authentication flows
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetPinResponse> GetPinAsync(string xPlexClientIdentifier, bool? strong = null, string? serverUrl = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get Access Token
|
||||
///
|
||||
/// <remarks>
|
||||
/// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetTokenResponse> GetTokenAsync(string pinID, string xPlexClientIdentifier, string? serverUrl = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations directly against https://Plex.tv<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class Plex: IPlex
|
||||
{
|
||||
/// <summary>
|
||||
/// List of server URLs available for the getPin operation.
|
||||
/// </summary>
|
||||
public static readonly string[] GetPinServerList = {
|
||||
"https://plex.tv/api/v2",
|
||||
};
|
||||
/// <summary>
|
||||
/// List of server URLs available for the getToken operation.
|
||||
/// </summary>
|
||||
public static readonly string[] GetTokenServerList = {
|
||||
"https://plex.tv/api/v2",
|
||||
};
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Plex(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
public async Task<GetPinResponse> GetPinAsync(string xPlexClientIdentifier, bool? strong = null, string? serverUrl = null)
|
||||
{
|
||||
var request = new GetPinRequest()
|
||||
{
|
||||
XPlexClientIdentifier = xPlexClientIdentifier,
|
||||
Strong = strong,
|
||||
};
|
||||
string baseUrl = Utilities.TemplateUrl(GetPinServerList[0], new Dictionary<string, string>(){
|
||||
});
|
||||
if (serverUrl != null)
|
||||
{
|
||||
baseUrl = serverUrl;
|
||||
}
|
||||
var urlString = URLBuilder.Build(baseUrl, "/pins", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
||||
|
||||
var client = _defaultClient;
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new GetPinResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetPinResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetPinPlexResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetTokenResponse> GetTokenAsync(string pinID, string xPlexClientIdentifier, string? serverUrl = null)
|
||||
{
|
||||
var request = new GetTokenRequest()
|
||||
{
|
||||
PinID = pinID,
|
||||
XPlexClientIdentifier = xPlexClientIdentifier,
|
||||
};
|
||||
string baseUrl = Utilities.TemplateUrl(GetTokenServerList[0], new Dictionary<string, string>(){
|
||||
});
|
||||
if (serverUrl != null)
|
||||
{
|
||||
baseUrl = serverUrl;
|
||||
}
|
||||
var urlString = URLBuilder.Build(baseUrl, "/pins/{pinID}", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
||||
|
||||
var client = _defaultClient;
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new GetTokenResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetTokenResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageId>Plex-API</PackageId>
|
||||
<Version>0.1.5</Version>
|
||||
<Version>0.2.0</Version>
|
||||
<Authors>LukeHagar</Authors>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace PlexAPI
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The protocol to use when connecting to your plex server.
|
||||
/// </summary>
|
||||
@@ -92,6 +91,15 @@ namespace PlexAPI
|
||||
/// </summary>
|
||||
public IMedia Media { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations with Plex Media Server Videos<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public IVideo Video { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Activities are awesome. They provide a way to monitor and control asynchronous operations on the server. In order to receive real-time updates for activities, a client would normally subscribe via either EventSource or Websocket endpoints.<br/>
|
||||
///
|
||||
@@ -152,6 +160,15 @@ namespace PlexAPI
|
||||
/// </summary>
|
||||
public ILog Log { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations directly against https://Plex.tv<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public IPlex Plex { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017"). <br/>
|
||||
///
|
||||
@@ -165,13 +182,22 @@ namespace PlexAPI
|
||||
public IPlaylists Playlists { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls against Security for Plex Media Server<br/>
|
||||
/// API Calls regarding authentication for Plex Media Server<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public ISecurity Security { get; }
|
||||
public IAuthentication Authentication { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations with Plex Media Server Statistics<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public IStatistics Statistics { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform search operations with Plex Media Server Sessions<br/>
|
||||
@@ -191,24 +217,17 @@ namespace PlexAPI
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public IUpdater Updater { get; }
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations with Plex Media Server Videos<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public IVideo Video { get; }
|
||||
}
|
||||
|
||||
|
||||
public class SDKConfig
|
||||
{
|
||||
public static string[] ServerList = new string[]
|
||||
{
|
||||
/// <summary>
|
||||
/// List of server URLs available to the SDK.
|
||||
/// </summary>
|
||||
public static readonly string[] ServerList = {
|
||||
"{protocol}://{ip}:{port}",
|
||||
};
|
||||
/// Contains the list of servers available to the SDK
|
||||
|
||||
public string serverUrl = "";
|
||||
public int serverIndex = 0;
|
||||
public List<Dictionary<string, string>> ServerDefaults = new List<Dictionary<string, string>>();
|
||||
@@ -235,31 +254,45 @@ namespace PlexAPI
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private int _serverIndex = 0;
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
public IServer Server { get; private set; }
|
||||
public IMedia Media { get; private set; }
|
||||
public IVideo Video { get; private set; }
|
||||
public IActivities Activities { get; private set; }
|
||||
public IButler Butler { get; private set; }
|
||||
public IHubs Hubs { get; private set; }
|
||||
public ISearch Search { get; private set; }
|
||||
public ILibrary Library { get; private set; }
|
||||
public ILog Log { get; private set; }
|
||||
public IPlex Plex { get; private set; }
|
||||
public IPlaylists Playlists { get; private set; }
|
||||
public ISecurity Security { get; private set; }
|
||||
public IAuthentication Authentication { get; private set; }
|
||||
public IStatistics Statistics { get; private set; }
|
||||
public ISessions Sessions { get; private set; }
|
||||
public IUpdater Updater { get; private set; }
|
||||
public IVideo Video { get; private set; }
|
||||
|
||||
public PlexAPISDK(Security? security = null, int? serverIndex = null, ServerProtocol? protocol = null, string? ip = null, string? port = null, string? serverUrl = null, Dictionary<string, string>? urlParams = null, ISpeakeasyHttpClient? client = null)
|
||||
public PlexAPISDK(string? accessToken = null, Func<string>? accessTokenSource = null, int? serverIndex = null, ServerProtocol? protocol = null, string? ip = null, string? port = null, string? serverUrl = null, Dictionary<string, string>? urlParams = null, ISpeakeasyHttpClient? client = null)
|
||||
{
|
||||
if (serverUrl != null) {
|
||||
if (urlParams != null) {
|
||||
if (serverIndex != null)
|
||||
{
|
||||
if (serverIndex.Value < 0 || serverIndex.Value >= SDKConfig.ServerList.Length)
|
||||
{
|
||||
throw new Exception($"Invalid server index {serverIndex.Value}");
|
||||
}
|
||||
_serverIndex = serverIndex.Value;
|
||||
}
|
||||
|
||||
if (serverUrl != null)
|
||||
{
|
||||
if (urlParams != null)
|
||||
{
|
||||
serverUrl = Utilities.TemplateUrl(serverUrl, urlParams);
|
||||
}
|
||||
_serverUrl = serverUrl;
|
||||
@@ -275,32 +308,42 @@ namespace PlexAPI
|
||||
};
|
||||
|
||||
_defaultClient = new SpeakeasyHttpClient(client);
|
||||
_securityClient = _defaultClient;
|
||||
|
||||
if(security != null)
|
||||
|
||||
if(accessTokenSource != null)
|
||||
{
|
||||
_securityClient = SecuritySerializer.Apply(_defaultClient, security);
|
||||
_securitySource = () => new Security() { AccessToken = accessTokenSource() };
|
||||
}
|
||||
|
||||
else if(accessToken != null)
|
||||
{
|
||||
_securitySource = () => new Security() { AccessToken = accessToken };
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("accessToken and accessTokenSource cannot both be null");
|
||||
}
|
||||
|
||||
SDKConfiguration = new SDKConfig()
|
||||
{
|
||||
ServerDefaults = serverDefaults,
|
||||
serverIndex = _serverIndex,
|
||||
serverUrl = _serverUrl
|
||||
};
|
||||
|
||||
Server = new Server(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Media = new Media(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Activities = new Activities(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Butler = new Butler(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Hubs = new Hubs(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Search = new Search(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Library = new Library(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Log = new Log(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Playlists = new Playlists(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Security = new Security(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Sessions = new Sessions(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Updater = new Updater(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Video = new Video(_defaultClient, _securityClient, _serverUrl, SDKConfiguration);
|
||||
Server = new Server(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Media = new Media(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Video = new Video(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Activities = new Activities(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Butler = new Butler(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Hubs = new Hubs(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Search = new Search(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Library = new Library(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Log = new Log(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Plex = new Plex(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Playlists = new Playlists(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Authentication = new Authentication(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Statistics = new Statistics(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Sessions = new Sessions(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
Updater = new Updater(_defaultClient, _securitySource, _serverUrl, SDKConfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -83,22 +84,21 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Search(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Search(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<PerformSearchResponse> PerformSearchAsync(string query, double? sectionId = null, double? limit = null)
|
||||
{
|
||||
@@ -110,41 +110,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/hubs/search", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new PerformSearchResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<PerformSearchResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<PerformVoiceSearchResponse> PerformVoiceSearchAsync(string query, double? sectionId = null, double? limit = null)
|
||||
{
|
||||
@@ -156,41 +160,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/hubs/search/voice", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new PerformVoiceSearchResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<PerformVoiceSearchResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetSearchResultsResponse> GetSearchResultsAsync(string query)
|
||||
{
|
||||
@@ -200,49 +208,54 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/search", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetSearchResultsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetSearchResultsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetSearchResultsSearchResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -90,7 +91,7 @@ namespace PlexAPI
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetResizedPhotoResponse> GetResizedPhotoAsync(GetResizedPhotoRequest? request = null);
|
||||
Task<GetResizedPhotoResponse> GetResizedPhotoAsync(GetResizedPhotoRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Get Server List
|
||||
@@ -113,404 +114,449 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Server(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Server(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetServerCapabilitiesResponse> GetServerCapabilitiesAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetServerCapabilitiesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetServerCapabilitiesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetServerCapabilitiesServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetServerPreferencesResponse> GetServerPreferencesAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/:/prefs";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetServerPreferencesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetServerPreferencesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetServerPreferencesServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetAvailableClientsResponse> GetAvailableClientsAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/clients";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetAvailableClientsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetAvailableClientsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetAvailableClientsServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetDevicesResponse> GetDevicesAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/devices";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetDevicesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetDevicesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetDevicesServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetServerIdentityResponse> GetServerIdentityAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/identity";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetServerIdentityResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetServerIdentityResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetServerIdentityServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetMyPlexAccountResponse> GetMyPlexAccountAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/myplex/account";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetMyPlexAccountResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetMyPlexAccountResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetMyPlexAccountServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetResizedPhotoResponse> GetResizedPhotoAsync(GetResizedPhotoRequest? request = null)
|
||||
|
||||
public async Task<GetResizedPhotoResponse> GetResizedPhotoAsync(GetResizedPhotoRequest request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/photo/:/transcode", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetResizedPhotoResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetResizedPhotoResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetServerListResponse> GetServerListAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/servers";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetServerListResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetServerListResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetServerListServerResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -76,169 +77,186 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Sessions(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Sessions(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetSessionsResponse> GetSessionsAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/status/sessions";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetSessionsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetSessionsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetSessionsSessionsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetSessionHistoryResponse> GetSessionHistoryAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/status/sessions/history/all";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetSessionHistoryResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetSessionHistoryResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetSessionHistorySessionsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetTranscodeSessionsResponse> GetTranscodeSessionsAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/transcode/sessions";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetTranscodeSessionsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetTranscodeSessionsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetTranscodeSessionsSessionsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StopTranscodeSessionResponse> StopTranscodeSessionAsync(string sessionKey)
|
||||
{
|
||||
@@ -248,40 +266,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/transcode/sessions/{sessionKey}", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new StopTranscodeSessionResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 204) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StopTranscodeSessionResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
127
PlexAPI/Statistics.cs
Normal file
127
PlexAPI/Statistics.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). 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 PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations with Plex Media Server Statistics<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public interface IStatistics
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get Media Statistics
|
||||
///
|
||||
/// <remarks>
|
||||
/// This will return the media statistics for the server
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetStatisticsResponse> GetStatisticsAsync(long? timespan = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API Calls that perform operations with Plex Media Server Statistics<br/>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public class Statistics: IStatistics
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Statistics(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
public async Task<GetStatisticsResponse> GetStatisticsAsync(long? timespan = null)
|
||||
{
|
||||
var request = new GetStatisticsRequest()
|
||||
{
|
||||
Timespan = timespan,
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/statistics/media", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new GetStatisticsResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetStatisticsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetStatisticsStatisticsResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -70,71 +71,76 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Updater(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Updater(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetUpdateStatusResponse> GetUpdateStatusAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
|
||||
var urlString = baseUrl + "/updater/status";
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetUpdateStatusResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.TwoHundredApplicationJsonObject = JsonConvert.DeserializeObject<GetUpdateStatusResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.FourHundredAndOneApplicationJsonObject = JsonConvert.DeserializeObject<GetUpdateStatusUpdaterResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<CheckForUpdatesResponse> CheckForUpdatesAsync(Download? download = null)
|
||||
{
|
||||
@@ -144,41 +150,45 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/updater/check", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new CheckForUpdatesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<CheckForUpdatesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<ApplyUpdatesResponse> ApplyUpdatesAsync(Tonight? tonight = null, Skip? skip = null)
|
||||
{
|
||||
@@ -189,40 +199,44 @@ namespace PlexAPI
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/updater/apply", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new ApplyUpdatesResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400) || (response.StatusCode == 500))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<ApplyUpdatesResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,16 @@ namespace PlexAPI.Utils
|
||||
|
||||
internal class BigIntSerializer : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(BigInteger);
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
var nullableType = Nullable.GetUnderlyingType(objectType);
|
||||
if (nullableType != null)
|
||||
{
|
||||
return nullableType == typeof(BigInteger);
|
||||
}
|
||||
|
||||
return objectType == typeof(BigInteger);
|
||||
}
|
||||
|
||||
public override bool CanRead => true;
|
||||
|
||||
|
||||
@@ -16,7 +16,16 @@ namespace PlexAPI.Utils
|
||||
|
||||
internal class DecimalSerializer : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(Decimal);
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
var nullableType = Nullable.GetUnderlyingType(objectType);
|
||||
if (nullableType != null)
|
||||
{
|
||||
return nullableType == typeof(Decimal);
|
||||
}
|
||||
|
||||
return objectType == typeof(Decimal);
|
||||
}
|
||||
|
||||
public override bool CanRead => true;
|
||||
|
||||
|
||||
@@ -15,7 +15,16 @@ namespace PlexAPI.Utils
|
||||
{
|
||||
internal class EnumSerializer : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(System.Type objectType) => objectType.IsEnum;
|
||||
public override bool CanConvert(System.Type objectType)
|
||||
{
|
||||
var nullableType = Nullable.GetUnderlyingType(objectType);
|
||||
if (nullableType != null)
|
||||
{
|
||||
return nullableType.IsEnum;
|
||||
}
|
||||
|
||||
return objectType.IsEnum;
|
||||
}
|
||||
|
||||
public override bool CanRead => true;
|
||||
|
||||
|
||||
@@ -16,8 +16,16 @@ namespace PlexAPI.Utils
|
||||
|
||||
internal class IsoDateTimeSerializer: JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType) =>
|
||||
objectType == typeof(DateTime);
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
var nullableType = Nullable.GetUnderlyingType(objectType);
|
||||
if (nullableType != null)
|
||||
{
|
||||
return nullableType == typeof(DateTime);
|
||||
}
|
||||
|
||||
return objectType == typeof(DateTime);
|
||||
}
|
||||
|
||||
public override bool CanRead => false;
|
||||
|
||||
|
||||
@@ -22,11 +22,23 @@ namespace PlexAPI.Utils
|
||||
public static HttpContent? Serialize(
|
||||
object? request,
|
||||
string requestFieldName,
|
||||
string serializationMethod
|
||||
string serializationMethod,
|
||||
bool nullable = false,
|
||||
bool optional = false,
|
||||
string format = ""
|
||||
)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
if (!nullable && !optional)
|
||||
{
|
||||
throw new ArgumentNullException("request body is required");
|
||||
}
|
||||
else if (nullable && serializationMethod == "json")
|
||||
{
|
||||
return new StringContent("null", Encoding.UTF8, "application/json");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -56,14 +68,15 @@ namespace PlexAPI.Utils
|
||||
}
|
||||
|
||||
// Not an object or flattened request
|
||||
return TrySerialize(request, requestFieldName, serializationMethod);
|
||||
return TrySerialize(request, requestFieldName, serializationMethod, "", format);
|
||||
}
|
||||
|
||||
private static HttpContent? TrySerialize(
|
||||
object request,
|
||||
string requestFieldName,
|
||||
string serializationMethod,
|
||||
string mediaType = ""
|
||||
string mediaType = "",
|
||||
string format = ""
|
||||
)
|
||||
{
|
||||
if (mediaType == "")
|
||||
@@ -81,7 +94,7 @@ namespace PlexAPI.Utils
|
||||
switch (serializationMethod)
|
||||
{
|
||||
case "json":
|
||||
return SerializeJson(request, mediaType);
|
||||
return SerializeJson(request, mediaType, format);
|
||||
case "form":
|
||||
return SerializeForm(request, requestFieldName, mediaType);
|
||||
case "multipart":
|
||||
@@ -109,9 +122,9 @@ namespace PlexAPI.Utils
|
||||
}
|
||||
}
|
||||
|
||||
private static HttpContent SerializeJson(object request, string mediaType)
|
||||
private static HttpContent SerializeJson(object request, string mediaType, string format = "")
|
||||
{
|
||||
return new StringContent(Utilities.SerializeJSON(request), Encoding.UTF8, mediaType);
|
||||
return new StringContent(Utilities.SerializeJSON(request, format), Encoding.UTF8, mediaType);
|
||||
}
|
||||
|
||||
private static HttpContent SerializeForm(
|
||||
@@ -482,7 +495,7 @@ namespace PlexAPI.Utils
|
||||
{
|
||||
form[fieldName] = new List<string>();
|
||||
}
|
||||
|
||||
|
||||
form[fieldName].Add(Utilities.ValueToString(value));
|
||||
}
|
||||
}
|
||||
@@ -499,4 +512,4 @@ namespace PlexAPI.Utils
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,14 @@ namespace PlexAPI.Utils
|
||||
|
||||
internal static class SecuritySerializer
|
||||
{
|
||||
public static ISpeakeasyHttpClient Apply(ISpeakeasyHttpClient client, object security)
|
||||
public static ISpeakeasyHttpClient Apply(ISpeakeasyHttpClient client, Func<object> securitySource)
|
||||
{
|
||||
if (securitySource == null)
|
||||
{
|
||||
return client;
|
||||
}
|
||||
|
||||
var security = securitySource();
|
||||
if (security == null)
|
||||
{
|
||||
return client;
|
||||
|
||||
@@ -15,24 +15,52 @@ namespace PlexAPI.Utils
|
||||
using System.Net.Http.Headers;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using NodaTime;
|
||||
using System.Collections;
|
||||
|
||||
public class Utilities
|
||||
{
|
||||
public static string SerializeJSON(object obj)
|
||||
public static JsonConverter[] GetJsonConverters(Type type, string format = "")
|
||||
{
|
||||
if (format == "string")
|
||||
{
|
||||
if (type == typeof(BigInteger))
|
||||
{
|
||||
return new JsonConverter[] { new BigIntSerializer() };
|
||||
}
|
||||
if (type == typeof(Decimal))
|
||||
{
|
||||
return new JsonConverter[] { new DecimalSerializer() };
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonConverter[]
|
||||
{
|
||||
new IsoDateTimeSerializer(),
|
||||
new EnumSerializer(),
|
||||
};
|
||||
}
|
||||
|
||||
public static string SerializeJSON(object obj, string format = "")
|
||||
{
|
||||
var type = obj.GetType();
|
||||
if (IsList(obj))
|
||||
{
|
||||
type = type.GetGenericArguments().Single();
|
||||
}
|
||||
else if (IsDictionary(obj))
|
||||
{
|
||||
type = type.GetGenericArguments().Last();
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(
|
||||
obj,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Converters = new JsonConverter[]
|
||||
{
|
||||
new IsoDateTimeSerializer(),
|
||||
new EnumSerializer()
|
||||
}
|
||||
Converters = GetJsonConverters(type, format)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -82,11 +110,11 @@ namespace PlexAPI.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPrimitive(object obj) => obj != null && obj.GetType().IsPrimitive;
|
||||
public static bool IsPrimitive(object? obj) => obj != null && obj.GetType().IsPrimitive;
|
||||
|
||||
public static bool IsEnum(object obj) => obj != null && obj.GetType().IsEnum;
|
||||
public static bool IsEnum(object? obj) => obj != null && obj.GetType().IsEnum;
|
||||
|
||||
public static bool IsDate(object obj) =>
|
||||
public static bool IsDate(object? obj) =>
|
||||
obj != null && (obj.GetType() == typeof(DateTime) || obj.GetType() == typeof(LocalDate));
|
||||
|
||||
private static string StripSurroundingQuotes(string input)
|
||||
@@ -238,4 +266,4 @@ namespace PlexAPI.Utils
|
||||
return template;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
144
PlexAPI/Video.cs
144
PlexAPI/Video.cs
@@ -11,6 +11,7 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -28,6 +29,15 @@ namespace PlexAPI
|
||||
public interface IVideo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Get the timeline for a media item
|
||||
///
|
||||
/// <remarks>
|
||||
/// Get the timeline for a media item
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetTimelineResponse> GetTimelineAsync(GetTimelineRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Start Universal Transcode
|
||||
///
|
||||
@@ -35,16 +45,7 @@ namespace PlexAPI
|
||||
/// Begin a Universal Transcode Session
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<StartUniversalTranscodeResponse> StartUniversalTranscodeAsync(StartUniversalTranscodeRequest? request = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get the timeline for a media item
|
||||
///
|
||||
/// <remarks>
|
||||
/// Get the timeline for a media item
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
Task<GetTimelineResponse> GetTimelineAsync(GetTimelineRequest? request = null);
|
||||
Task<StartUniversalTranscodeResponse> StartUniversalTranscodeAsync(StartUniversalTranscodeRequest request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,101 +59,108 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.1.5";
|
||||
private const string _sdkGenVersion = "2.237.3";
|
||||
private const string _sdkVersion = "0.2.0";
|
||||
private const string _sdkGenVersion = "2.279.1";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.1.5 2.237.3 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.0 2.279.1 0.0.3 Plex-API";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _securityClient;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Video(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
|
||||
public Video(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_securityClient = securityClient;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
}
|
||||
|
||||
|
||||
public async Task<StartUniversalTranscodeResponse> StartUniversalTranscodeAsync(StartUniversalTranscodeRequest? request = null)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/video/:/transcode/universal/start.mpd", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new StartUniversalTranscodeResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
return response;
|
||||
}
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StartUniversalTranscodeResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetTimelineResponse> GetTimelineAsync(GetTimelineRequest? request = null)
|
||||
public async Task<GetTimelineResponse> GetTimelineAsync(GetTimelineRequest request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/:/timeline", request);
|
||||
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
|
||||
var client = _securityClient;
|
||||
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
|
||||
var response = new GetTimelineResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<GetTimelineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<StartUniversalTranscodeResponse> StartUniversalTranscodeAsync(StartUniversalTranscodeRequest request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/video/:/transcode/universal/start.mpd", request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
var response = new StartUniversalTranscodeResponse
|
||||
{
|
||||
StatusCode = (int)httpResponse.StatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};
|
||||
|
||||
if((response.StatusCode == 200) || (response.StatusCode == 400))
|
||||
{
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
if((response.StatusCode == 401))
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<StartUniversalTranscodeResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user