ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.391.3

This commit is contained in:
speakeasybot
2024-09-06 17:13:00 +00:00
parent 2bed38d2cb
commit d077d5e9f0
610 changed files with 4195 additions and 3384 deletions

View File

@@ -0,0 +1,36 @@
namespace LukeHagar.PlexAPI.SDK.Hooks
{
/// <summary>
/// Hook Registration File.
/// </summary>
/// <remarks>
/// This file is only ever generated once on the first generation and then is free to be modified.
/// Any hooks you wish to add should be registered in the InitHooks function. Feel free to define them
/// in this file or in separate files in the Hooks folder.
/// </remarks>
public static class HookRegistration
{
/// <summary>
/// Initializes hooks.
/// </summary>
/// <remarks>
/// Add hooks by calling `LukeHagar.PlexAPI.SDK.Hooks.Register&lt;HookInterface&gt;(myHook);`
/// where `I&lt;HookInterface&gt;` is one of the following interfaces defined in HookTypes.cs:
/// - ISDKInitHook
/// - IBeforeRequestHook
/// - IAfterSuccess
/// - IAfterError
/// and `myHook` an instance that implements that specific interface.
/// </remarks>
public static void InitHooks(IHooks hooks)
{
// var myHook = new MyHook();
// hooks.RegisterSDKInitHook(myHook);
// hooks.RegisterBeforeRequestHook(myHook);
// hooks.RegisterAfterSuccessHook(myHook);
// hooks.RegisterAfterErrorHook(myHook;
}
}
}

View File

@@ -0,0 +1,98 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace LukeHagar.PlexAPI.SDK.Hooks
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using LukeHagar.PlexAPI.SDK.Utils;
public class HookContext
{
public string OperationID { get; set; }
public List<string>? Oauth2Scopes { get; set; }
public Func<object>? SecuritySource { get; set; }
public HookContext(string operationID, List<string>? oauth2Scopes, Func<object>? securitySource)
{
OperationID = operationID;
Oauth2Scopes = oauth2Scopes;
SecuritySource = securitySource;
}
}
public class BeforeRequestContext : HookContext
{
public BeforeRequestContext(HookContext hookCtx)
: base(hookCtx.OperationID, hookCtx.Oauth2Scopes, hookCtx.SecuritySource) { }
}
public class AfterSuccessContext : HookContext
{
public AfterSuccessContext(HookContext hookCtx)
: base(hookCtx.OperationID, hookCtx.Oauth2Scopes, hookCtx.SecuritySource) { }
}
public class AfterErrorContext : HookContext
{
public AfterErrorContext(HookContext hookCtx)
: base(hookCtx.OperationID, hookCtx.Oauth2Scopes, hookCtx.SecuritySource) { }
}
/// <summary>
/// SDKInit hook is called when the SDK is initializing.
/// The hook can modify and return a new baseUrl and HTTP client to be used by the SDK.
/// </summary>
public interface ISDKInitHook
{
(string, ISpeakeasyHttpClient) SDKInit(string baseUrl, ISpeakeasyHttpClient client);
}
/// <summary>
/// BeforeRequestAsync hook is called before the SDK sends a request.
/// The hook can modify the request before it is sent or throw an exception to stop the request from being sent.
/// </summary>
public interface IBeforeRequestHook
{
Task<HttpRequestMessage> BeforeRequestAsync(BeforeRequestContext hookCtx, HttpRequestMessage request);
}
/// <summary>
/// AfterSuccessAsync is called after the SDK receives a response.
/// The hook can modify the response before it is handled or throw an exception to stop the response from being handled.
/// </summary>
public interface IAfterSuccessHook
{
Task<HttpResponseMessage> AfterSuccessAsync(AfterSuccessContext hookCtx, HttpResponseMessage response);
}
/// <summary>
/// AfterErrorAsync is called after the SDK encounters an error, or a non-successful response.
/// The hook can modify the response, if available, otherwise modify the error.
/// All hooks are called sequentially. If an error is returned, it will be passed to the subsequent hook implementing IAfterErrorHook.
/// If you want to prevent other AfterError hooks from being run, you can throw an FailEarlyException instead.
/// </summary>
public interface IAfterErrorHook
{
Task<(HttpResponseMessage?, Exception?)> AfterErrorAsync(AfterErrorContext hookCtx, HttpResponseMessage? response, Exception? error);
}
public interface IHooks
{
void RegisterSDKInitHook(ISDKInitHook hook);
void RegisterBeforeRequestHook(IBeforeRequestHook hook);
void RegisterAfterSuccessHook(IAfterSuccessHook hook);
void RegisterAfterErrorHook(IAfterErrorHook hook);
}
}

View File

@@ -0,0 +1,129 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace LukeHagar.PlexAPI.SDK.Hooks
{
using LukeHagar.PlexAPI.SDK.Utils;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
public sealed class FailEarlyException : Exception {}
public class SDKHooks: IHooks
{
public List<ISDKInitHook> sdkInitHooks;
public List<IBeforeRequestHook> beforeRequestHooks;
public List<IAfterSuccessHook> afterSuccessHooks;
public List<IAfterErrorHook> afterErrorHooks;
public SDKHooks()
{
this.sdkInitHooks = new List<ISDKInitHook>();
this.beforeRequestHooks = new List<IBeforeRequestHook>();
this.afterSuccessHooks = new List<IAfterSuccessHook>();
this.afterErrorHooks = new List<IAfterErrorHook>();
HookRegistration.InitHooks(this);
}
public void RegisterSDKInitHook(ISDKInitHook hook)
{
this.sdkInitHooks.Add(hook);
}
public void RegisterBeforeRequestHook(IBeforeRequestHook hook)
{
this.beforeRequestHooks.Add(hook);
}
public void RegisterAfterSuccessHook(IAfterSuccessHook hook)
{
this.afterSuccessHooks.Add(hook);
}
public void RegisterAfterErrorHook(IAfterErrorHook hook)
{
this.afterErrorHooks.Add(hook);
}
public (string, ISpeakeasyHttpClient) SDKInit(string baseUrl, ISpeakeasyHttpClient client)
{
var urlAndClient = (baseUrl, client);
foreach (var hook in this.sdkInitHooks)
{
try
{
urlAndClient = hook.SDKInit(urlAndClient.Item1, urlAndClient.Item2);
} catch (Exception ex)
{
throw new Exception("An error occurred while calling SDKInit hook.", ex);
}
}
return urlAndClient;
}
public async Task<HttpRequestMessage> BeforeRequestAsync(BeforeRequestContext hookCtx, HttpRequestMessage request)
{
foreach (var hook in this.beforeRequestHooks)
{
try
{
request = await hook.BeforeRequestAsync(hookCtx, request);
} catch (Exception ex)
{
throw new Exception("An error occurred while calling BeforeRequestAsync hook", ex);
}
}
return request;
}
public async Task<HttpResponseMessage> AfterSuccessAsync(AfterSuccessContext hookCtx, HttpResponseMessage response)
{
foreach (var hook in this.afterSuccessHooks)
{
try
{
response = await hook.AfterSuccessAsync(hookCtx, response);
}
catch (Exception ex)
{
throw new Exception("An error occurred while calling AfterSuccessAsync hook.", ex);
}
}
return response;
}
public async Task<HttpResponseMessage?> AfterErrorAsync(AfterErrorContext hookCtx, HttpResponseMessage? response, Exception? error)
{
(HttpResponseMessage?, Exception?) responseAndError = (response, error);
foreach (var hook in this.afterErrorHooks)
{
try
{
responseAndError = await hook.AfterErrorAsync(hookCtx, responseAndError.Item1, responseAndError.Item2);
} catch (FailEarlyException)
{
throw;
} catch (Exception ex)
{
throw new Exception("An error occurred while calling AfterErrorAsync hook", ex);
}
}
if (responseAndError.Item2 != null)
{
throw responseAndError.Item2;
}
return responseAndError.Item1;
}
}
}