-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* further work will be needed if APIs diverge further
- Loading branch information
Showing
10 changed files
with
589 additions
and
129 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { KyHttpClient } from "../__generated__/ky-client"; | ||
import { MergedCustomFormatResource } from "../__generated__/mergedTypes"; | ||
import { Api } from "../__generated__/radarr/Api"; | ||
import { logger } from "../logger"; | ||
import { IArrClient, validateClientParams } from "./unified-client"; | ||
|
||
export class RadarrClient implements IArrClient { | ||
private api!: Api<unknown>; | ||
|
||
constructor(baseUrl: string, apiKey: string) { | ||
this.initialize(baseUrl, apiKey); | ||
} | ||
|
||
private initialize(baseUrl: string, apiKey: string) { | ||
validateClientParams(baseUrl, apiKey, "RADARR"); | ||
|
||
const httpClient = new KyHttpClient({ | ||
headers: { | ||
"X-Api-Key": apiKey, | ||
}, | ||
prefixUrl: baseUrl, | ||
}); | ||
|
||
this.api = new Api(httpClient); | ||
} | ||
|
||
// Quality Management | ||
getQualityDefinitions() { | ||
return this.api.v3QualitydefinitionList(); | ||
} | ||
|
||
updateQualityDefinitions(definitions: any) { | ||
return this.api.v3QualitydefinitionUpdateUpdate(definitions); | ||
} | ||
|
||
// Quality Profiles | ||
getQualityProfiles() { | ||
return this.api.v3QualityprofileList(); | ||
} | ||
|
||
createQualityProfile(profile: any) { | ||
return this.api.v3QualityprofileCreate(profile); | ||
} | ||
|
||
updateQualityProfile(id: string, profile: any) { | ||
return this.api.v3QualityprofileUpdate(id, profile); | ||
} | ||
|
||
// Custom Formats | ||
getCustomFormats() { | ||
return this.api.v3CustomformatList(); | ||
} | ||
|
||
createCustomFormat(format: MergedCustomFormatResource) { | ||
return this.api.v3CustomformatCreate(format); | ||
} | ||
|
||
updateCustomFormat(id: string, format: MergedCustomFormatResource) { | ||
return this.api.v3CustomformatUpdate(id, format); | ||
} | ||
|
||
deleteCustomFormat(id: string) { | ||
return this.api.v3CustomformatDelete(+id); | ||
} | ||
|
||
// Metadata Profiles | ||
async getMetadataProfiles() { | ||
throw new Error("Metadata profiles are not supported in Radarr"); | ||
} | ||
|
||
async createMetadataProfile(profile: any) { | ||
throw new Error("Metadata profiles are not supported in Radarr"); | ||
} | ||
|
||
async updateMetadataProfile(id: number, profile: any) { | ||
throw new Error("Metadata profiles are not supported in Radarr"); | ||
} | ||
|
||
// System/Health Check | ||
getSystemStatus() { | ||
return this.api.v3SystemStatusList(); | ||
} | ||
|
||
async testConnection() { | ||
try { | ||
await this.api.v3HealthList(); | ||
} catch (error) { | ||
logger.error(error); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { KyHttpClient } from "../__generated__/ky-client"; | ||
import { MergedCustomFormatResource } from "../__generated__/mergedTypes"; | ||
import { Api } from "../__generated__/readarr/Api"; | ||
import { logger } from "../logger"; | ||
import { IArrClient, validateClientParams } from "./unified-client"; | ||
|
||
export class ReadarrClient implements IArrClient { | ||
private api!: Api<unknown>; | ||
|
||
constructor(baseUrl: string, apiKey: string) { | ||
this.initialize(baseUrl, apiKey); | ||
} | ||
|
||
private initialize(baseUrl: string, apiKey: string) { | ||
validateClientParams(baseUrl, apiKey, "READARR"); | ||
|
||
const httpClient = new KyHttpClient({ | ||
headers: { | ||
"X-Api-Key": apiKey, | ||
}, | ||
prefixUrl: baseUrl, | ||
}); | ||
|
||
this.api = new Api(httpClient); | ||
} | ||
|
||
// Quality Management | ||
getQualityDefinitions() { | ||
return this.api.v1QualitydefinitionList(); | ||
} | ||
|
||
updateQualityDefinitions(definitions: any) { | ||
return this.api.v1QualitydefinitionUpdateUpdate(definitions); | ||
} | ||
|
||
// Quality Profiles | ||
getQualityProfiles() { | ||
return this.api.v1QualityprofileList(); | ||
} | ||
|
||
createQualityProfile(profile: any) { | ||
return this.api.v1QualityprofileCreate(profile); | ||
} | ||
|
||
updateQualityProfile(id: string, profile: any) { | ||
return this.api.v1QualityprofileUpdate(id, profile); | ||
} | ||
|
||
// Custom Formats | ||
getCustomFormats() { | ||
return this.api.v1CustomformatList(); | ||
} | ||
|
||
createCustomFormat(format: MergedCustomFormatResource) { | ||
return this.api.v1CustomformatCreate(format); | ||
} | ||
|
||
updateCustomFormat(id: string, format: MergedCustomFormatResource) { | ||
return this.api.v1CustomformatUpdate(id, format); | ||
} | ||
|
||
deleteCustomFormat(id: string) { | ||
return this.api.v1CustomformatDelete(+id); | ||
} | ||
|
||
// Metadata Profiles | ||
async getMetadataProfiles() { | ||
return this.api.v1MetadataprofileList(); | ||
} | ||
|
||
async createMetadataProfile(profile: any) { | ||
return this.api.v1MetadataprofileCreate(profile); | ||
} | ||
|
||
async updateMetadataProfile(id: number, profile: any) { | ||
return this.api.v1MetadataprofileUpdate(id.toString(), profile); | ||
} | ||
|
||
// System/Health Check | ||
getSystemStatus() { | ||
return this.api.v1SystemStatusList(); | ||
} | ||
|
||
async testConnection() { | ||
try { | ||
await this.api.v1HealthList(); | ||
} catch (error) { | ||
logger.error(error); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { KyHttpClient } from "../__generated__/ky-client"; | ||
import { MergedCustomFormatResource } from "../__generated__/mergedTypes"; | ||
import { Api } from "../__generated__/sonarr/Api"; | ||
import { logger } from "../logger"; | ||
import { IArrClient, validateClientParams } from "./unified-client"; | ||
|
||
export class SonarrClient implements IArrClient { | ||
private api!: Api<unknown>; | ||
|
||
constructor(baseUrl: string, apiKey: string) { | ||
this.initialize(baseUrl, apiKey); | ||
} | ||
|
||
private initialize(baseUrl: string, apiKey: string) { | ||
validateClientParams(baseUrl, apiKey, "SONARR"); | ||
|
||
const httpClient = new KyHttpClient({ | ||
headers: { | ||
"X-Api-Key": apiKey, | ||
}, | ||
prefixUrl: baseUrl, | ||
}); | ||
|
||
this.api = new Api(httpClient); | ||
} | ||
|
||
// Quality Management | ||
getQualityDefinitions() { | ||
return this.api.v3QualitydefinitionList(); | ||
} | ||
|
||
updateQualityDefinitions(definitions: any) { | ||
return this.api.v3QualitydefinitionUpdateUpdate(definitions); | ||
} | ||
|
||
// Quality Profiles | ||
getQualityProfiles() { | ||
return this.api.v3QualityprofileList(); | ||
} | ||
|
||
createQualityProfile(profile: any) { | ||
return this.api.v3QualityprofileCreate(profile); | ||
} | ||
|
||
updateQualityProfile(id: string, profile: any) { | ||
return this.api.v3QualityprofileUpdate(id, profile); | ||
} | ||
|
||
// Custom Formats | ||
getCustomFormats() { | ||
return this.api.v3CustomformatList(); | ||
} | ||
|
||
createCustomFormat(format: MergedCustomFormatResource) { | ||
return this.api.v3CustomformatCreate(format); | ||
} | ||
|
||
updateCustomFormat(id: string, format: MergedCustomFormatResource) { | ||
return this.api.v3CustomformatUpdate(id, format); | ||
} | ||
|
||
deleteCustomFormat(id: string) { | ||
return this.api.v3CustomformatDelete(+id); | ||
} | ||
|
||
// Metadata Profiles | ||
async getMetadataProfiles() { | ||
throw new Error("Metadata profiles are not supported in Sonarr"); | ||
} | ||
|
||
async createMetadataProfile(profile: any) { | ||
throw new Error("Metadata profiles are not supported in Sonarr"); | ||
} | ||
|
||
async updateMetadataProfile(id: number, profile: any) { | ||
throw new Error("Metadata profiles are not supported in Sonarr"); | ||
} | ||
|
||
// System/Health Check | ||
getSystemStatus() { | ||
return this.api.v3SystemStatusList(); | ||
} | ||
|
||
async testConnection() { | ||
try { | ||
await this.api.v3HealthList(); | ||
} catch (error) { | ||
logger.error(error); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.