Skip to content

Commit

Permalink
Merge pull request #4786 from navikt/feature/pdfgen
Browse files Browse the repository at this point in the history
Feature/pdfgen
  • Loading branch information
sondrele authored Dec 12, 2024
2 parents ef3c957 + ee68fcd commit 8efccbc
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 254 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-pdfgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import io.ktor.client.engine.*
import io.ktor.client.engine.cio.*
import no.nav.mulighetsrommet.altinn.AltinnClient
import no.nav.mulighetsrommet.api.avtale.task.NotifySluttdatoForAvtalerNarmerSeg
import no.nav.mulighetsrommet.api.clients.brreg.BrregClient
import no.nav.mulighetsrommet.api.clients.sanity.SanityClient
import no.nav.mulighetsrommet.api.datavarehus.kafka.DatavarehusTiltakV1KafkaProducer
import no.nav.mulighetsrommet.api.gjennomforing.kafka.ArenaMigreringTiltaksgjennomforingerV1KafkaProducer
Expand All @@ -23,7 +22,6 @@ import no.nav.mulighetsrommet.database.FlywayMigrationManager
import no.nav.mulighetsrommet.kafka.KafkaTopicConsumer
import no.nav.mulighetsrommet.ktor.ServerConfig
import no.nav.mulighetsrommet.unleash.UnleashService
import no.nav.mulighetsrommet.utdanning.client.UtdanningClient
import no.nav.mulighetsrommet.utdanning.task.SynchronizeUtdanninger
import java.util.*

Expand All @@ -38,28 +36,28 @@ data class AppConfig(
val kafka: KafkaConfig,
val auth: AuthConfig,
val sanity: SanityClient.Config,
val veilarboppfolgingConfig: ServiceClientConfig,
val veilarbvedtaksstotteConfig: ServiceClientConfig,
val veilarbdialogConfig: ServiceClientConfig,
val amtDeltakerConfig: ServiceClientConfig,
val poaoTilgang: ServiceClientConfig,
val arenaAdapter: ServiceClientConfig,
val tiltakshistorikk: ServiceClientConfig,
val pdfgen: ServiceClientConfig,
val msGraphConfig: ServiceClientConfig,
val isoppfolgingstilfelleConfig: ServiceClientConfig,
val norg2: Norg2Config,
val veilarboppfolgingConfig: AuthenticatedHttpClientConfig,
val veilarbvedtaksstotteConfig: AuthenticatedHttpClientConfig,
val veilarbdialogConfig: AuthenticatedHttpClientConfig,
val amtDeltakerConfig: AuthenticatedHttpClientConfig,
val poaoTilgang: AuthenticatedHttpClientConfig,
val arenaAdapter: AuthenticatedHttpClientConfig,
val tiltakshistorikk: AuthenticatedHttpClientConfig,
val pdfgen: HttpClientConfig,
val msGraphConfig: AuthenticatedHttpClientConfig,
val isoppfolgingstilfelleConfig: AuthenticatedHttpClientConfig,
val norg2: HttpClientConfig,
val tasks: TaskConfig,
val slack: SlackConfig,
val brreg: BrregClient.Config,
val pamOntologi: ServiceClientConfig,
val brreg: HttpClientConfig,
val pamOntologi: AuthenticatedHttpClientConfig,
val unleash: UnleashService.Config,
val axsys: ServiceClientConfig,
val pdl: ServiceClientConfig,
val axsys: AuthenticatedHttpClientConfig,
val pdl: AuthenticatedHttpClientConfig,
val engine: HttpClientEngine = CIO.create(),
val utdanning: UtdanningClient.Config,
val utdanning: HttpClientConfig,
val altinn: AltinnClient.Config,
val dokark: ServiceClientConfig,
val dokark: AuthenticatedHttpClientConfig,
)

data class AuthConfig(
Expand Down Expand Up @@ -107,11 +105,15 @@ data class AuthProvider(
val tokenEndpointUrl: String,
)

data class ServiceClientConfig(
data class AuthenticatedHttpClientConfig(
val url: String,
val scope: String,
)

data class HttpClientConfig(
val url: String,
)

data class TaskConfig(
val synchronizeNorgEnheter: SynchronizeNorgEnheter.Config,
val synchronizeNavAnsatte: SynchronizeNavAnsatte.Config,
Expand All @@ -124,10 +126,6 @@ data class TaskConfig(
val generateRefusjonskrav: GenerateRefusjonskrav.Config,
)

data class Norg2Config(
val baseUrl: String,
)

data class SlackConfig(
val token: String,
val channel: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import arrow.core.left
import arrow.core.right
import io.ktor.client.call.*
import io.ktor.client.engine.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.cache.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
Expand All @@ -26,20 +25,13 @@ object OrgnummerUtil {
}
}

class BrregClient(
private val baseUrl: String,
clientEngine: HttpClientEngine,
) {
class BrregClient(clientEngine: HttpClientEngine, private val baseUrl: String) {
private val log = LoggerFactory.getLogger(javaClass)

private val client = httpJsonClient(clientEngine).config {
install(HttpCache)
}

data class Config(
val baseUrl: String,
)

suspend fun getBrregVirksomhet(orgnr: Organisasjonsnummer): Either<BrregError, BrregVirksomhetDto> {
// Sjekker først hovedenhet
return getHovedenhet(orgnr).fold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.Serializable
import no.nav.mulighetsrommet.api.refusjon.model.RefusjonKravAft
import no.nav.mulighetsrommet.api.tilsagn.model.ArrangorflateTilsagn
import no.nav.mulighetsrommet.tokenprovider.AccessType
import no.nav.mulighetsrommet.tokenprovider.TokenProvider

class PdfGenClient(
clientEngine: HttpClientEngine = CIO.create(),
private val baseUrl: String,
private val tokenProvider: TokenProvider,
) {
private val client = HttpClient(clientEngine) {
install(ContentNegotiation) {
Expand Down Expand Up @@ -57,7 +54,6 @@ class PdfGenClient(
return client
.post {
url("$baseUrl/api/v1/genpdf/$app/$template")
bearerAuth(tokenProvider.exchange(AccessType.M2M))
contentType(ContentType.Application.Json)
setBody(body)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ private fun services(appConfig: AppConfig) = module {
PdfGenClient(
clientEngine = appConfig.engine,
baseUrl = appConfig.pdfgen.url,
tokenProvider = cachedTokenProvider.withScope(appConfig.pdfgen.scope),
)
}
single {
Expand Down Expand Up @@ -319,7 +318,7 @@ private fun services(appConfig: AppConfig) = module {
single {
Norg2Client(
clientEngine = appConfig.engine,
baseUrl = appConfig.norg2.baseUrl,
baseUrl = appConfig.norg2.url,
)
}
single {
Expand All @@ -329,7 +328,7 @@ private fun services(appConfig: AppConfig) = module {
}
single { SanityService(get()) }
single {
BrregClient(baseUrl = appConfig.brreg.baseUrl, clientEngine = appConfig.engine)
BrregClient(clientEngine = appConfig.engine, baseUrl = appConfig.brreg.url)
}
single {
AmtDeltakerClient(
Expand All @@ -345,7 +344,7 @@ private fun services(appConfig: AppConfig) = module {
tokenProvider = cachedTokenProvider.withScope(appConfig.pamOntologi.scope),
)
}
single { UtdanningClient(config = appConfig.utdanning) }
single { UtdanningClient(baseUrl = appConfig.utdanning.url) }
single {
AltinnClient(
baseUrl = appConfig.altinn.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import no.nav.mulighetsrommet.ktor.clients.httpJsonClient

class UtdanningClient(engine: HttpClientEngine = CIO.create(), val config: Config) {
data class Config(
val baseUrl: String,
)

class UtdanningClient(engine: HttpClientEngine = CIO.create(), val baseUrl: String) {
private val client: HttpClient = httpJsonClient(engine)

suspend fun getUtdanninger(): List<UtdanningNoProgramomraade> {
val response = client.get("${config.baseUrl}/nav_export/programomraader")
val response = client.get("$baseUrl/nav_export/programomraader")
return response.body()
}
}
Expand Down
75 changes: 37 additions & 38 deletions mulighetsrommet-api/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ app:
id: amt-arrangor-melding
topic: amt.arrangor-melding-v1

tasks:
synchronizeNorgEnheter:
delayOfMinutes: 360 # Hver 6. time
synchronizeNavAnsatte:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
synchronizeUtdanninger:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifySluttdatoForGjennomforingerNarmerSeg:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifySluttdatoForAvtalerNarmerSeg:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifyFailedKafkaEvents:
maxRetries: 5
cronPattern: "0 */15 * ? * MON-FRI"
generateValidationReport:
bucketName: mulighetsrommet-api-uploads-dev
updateApentForPamelding:
disabled: false
cronPattern: "0 55 23 * * *" # 23.55 hver kveld
generateRefusjonskrav:
cronPattern: "0 0 5 7 * *"

auth:
azure:
issuer: ${AZURE_OPENID_CONFIG_ISSUER}
Expand Down Expand Up @@ -87,6 +109,18 @@ app:
projectId: ${SANITY_PROJECT_ID}
token: ${SANITY_AUTH_TOKEN}

slack:
token: ${SLACK_TOKEN}
channel: "#team-valp-monitorering-dev"
enable: true

unleash:
appName: ${NAIS_APP_NAME}
url: ${UNLEASH_SERVER_API_URL}
token: ${UNLEASH_SERVER_API_TOKEN}
instanceId: ${NAIS_CLIENT_ID}
environment: development

veilarbvedtaksstotteConfig:
url: http://veilarbvedtaksstotte.obo/veilarbvedtaksstotte/api
scope: api://dev-gcp.obo.veilarbvedtaksstotte/.default
Expand Down Expand Up @@ -121,7 +155,6 @@ app:

pdfgen:
url: http://pdfgen
scope: api://dev-gcp.team-mulighetsrommet.pdfgen/.default

axsys:
url: https://axsys.dev-fss-pub.nais.io
Expand All @@ -140,53 +173,19 @@ app:
scope: api://dev-gcp.teamsykefravr.isoppfolgingstilfelle/.default

norg2:
baseUrl: http://norg2.org
url: http://norg2.org

brreg:
baseUrl: https://data.brreg.no/enhetsregisteret/api
url: https://data.brreg.no/enhetsregisteret/api

altinn:
url: https://platform.tt02.altinn.no
apiKey: ${ALTINN_API_KEY}
scope: ${MASKINPORTEN_SCOPES}

utdanning:
baseurl: https://api.utdanning.no
url: https://api.utdanning.no

dokark:
url: https://dokarkiv-q2.dev-fss-pub.nais.io
scope: api://dev-fss.teamdokumenthandtering.dokarkiv/.default

tasks:
synchronizeNorgEnheter:
delayOfMinutes: 360 # Hver 6. time
synchronizeNavAnsatte:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
synchronizeUtdanninger:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifySluttdatoForGjennomforingerNarmerSeg:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifySluttdatoForAvtalerNarmerSeg:
cronPattern: "0 0 6 * * *" # Hver morgen kl. 06:00
notifyFailedKafkaEvents:
maxRetries: 5
cronPattern: "0 */15 * ? * MON-FRI"
generateValidationReport:
bucketName: mulighetsrommet-api-uploads-dev
updateApentForPamelding:
disabled: false
cronPattern: "0 55 23 * * *" # 23.55 hver kveld
generateRefusjonskrav:
cronPattern: "0 0 5 7 * *"

slack:
token: ${SLACK_TOKEN}
channel: "#team-valp-monitorering-dev"
enable: true

unleash:
appName: ${NAIS_APP_NAME}
url: ${UNLEASH_SERVER_API_URL}
token: ${UNLEASH_SERVER_API_TOKEN}
instanceId: ${NAIS_CLIENT_ID}
environment: development
Loading

0 comments on commit 8efccbc

Please sign in to comment.