mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
Regenerated SDK with small changes
This commit is contained in:
290
PlexAPI/Log.cs
290
PlexAPI/Log.cs
@@ -1,4 +1,3 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
||||
@@ -11,9 +10,13 @@
|
||||
namespace PlexAPI
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using PlexAPI.Hooks;
|
||||
using PlexAPI.Models.Components;
|
||||
using PlexAPI.Models.Errors;
|
||||
using PlexAPI.Models.Requests;
|
||||
using PlexAPI.Utils.Retries;
|
||||
using PlexAPI.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
@@ -91,17 +94,17 @@ namespace PlexAPI
|
||||
{
|
||||
public SDKConfig SDKConfiguration { get; private set; }
|
||||
private const string _language = "csharp";
|
||||
private const string _sdkVersion = "0.2.1";
|
||||
private const string _sdkGenVersion = "2.281.2";
|
||||
private const string _sdkVersion = "0.3.0";
|
||||
private const string _sdkGenVersion = "2.354.2";
|
||||
private const string _openapiDocVersion = "0.0.3";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.2.1 2.281.2 0.0.3 Plex-API";
|
||||
private const string _userAgent = "speakeasy-sdk/csharp 0.3.0 2.354.2 0.0.3 PlexAPI";
|
||||
private string _serverUrl = "";
|
||||
private ISpeakeasyHttpClient _defaultClient;
|
||||
private ISpeakeasyHttpClient _client;
|
||||
private Func<Security>? _securitySource;
|
||||
|
||||
public Log(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
public Log(ISpeakeasyHttpClient client, Func<Security>? securitySource, string serverUrl, SDKConfig config)
|
||||
{
|
||||
_defaultClient = defaultClient;
|
||||
_client = client;
|
||||
_securitySource = securitySource;
|
||||
_serverUrl = serverUrl;
|
||||
SDKConfiguration = config;
|
||||
@@ -115,51 +118,88 @@ namespace PlexAPI
|
||||
Message = message,
|
||||
Source = source,
|
||||
};
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
||||
var urlString = URLBuilder.Build(baseUrl, "/log", 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);
|
||||
httpRequest = new SecurityMetadata(_securitySource).Apply(httpRequest);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
var hookCtx = new HookContext("logLine", null, _securitySource);
|
||||
|
||||
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
||||
|
||||
HttpResponseMessage httpResponse;
|
||||
try
|
||||
{
|
||||
httpResponse = await _client.SendAsync(httpRequest);
|
||||
int _statusCode = (int)httpResponse.StatusCode;
|
||||
|
||||
if (_statusCode == 400 || _statusCode == 401 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
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))
|
||||
int responseStatusCode = (int)httpResponse.StatusCode;
|
||||
if(responseStatusCode == 200)
|
||||
{
|
||||
return new LogLineResponse()
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<LogLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
StatusCode = responseStatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};;
|
||||
}
|
||||
else if(responseStatusCode == 400 || responseStatusCode >= 400 && responseStatusCode < 500 || responseStatusCode >= 500 && responseStatusCode < 600)
|
||||
{
|
||||
throw new SDKException("API error occurred", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
else if(responseStatusCode == 401)
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
||||
{
|
||||
var obj = ResponseBodyDeserializer.Deserialize<LogLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), NullValueHandling.Ignore);
|
||||
obj!.RawResponse = httpResponse;
|
||||
throw obj!;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown content type received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown status code received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<LogMultiLineResponse> LogMultiLineAsync(string request)
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
||||
|
||||
var urlString = baseUrl + "/log";
|
||||
|
||||
@@ -172,85 +212,159 @@ namespace PlexAPI
|
||||
httpRequest.Content = serializedBody;
|
||||
}
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
httpRequest = new SecurityMetadata(_securitySource).Apply(httpRequest);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
var hookCtx = new HookContext("logMultiLine", null, _securitySource);
|
||||
|
||||
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
||||
|
||||
HttpResponseMessage httpResponse;
|
||||
try
|
||||
{
|
||||
httpResponse = await _client.SendAsync(httpRequest);
|
||||
int _statusCode = (int)httpResponse.StatusCode;
|
||||
|
||||
if (_statusCode == 400 || _statusCode == 401 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
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))
|
||||
int responseStatusCode = (int)httpResponse.StatusCode;
|
||||
if(responseStatusCode == 200)
|
||||
{
|
||||
return new LogMultiLineResponse()
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<LogMultiLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
StatusCode = responseStatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};;
|
||||
}
|
||||
else if(responseStatusCode == 400 || responseStatusCode >= 400 && responseStatusCode < 500 || responseStatusCode >= 500 && responseStatusCode < 600)
|
||||
{
|
||||
throw new SDKException("API error occurred", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
else if(responseStatusCode == 401)
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
||||
{
|
||||
var obj = ResponseBodyDeserializer.Deserialize<LogMultiLineResponseBody>(await httpResponse.Content.ReadAsStringAsync(), NullValueHandling.Ignore);
|
||||
obj!.RawResponse = httpResponse;
|
||||
throw obj!;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown content type received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown status code received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public async Task<EnablePaperTrailResponse> EnablePaperTrailAsync()
|
||||
{
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
|
||||
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
||||
|
||||
var urlString = baseUrl + "/log/networked";
|
||||
|
||||
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
||||
httpRequest.Headers.Add("user-agent", _userAgent);
|
||||
|
||||
var client = _defaultClient;
|
||||
if (_securitySource != null)
|
||||
{
|
||||
client = SecuritySerializer.Apply(_defaultClient, _securitySource);
|
||||
httpRequest = new SecurityMetadata(_securitySource).Apply(httpRequest);
|
||||
}
|
||||
|
||||
var httpResponse = await client.SendAsync(httpRequest);
|
||||
var hookCtx = new HookContext("enablePaperTrail", null, _securitySource);
|
||||
|
||||
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
||||
|
||||
HttpResponseMessage httpResponse;
|
||||
try
|
||||
{
|
||||
httpResponse = await _client.SendAsync(httpRequest);
|
||||
int _statusCode = (int)httpResponse.StatusCode;
|
||||
|
||||
if (_statusCode == 400 || _statusCode == 401 || _statusCode == 403 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
||||
if (_httpResponse != null)
|
||||
{
|
||||
httpResponse = _httpResponse;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
||||
|
||||
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
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))
|
||||
int responseStatusCode = (int)httpResponse.StatusCode;
|
||||
if(responseStatusCode == 200)
|
||||
{
|
||||
return new EnablePaperTrailResponse()
|
||||
{
|
||||
response.Object = JsonConvert.DeserializeObject<EnablePaperTrailResponseBody>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
|
||||
}
|
||||
|
||||
return response;
|
||||
StatusCode = responseStatusCode,
|
||||
ContentType = contentType,
|
||||
RawResponse = httpResponse
|
||||
};;
|
||||
}
|
||||
else if(responseStatusCode == 400 || responseStatusCode == 403 || responseStatusCode >= 400 && responseStatusCode < 500 || responseStatusCode >= 500 && responseStatusCode < 600)
|
||||
{
|
||||
throw new SDKException("API error occurred", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
else if(responseStatusCode == 401)
|
||||
{
|
||||
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
||||
{
|
||||
var obj = ResponseBodyDeserializer.Deserialize<EnablePaperTrailResponseBody>(await httpResponse.Content.ReadAsStringAsync(), NullValueHandling.Ignore);
|
||||
obj!.RawResponse = httpResponse;
|
||||
throw obj!;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown content type received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SDKException("Unknown status code received", responseStatusCode, await httpResponse.Content.ReadAsStringAsync(), httpResponse);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user