Add module for seerr api

This commit is contained in:
Damontecres 2025-12-01 19:25:42 -05:00
parent e0d50baf15
commit 2cc762a5b8
No known key found for this signature in database
8 changed files with 7869 additions and 2 deletions

1
seerr-api/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -0,0 +1,51 @@
plugins {
id("java-library")
alias(libs.plugins.kotlin.jvm)
id("org.openapi.generator") version "7.17.0"
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
}
sourceSets {
main {
kotlin.srcDirs("$buildDir/generated/seerr_api/src/main/kotlin")
}
}
}
openApiGenerate {
generatorName.set("kotlin")
inputSpec.set("$projectDir/src/main/seerr-api.yml")
outputDir.set("$buildDir/generated/seerr_api")
apiPackage.set("com.github.damontecres.api.seerr")
modelPackage.set("com.github.damontecres.api.seerr.model")
groupId.set("com.github.damontecres.api.seerr")
id.set("seerr-api")
packageName.set("com.github.damontecres.api.seerr")
additionalProperties.apply {
put("serializationLibrary", "kotlinx_serialization")
put("sortModelPropertiesByRequiredFlag", true)
put("sortParamsByRequiredFlag", true)
put("useCoroutines", true)
put("enumPropertyNaming", "UPPERCASE")
put("modelMutable", false)
}
}
tasks.named("compileKotlin") {
dependsOn.add(tasks.named("openApiGenerate"))
}
dependencies {
implementation(platform(libs.okhttp.bom))
implementation(libs.okhttp)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.coroutines.core)
}

View file

@ -0,0 +1,48 @@
package com.github.damontecres.api.seerr
import com.github.damontecres.api.seerr.infrastructure.ApiClient
import okhttp3.Call
import okhttp3.OkHttpClient
class SeerrApiClient(
val baseUrl: String,
val apiKey: String,
okHttpClient: OkHttpClient,
) {
private val client =
okHttpClient
.newBuilder()
.addInterceptor {
it.proceed(
it
.request()
.newBuilder()
.header("X-Api-Key", apiKey)
.build(),
)
}.build()
private fun <T : ApiClient> create(initializer: (String, Call.Factory) -> T): Lazy<T> =
lazy {
initializer.invoke(baseUrl, client)
}
val authApi by create(::AuthApi)
val blacklistApi by create(::BlacklistApi)
val collectionApi by create(::CollectionApi)
val issueApi by create(::IssueApi)
val mediaApi by create(::MediaApi)
val moviesApi by create(::MoviesApi)
val otherApi by create(::OtherApi)
val overrideruleApi by create(::OverrideruleApi)
val personApi by create(::PersonApi)
val publicApi by create(::PublicApi)
val requestApi by create(::RequestApi)
val searchApi by create(::SearchApi)
val serviceApi by create(::ServiceApi)
val settingsApi by create(::SettingsApi)
val tmdbApi by create(::TmdbApi)
val tvApi by create(::TvApi)
val usersApi by create(::UsersApi)
val watchlistApi by create(::WatchlistApi)
}

File diff suppressed because it is too large Load diff