-
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.
Merge pull request #4782 from navikt/feature/pdfgen
Feature/pdfgen
- Loading branch information
Showing
42 changed files
with
512 additions
and
337 deletions.
There are no files selected for viewing
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,76 @@ | ||
name: Deploy pdfgen | ||
|
||
on: | ||
push: | ||
paths: | ||
- .github/workflows/deploy-pdfgen.yaml | ||
- mulighetsrommet-pdfgen/** | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
type: choice | ||
description: Environment | ||
required: true | ||
default: dev | ||
options: | ||
- dev | ||
- dev_and_prod | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Lint | ||
uses: ./.github/actions/lint-yaml | ||
with: | ||
path: mulighetsrommet-pdfgen/.nais | ||
- name: docker-build-push | ||
uses: nais/docker-build-push@v0 | ||
id: docker-build-push | ||
if: github.event_name == 'push' && github.ref_name == 'main' || github.event_name == 'workflow_dispatch' | ||
with: | ||
team: team-mulighetsrommet | ||
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | ||
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | ||
docker_context: mulighetsrommet-pdfgen | ||
image_suffix: pdfgen | ||
|
||
deploy-dev: | ||
name: Deploy (dev) | ||
runs-on: ubuntu-latest | ||
needs: [ci] | ||
if: github.event_name == 'push' && github.ref_name == 'main' || github.event_name == 'workflow_dispatch' | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Deploy | ||
uses: nais/deploy/actions/deploy@v2 | ||
env: | ||
CLUSTER: dev-gcp | ||
RESOURCE: mulighetsrommet-pdfgen/.nais/nais-dev.yaml | ||
VAR: image=${{ needs.ci.outputs.image }} | ||
|
||
deploy-prod: | ||
name: Deploy (prod) | ||
runs-on: ubuntu-latest | ||
needs: [ci, deploy-dev] | ||
if: github.event_name == 'push' && github.ref_name == 'main' || github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'dev_and_prod' | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Deploy | ||
uses: nais/deploy/actions/deploy@v2 | ||
env: | ||
CLUSTER: prod-gcp | ||
RESOURCE: mulighetsrommet-pdfgen/.nais/nais-prod.yaml | ||
VAR: image=${{ needs.ci.outputs.image }} |
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
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
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
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
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
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
66 changes: 66 additions & 0 deletions
66
mulighetsrommet-api/src/main/kotlin/no/nav/mulighetsrommet/api/pdfgen/PdfGenClient.kt
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,66 @@ | ||
package no.nav.mulighetsrommet.api.pdfgen | ||
|
||
import io.ktor.client.* | ||
import io.ktor.client.engine.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.client.request.* | ||
import io.ktor.client.statement.* | ||
import io.ktor.http.* | ||
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) { | ||
json() | ||
} | ||
} | ||
|
||
suspend fun getRefusjonKvittering(refusjon: RefusjonKravAft, tilsagn: List<ArrangorflateTilsagn>): ByteArray { | ||
@Serializable | ||
data class PdfData( | ||
val refusjon: RefusjonKravAft, | ||
val tilsagn: List<ArrangorflateTilsagn>, | ||
) | ||
|
||
return downloadPdf( | ||
app = "refusjon", | ||
template = "kvittering", | ||
body = PdfData(refusjon, tilsagn), | ||
) | ||
} | ||
|
||
suspend fun refusjonJournalpost(refusjon: RefusjonKravAft, tilsagn: List<ArrangorflateTilsagn>): ByteArray { | ||
@Serializable | ||
data class PdfData( | ||
val refusjon: RefusjonKravAft, | ||
val tilsagn: List<ArrangorflateTilsagn>, | ||
) | ||
|
||
return downloadPdf( | ||
app = "refusjon", | ||
template = "journalpost", | ||
body = PdfData(refusjon, tilsagn), | ||
) | ||
} | ||
|
||
private suspend inline fun <reified T> downloadPdf(app: String, template: String, body: T): ByteArray { | ||
return client | ||
.post { | ||
url("$baseUrl/api/v1/genpdf/$app/$template") | ||
bearerAuth(tokenProvider.exchange(AccessType.M2M)) | ||
contentType(ContentType.Application.Json) | ||
setBody(body) | ||
} | ||
.bodyAsBytes() | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
mulighetsrommet-api/src/main/kotlin/no/nav/mulighetsrommet/api/pdfgen/Pdfgen.kt
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
Oops, something went wrong.