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

78 lines
2.7 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace LukeHagar.PlexAPI.SDK
{
using LukeHagar.PlexAPI.SDK.Hooks;
using LukeHagar.PlexAPI.SDK.Models.Components;
using LukeHagar.PlexAPI.SDK.Utils;
using LukeHagar.PlexAPI.SDK.Utils.Retries;
using System;
using System.Collections.Generic;
using System.Linq;
public struct SDKConfig
{
/// <summary>
/// List of server URLs available to the SDK.
/// </summary>
public static readonly string[] ServerList = {
"{protocol}://{ip}:{port}",
};
public ISpeakeasyHttpClient Client;
public string ServerUrl;
public int ServerIndex;
public List<Dictionary<string, string>> ServerVariables;
public string UserAgent;
public Func<LukeHagar.PlexAPI.SDK.Models.Components.Security>? SecuritySource;
public SDKHooks Hooks;
public RetryConfig? RetryConfig;
/// <summary>
/// Initializes a new instance of the SDKConfig struct with default values.
/// </summary>
public SDKConfig(ISpeakeasyHttpClient? client = null)
{
Client = client ?? new SpeakeasyHttpClient();
ServerUrl = "";
ServerIndex = 0;
ServerVariables = new List<Dictionary<string, string>>()
{
new Dictionary<string, string>()
{
{"protocol", "https"},
{"ip", "10.10.10.47"},
{"port", "32400"},
},
};
UserAgent = "speakeasy-sdk/csharp 0.16.1 2.674.3 0.0.3 LukeHagar.PlexAPI.SDK";
SecuritySource = null;
Hooks = new SDKHooks();
RetryConfig = null;
}
public void SetServerVariable(string key, string value)
{
foreach (var serverVariables in this.ServerVariables.Where(dict => dict.ContainsKey(key)))
{
serverVariables[key] = value;
}
}
public string GetTemplatedServerUrl()
{
if (!String.IsNullOrEmpty(this.ServerUrl))
{
return Utilities.TemplateUrl(Utilities.RemoveSuffix(this.ServerUrl, "/"), new Dictionary<string, string>());
}
return Utilities.TemplateUrl(SDKConfig.ServerList[this.ServerIndex], this.ServerVariables[this.ServerIndex]);
}
}
}