mirror of
https://github.com/jellyfin/jellyfin-sdk-csharp.git
synced 2024-11-26 23:20:43 +00:00
Initialize
This commit is contained in:
commit
18f4c8f464
21
.github/dependabot.yml
vendored
Normal file
21
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: '/stable'
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '00:00'
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: '/unstable'
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '00:00'
|
||||
open-pull-requests-limit: 10
|
64
.github/workflows/stable-generation.yml
vendored
Normal file
64
.github/workflows/stable-generation.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
name: Generate stable API
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./stable
|
||||
env:
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: 'master'
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '5.0.x'
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
|
||||
- name: Restore packages
|
||||
run: dotnet restore
|
||||
|
||||
- name: Get OpenApi version
|
||||
id: apiversion
|
||||
run: echo "::set-output name=number::$(curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json | jq '.info.version')"
|
||||
|
||||
- name: Create new version string
|
||||
id: version
|
||||
run: echo "::set-output name=number::$(echo ${{ steps.apiversion.outputs.number }})"
|
||||
|
||||
- name: Install dotnet-setversion
|
||||
run: dotnet tool install -g dotnet-setversion
|
||||
|
||||
- name: Set project version
|
||||
run: setversion ${{steps.version.outputs.number}}
|
||||
|
||||
- name: Generate Api Client
|
||||
run: dotnet build -c Release
|
||||
|
||||
- name: Check if generated client files were modified
|
||||
id: diff
|
||||
run: echo "::set-output name=count::$(git status -s | grep g.cs | grep -v csproj | wc -l)"
|
||||
|
||||
- name: Publish to nuget
|
||||
# if: ${{ steps.diff.outputs.count }} > 0
|
||||
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||
|
||||
- name: Commit new changes to the repo
|
||||
# if: ${{ steps.diff.outputs.count }} > 0
|
||||
run: |
|
||||
git config --global user.email "packaging@jellyfin.org"
|
||||
git config --global user.name "Jellyfin Packaging Team"
|
||||
git pull
|
||||
git add .
|
||||
git commit -m "Update stable OpenAPI client" || echo
|
||||
git push
|
64
.github/workflows/unstable-generation.yml
vendored
Normal file
64
.github/workflows/unstable-generation.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
name: Generate unstable API
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./unstable
|
||||
env:
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: 'master'
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '5.0.x'
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
|
||||
- name: Restore packages
|
||||
run: dotnet restore
|
||||
|
||||
- name: Get OpenApi version
|
||||
id: apiversion
|
||||
run: echo "::set-output name=number::$(curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-unstable.json | jq '.info.version')"
|
||||
|
||||
- name: Create new version string
|
||||
id: version
|
||||
run: echo "::set-output name=number::$(echo ${{ steps.apiversion.outputs.number }}-unstable.$(date +'%Y%m%d%H%M'))"
|
||||
|
||||
- name: Install dotnet-setversion
|
||||
run: dotnet tool install -g dotnet-setversion
|
||||
|
||||
- name: Set project version
|
||||
run: setversion ${{steps.version.outputs.number}}
|
||||
|
||||
- name: Generate Api Client
|
||||
run: dotnet build -c Release
|
||||
|
||||
- name: Check if generated client files were modified
|
||||
id: diff
|
||||
run: echo "::set-output name=count::$(git status -s | grep g.cs | grep -v csproj | wc -l)"
|
||||
|
||||
- name: Publish to nuget
|
||||
# if: ${{ steps.diff.outputs.count }} > 0
|
||||
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||
|
||||
- name: Commit new changes to the repo
|
||||
# if: ${{ steps.diff.outputs.count }} > 0
|
||||
run: |
|
||||
git config --global user.email "packaging@jellyfin.org"
|
||||
git config --global user.name "Jellyfin Packaging Team"
|
||||
git pull
|
||||
git add .
|
||||
git commit -m "Update unstable OpenAPI client" || echo
|
||||
git push
|
240
.gitignore
vendored
Normal file
240
.gitignore
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
.directory
|
||||
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
project.fragment.lock.json
|
||||
project.lock.json
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
#################
|
||||
## Media Browser
|
||||
#################
|
||||
ProgramData*/
|
||||
CorePlugins*/
|
||||
ProgramData-Server*/
|
||||
ProgramData-UI*/
|
||||
|
||||
#################
|
||||
## Visual Studio
|
||||
#################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
.vs/
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
*.scc
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.orig
|
||||
*.rej
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.ipch
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
# packages/
|
||||
dlls/
|
||||
dllssigned/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
#############
|
||||
## Windows detritus
|
||||
#############
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
|
||||
#############
|
||||
## Python
|
||||
#############
|
||||
|
||||
*.py[co]
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
build/
|
||||
eggs/
|
||||
parts/
|
||||
var/
|
||||
sdist/
|
||||
develop-eggs/
|
||||
.installed.cfg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
|
||||
#Translations
|
||||
*.mo
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
||||
|
||||
##########
|
||||
# Rider
|
||||
##########
|
||||
.idea/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Jellyfin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
88
stable/BaseClient.cs
Normal file
88
stable/BaseClient.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jellyfin.Sdk
|
||||
{
|
||||
/// <summary>
|
||||
/// The base client.
|
||||
/// </summary>
|
||||
public class BaseClient
|
||||
{
|
||||
private readonly SdkClientSettings _clientState;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseClient"/>.
|
||||
/// </summary>
|
||||
/// <param name="clientState">The sdk client state.</param>
|
||||
public BaseClient(SdkClientSettings clientState)
|
||||
{
|
||||
_clientState = clientState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="request">The http request message.</param>
|
||||
/// <param name="url">The request url.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, StringBuilder url)
|
||||
{
|
||||
// Insert baseurl into full url.
|
||||
if (!string.IsNullOrEmpty(_clientState.BaseUrl))
|
||||
{
|
||||
url.Insert(0, _clientState.BaseUrl.TrimEnd('/') + '/');
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_clientState.AccessToken))
|
||||
{
|
||||
// Token isn't set, attempt to request without.
|
||||
request.Headers.Add("X-Emby-Authorization", _clientState.DefaultAuthorizationHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Token is set, make regular request.
|
||||
request.Headers.Add("X-Emby-Token", _clientState.AccessToken);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="request">The http request message.</param>
|
||||
/// <param name="url">The request url.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, string url)
|
||||
{
|
||||
// Required for generated api.
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process response message.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="response">The http response message.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task ProcessResponseAsync(HttpClient client, HttpResponseMessage response, CancellationToken cancellationToken)
|
||||
{
|
||||
// Required for generated api.
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
33
stable/Jellyfin.Sdk.csproj
Normal file
33
stable/Jellyfin.Sdk.csproj
Normal file
@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Version>10.7.2.1</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PackageId>Jellyfin.Sdk</PackageId>
|
||||
<Authors>Jellyfin Contributors</Authors>
|
||||
<PackageTags>Jellyfin;Api;Sdk;Client</PackageTags>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Description>Auto generated sdk for Jellyfin.</Description>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NSwag.MSBuild" Version="13.10.9">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Target Name="GenerateSdkSourceCode" BeforeTargets="CoreCompile;PrepareResource">
|
||||
<Exec Command="$(NSwagExe_Net50) run nswag.json" />
|
||||
</Target>
|
||||
</Project>
|
29
stable/SdkClientSettings.cs
Normal file
29
stable/SdkClientSettings.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace Jellyfin.Sdk
|
||||
{
|
||||
/// <summary>
|
||||
/// The sdk client settings.
|
||||
/// </summary>
|
||||
public class SdkClientSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Jellyfin server's base url.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// https://demo.jellyfin.org/stable
|
||||
/// </example>
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user's access token.
|
||||
/// </summary>
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the default authorization header.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is used when the access token is not set.
|
||||
/// </remarks>
|
||||
public string DefaultAuthorizationHeader { get; set; }
|
||||
}
|
||||
}
|
100
stable/nswag.json
Normal file
100
stable/nswag.json
Normal file
@ -0,0 +1,100 @@
|
||||
{
|
||||
"runtime": "Net50",
|
||||
"defaultVariables": null,
|
||||
"documentGenerator": {
|
||||
"fromDocument": {
|
||||
"json": "",
|
||||
"url": "https://repo.jellyfin.org/releases/openapi/jellyfin-openapi-stable.json",
|
||||
"output": null,
|
||||
"newLineBehavior": "Auto"
|
||||
}
|
||||
},
|
||||
"codeGenerators": {
|
||||
"openApiToCSharpClient": {
|
||||
"clientBaseClass": "BaseClient",
|
||||
"configurationClass": "SdkClientSettings",
|
||||
"generateClientClasses": true,
|
||||
"generateClientInterfaces": true,
|
||||
"clientBaseInterface": null,
|
||||
"injectHttpClient": true,
|
||||
"disposeHttpClient": false,
|
||||
"protectedMethods": [],
|
||||
"generateExceptionClasses": true,
|
||||
"exceptionClass": "{controller}Exception",
|
||||
"wrapDtoExceptions": true,
|
||||
"useHttpClientCreationMethod": false,
|
||||
"httpClientType": "System.Net.Http.HttpClient",
|
||||
"useHttpRequestMessageCreationMethod": false,
|
||||
"useBaseUrl": false,
|
||||
"generateBaseUrlProperty": false,
|
||||
"generateSyncMethods": false,
|
||||
"generatePrepareRequestAndProcessResponseAsAsyncMethods": true,
|
||||
"exposeJsonSerializerSettings": false,
|
||||
"clientClassAccessModifier": "public",
|
||||
"typeAccessModifier": "public",
|
||||
"generateContractsOutput": false,
|
||||
"contractsNamespace": null,
|
||||
"contractsOutputFilePath": null,
|
||||
"parameterDateTimeFormat": "s",
|
||||
"parameterDateFormat": "yyyy-MM-dd",
|
||||
"generateUpdateJsonSerializerSettingsMethod": true,
|
||||
"useRequestAndResponseSerializationSettings": false,
|
||||
"serializeTypeInformation": false,
|
||||
"queryNullValue": "",
|
||||
"className": "{controller}Client",
|
||||
"operationGenerationMode": "MultipleClientsFromFirstTagAndOperationId",
|
||||
"additionalNamespaceUsages": [],
|
||||
"additionalContractNamespaceUsages": [],
|
||||
"generateOptionalParameters": true,
|
||||
"generateJsonMethods": false,
|
||||
"enforceFlagEnums": false,
|
||||
"parameterArrayType": "System.Collections.Generic.IEnumerable",
|
||||
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"responseArrayType": "System.Collections.Generic.IReadOnlyList",
|
||||
"responseDictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"wrapResponses": false,
|
||||
"wrapResponseMethods": [],
|
||||
"generateResponseClasses": true,
|
||||
"responseClass": "SwaggerResponse",
|
||||
"namespace": "Jellyfin.Sdk",
|
||||
"requiredPropertiesMustBeDefined": true,
|
||||
"dateType": "System.DateTimeOffset",
|
||||
"jsonConverters": null,
|
||||
"anyType": "object",
|
||||
"dateTimeType": "System.DateTimeOffset",
|
||||
"timeType": "System.TimeSpan",
|
||||
"timeSpanType": "System.TimeSpan",
|
||||
"arrayType": "System.Collections.Generic.IReadOnlyList",
|
||||
"arrayInstanceType": "",
|
||||
"dictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
|
||||
"arrayBaseType": "System.Collections.Generic.IReadOnlyList",
|
||||
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
|
||||
"classStyle": "Poco",
|
||||
"jsonLibrary": "NewtonsoftJson",
|
||||
"generateDefaultValues": true,
|
||||
"generateDataAnnotations": true,
|
||||
"excludedTypeNames": [],
|
||||
"excludedParameterNames": [],
|
||||
"handleReferences": false,
|
||||
"generateImmutableArrayProperties": false,
|
||||
"generateImmutableDictionaryProperties": false,
|
||||
"jsonSerializerSettingsTransformationMethod": null,
|
||||
"inlineNamedArrays": false,
|
||||
"inlineNamedDictionaries": false,
|
||||
"inlineNamedTuples": true,
|
||||
"inlineNamedAny": false,
|
||||
"generateDtoTypes": true,
|
||||
"generateOptionalPropertiesAsNullable": false,
|
||||
"generateNullableReferenceTypes": false,
|
||||
"templateDirectory": null,
|
||||
"typeNameGeneratorType": null,
|
||||
"propertyNameGeneratorType": null,
|
||||
"enumNameGeneratorType": null,
|
||||
"serviceHost": ".",
|
||||
"serviceSchemes": null,
|
||||
"output": "JellyfinSdk.g.cs",
|
||||
"newLineBehavior": "Auto"
|
||||
}
|
||||
}
|
||||
}
|
88
unstable/BaseClient.cs
Normal file
88
unstable/BaseClient.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jellyfin.Sdk
|
||||
{
|
||||
/// <summary>
|
||||
/// The base client.
|
||||
/// </summary>
|
||||
public class BaseClient
|
||||
{
|
||||
private readonly SdkClientSettings _clientState;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseClient"/>.
|
||||
/// </summary>
|
||||
/// <param name="clientState">The sdk client state.</param>
|
||||
public BaseClient(SdkClientSettings clientState)
|
||||
{
|
||||
_clientState = clientState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="request">The http request message.</param>
|
||||
/// <param name="url">The request url.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, StringBuilder url)
|
||||
{
|
||||
// Insert baseurl into full url.
|
||||
if (!string.IsNullOrEmpty(_clientState.BaseUrl))
|
||||
{
|
||||
url.Insert(0, _clientState.BaseUrl.TrimEnd('/') + '/');
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_clientState.AccessToken))
|
||||
{
|
||||
// Token isn't set, attempt to request without.
|
||||
request.Headers.Add("X-Emby-Authorization", _clientState.DefaultAuthorizationHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Token is set, make regular request.
|
||||
request.Headers.Add("X-Emby-Token", _clientState.AccessToken);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="request">The http request message.</param>
|
||||
/// <param name="url">The request url.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, string url)
|
||||
{
|
||||
// Required for generated api.
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process response message.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for generated clients.
|
||||
/// </remarks>
|
||||
/// <param name="client">The http client.</param>
|
||||
/// <param name="response">The http response message.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The Task.</returns>
|
||||
protected Task ProcessResponseAsync(HttpClient client, HttpResponseMessage response, CancellationToken cancellationToken)
|
||||
{
|
||||
// Required for generated api.
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
33
unstable/Jellyfin.Sdk.csproj
Normal file
33
unstable/Jellyfin.Sdk.csproj
Normal file
@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Version>10.8.0-unstable.202104201640</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PackageId>Jellyfin.ApiClient</PackageId>
|
||||
<Authors>Jellyfin Contributors</Authors>
|
||||
<PackageTags>Jellyfin;Api;Client</PackageTags>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Description>Auto generated Api client for Jellyfin.</Description>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NSwag.MSBuild" Version="13.10.9">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Target Name="GenerateApiClientSourceCode" BeforeTargets="CoreCompile;PrepareResource">
|
||||
<Exec Command="$(NSwagExe_Net50) run nswag.json" />
|
||||
</Target>
|
||||
</Project>
|
29
unstable/SdkClientSettings.cs
Normal file
29
unstable/SdkClientSettings.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace Jellyfin.Sdk
|
||||
{
|
||||
/// <summary>
|
||||
/// The sdk client settings.
|
||||
/// </summary>
|
||||
public class SdkClientSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Jellyfin server's base url.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// https://demo.jellyfin.org/stable
|
||||
/// </example>
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user's access token.
|
||||
/// </summary>
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the default authorization header.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is used when the access token is not set.
|
||||
/// </remarks>
|
||||
public string DefaultAuthorizationHeader { get; set; }
|
||||
}
|
||||
}
|
100
unstable/nswag.json
Normal file
100
unstable/nswag.json
Normal file
@ -0,0 +1,100 @@
|
||||
{
|
||||
"runtime": "Net50",
|
||||
"defaultVariables": null,
|
||||
"documentGenerator": {
|
||||
"fromDocument": {
|
||||
"json": "",
|
||||
"url": "https://repo.jellyfin.org/releases/openapi/jellyfin-openapi-unstable.json",
|
||||
"output": null,
|
||||
"newLineBehavior": "Auto"
|
||||
}
|
||||
},
|
||||
"codeGenerators": {
|
||||
"openApiToCSharpClient": {
|
||||
"clientBaseClass": "BaseClient",
|
||||
"configurationClass": "SdkClientSettings",
|
||||
"generateClientClasses": true,
|
||||
"generateClientInterfaces": true,
|
||||
"clientBaseInterface": null,
|
||||
"injectHttpClient": true,
|
||||
"disposeHttpClient": false,
|
||||
"protectedMethods": [],
|
||||
"generateExceptionClasses": true,
|
||||
"exceptionClass": "{controller}Exception",
|
||||
"wrapDtoExceptions": true,
|
||||
"useHttpClientCreationMethod": false,
|
||||
"httpClientType": "System.Net.Http.HttpClient",
|
||||
"useHttpRequestMessageCreationMethod": false,
|
||||
"useBaseUrl": false,
|
||||
"generateBaseUrlProperty": false,
|
||||
"generateSyncMethods": false,
|
||||
"generatePrepareRequestAndProcessResponseAsAsyncMethods": true,
|
||||
"exposeJsonSerializerSettings": false,
|
||||
"clientClassAccessModifier": "public",
|
||||
"typeAccessModifier": "public",
|
||||
"generateContractsOutput": false,
|
||||
"contractsNamespace": null,
|
||||
"contractsOutputFilePath": null,
|
||||
"parameterDateTimeFormat": "s",
|
||||
"parameterDateFormat": "yyyy-MM-dd",
|
||||
"generateUpdateJsonSerializerSettingsMethod": true,
|
||||
"useRequestAndResponseSerializationSettings": false,
|
||||
"serializeTypeInformation": false,
|
||||
"queryNullValue": "",
|
||||
"className": "{controller}Client",
|
||||
"operationGenerationMode": "MultipleClientsFromFirstTagAndOperationId",
|
||||
"additionalNamespaceUsages": [],
|
||||
"additionalContractNamespaceUsages": [],
|
||||
"generateOptionalParameters": true,
|
||||
"generateJsonMethods": false,
|
||||
"enforceFlagEnums": false,
|
||||
"parameterArrayType": "System.Collections.Generic.IEnumerable",
|
||||
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"responseArrayType": "System.Collections.Generic.IReadOnlyList",
|
||||
"responseDictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"wrapResponses": false,
|
||||
"wrapResponseMethods": [],
|
||||
"generateResponseClasses": true,
|
||||
"responseClass": "SwaggerResponse",
|
||||
"namespace": "Jellyfin.Sdk",
|
||||
"requiredPropertiesMustBeDefined": true,
|
||||
"dateType": "System.DateTimeOffset",
|
||||
"jsonConverters": null,
|
||||
"anyType": "object",
|
||||
"dateTimeType": "System.DateTimeOffset",
|
||||
"timeType": "System.TimeSpan",
|
||||
"timeSpanType": "System.TimeSpan",
|
||||
"arrayType": "System.Collections.Generic.IReadOnlyList",
|
||||
"arrayInstanceType": "",
|
||||
"dictionaryType": "System.Collections.Generic.IDictionary",
|
||||
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
|
||||
"arrayBaseType": "System.Collections.Generic.IReadOnlyList",
|
||||
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
|
||||
"classStyle": "Poco",
|
||||
"jsonLibrary": "NewtonsoftJson",
|
||||
"generateDefaultValues": true,
|
||||
"generateDataAnnotations": true,
|
||||
"excludedTypeNames": [],
|
||||
"excludedParameterNames": [],
|
||||
"handleReferences": false,
|
||||
"generateImmutableArrayProperties": false,
|
||||
"generateImmutableDictionaryProperties": false,
|
||||
"jsonSerializerSettingsTransformationMethod": null,
|
||||
"inlineNamedArrays": false,
|
||||
"inlineNamedDictionaries": false,
|
||||
"inlineNamedTuples": true,
|
||||
"inlineNamedAny": false,
|
||||
"generateDtoTypes": true,
|
||||
"generateOptionalPropertiesAsNullable": false,
|
||||
"generateNullableReferenceTypes": false,
|
||||
"templateDirectory": null,
|
||||
"typeNameGeneratorType": null,
|
||||
"propertyNameGeneratorType": null,
|
||||
"enumNameGeneratorType": null,
|
||||
"serviceHost": ".",
|
||||
"serviceSchemes": null,
|
||||
"output": "JellyfinSdk.g.cs",
|
||||
"newLineBehavior": "Auto"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user