mirror of
https://github.com/C9Glax/tranga.git
synced 2025-02-23 15:50:13 +01:00
GET LibraryTypes Create and Test set url to lowercase
Set Komga to also require username and password
This commit is contained in:
parent
9d47445339
commit
96b5921ed6
@ -39,24 +39,22 @@ public partial class Server
|
|||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!requestParameters.TryGetValue("URL", out string? url))
|
if(!requestParameters.TryGetValue("url", out string? url))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||||
|
|
||||||
switch (libraryType)
|
|
||||||
{
|
|
||||||
case LibraryConnector.LibraryType.Kavita:
|
|
||||||
if(!requestParameters.TryGetValue("username", out string? username))
|
if(!requestParameters.TryGetValue("username", out string? username))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||||
if(!requestParameters.TryGetValue("password", out string? password))
|
if(!requestParameters.TryGetValue("password", out string? password))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
||||||
|
|
||||||
|
switch (libraryType)
|
||||||
|
{
|
||||||
|
case LibraryConnector.LibraryType.Kavita:
|
||||||
Kavita kavita = new (this, url, username, password);
|
Kavita kavita = new (this, url, username, password);
|
||||||
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Kavita);
|
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Kavita);
|
||||||
libraryConnectors.Add(kavita);
|
libraryConnectors.Add(kavita);
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, kavita);
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, kavita);
|
||||||
case LibraryConnector.LibraryType.Komga:
|
case LibraryConnector.LibraryType.Komga:
|
||||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
Komga komga = new (this, url, username, password);
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
|
||||||
Komga komga = new (this, url, auth);
|
|
||||||
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Komga);
|
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Komga);
|
||||||
libraryConnectors.Add(komga);
|
libraryConnectors.Add(komga);
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga);
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga);
|
||||||
@ -72,16 +70,16 @@ public partial class Server
|
|||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!requestParameters.TryGetValue("URL", out string? url))
|
if(!requestParameters.TryGetValue("url", out string? url))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||||
|
|
||||||
switch (libraryType)
|
|
||||||
{
|
|
||||||
case LibraryConnector.LibraryType.Kavita:
|
|
||||||
if(!requestParameters.TryGetValue("username", out string? username))
|
if(!requestParameters.TryGetValue("username", out string? username))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||||
if(!requestParameters.TryGetValue("password", out string? password))
|
if(!requestParameters.TryGetValue("password", out string? password))
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
||||||
|
|
||||||
|
switch (libraryType)
|
||||||
|
{
|
||||||
|
case LibraryConnector.LibraryType.Kavita:
|
||||||
Kavita kavita = new (this, url, username, password);
|
Kavita kavita = new (this, url, username, password);
|
||||||
return kavita.Test() switch
|
return kavita.Test() switch
|
||||||
{
|
{
|
||||||
@ -89,9 +87,7 @@ public partial class Server
|
|||||||
_ => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.FailedDependency, kavita)
|
_ => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.FailedDependency, kavita)
|
||||||
};
|
};
|
||||||
case LibraryConnector.LibraryType.Komga:
|
case LibraryConnector.LibraryType.Komga:
|
||||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
Komga komga = new (this, url, username, password);
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
|
||||||
Komga komga = new (this, url, auth);
|
|
||||||
return komga.Test() switch
|
return komga.Test() switch
|
||||||
{
|
{
|
||||||
true => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga),
|
true => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga),
|
||||||
|
@ -804,22 +804,10 @@ Creates a Library-Connector of the specified Type.
|
|||||||
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
||||||
|
|
||||||
| Parameter | Value |
|
| Parameter | Value |
|
||||||
|-------------|--------------------|
|
|-----------|--------------------|
|
||||||
| URL | URL of the Library |
|
| url | URL of the Library |
|
||||||
|
| username | Username |
|
||||||
#### Type specific Parameters (must be included for each)
|
| password | Password |
|
||||||
* Komga
|
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|-----------|-------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| auth | [Base64 encoded Basic-Authentication-String](https://datatracker.ietf.org/doc/html/rfc7617) (`username:password`) |
|
|
||||||
|
|
||||||
* Kavita
|
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|-----------|-----------------|
|
|
||||||
| username | Kavita Username |
|
|
||||||
| password | Kavita Password |
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -844,22 +832,10 @@ Tests a Library-Connector of the specified Type.
|
|||||||
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
||||||
|
|
||||||
| Parameter | Value |
|
| Parameter | Value |
|
||||||
|-------------|--------------------|
|
|-----------|--------------------|
|
||||||
| URL | URL of the Library |
|
| url | URL of the Library |
|
||||||
|
| username | Username |
|
||||||
#### Type specific Parameters (must be included for each)
|
| password | Password |
|
||||||
* Komga
|
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|-----------|-------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| auth | [Base64 encoded Basic-Authentication-String](https://datatracker.ietf.org/doc/html/rfc7617) (`username:password`) |
|
|
||||||
|
|
||||||
* Kavita
|
|
||||||
|
|
||||||
| Parameter | Value |
|
|
||||||
|-----------|-----------------|
|
|
||||||
| username | Kavita Username |
|
|
||||||
| password | Kavita Password |
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user