Skip to content

Commit

Permalink
Merge pull request #4 from pagopa/PPANTT-80-feat-add-psp-api
Browse files Browse the repository at this point in the history
[PPANTT-80] feat: add psp api
  • Loading branch information
alessio-cialini authored Sep 24, 2024
2 parents 9a9e938 + 370477e commit cb7da5a
Show file tree
Hide file tree
Showing 32 changed files with 1,732 additions and 121 deletions.
135 changes: 80 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,120 @@
# Template for Quarkus Microservice project
# pagoPA Payment Options Service

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TODO-set-your-id&metric=alert_status)](https://sonarcloud.io/dashboard?id=TODO-set-your-id)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pagopa_pagopa-payment-options-service&metric=alert_status)](https://sonarcloud.io/dashboard?id=pagopa_pagopa-payment-options-service)

## TODO List
- Add a description
- Generate an index with this tool: https://ecotrust-canada.github.io/markdown-toc/
- Find and solve all the TODOs in this template (e.g. in `.github` folder, `pom.xml` and so on)
Expose APIs that will be used by IO to retrieve the PDF receipts

---
## API Documentation 📖
See the [OpenAPI 3 here.](https://raw.githubusercontent.com/pagopa/pagopa-quarkus-template/openapi/openapi.json)

---
## Summary 📖

- [Api Documentation 📖](#api-documentation-)
- [Technology Stack 📚](#technology-stack-)
- [Start Project Locally 🚀](#start-project-locally-)
* [Run locally with Docker](#run-locally-with-docker)
+ [Prerequisites](#prerequisites)
+ [Run docker container](#run-docker-container)
* [Running the application in dev mode](#running-the-application-in-dev-mode)
- [Develop Locally 💻](#develop-locally-)
* [Prerequisites](#prerequisites)
* [Testing 🧪](#testing-)
+ [Unit test](#unit-test)
+ [Integration test [WIP]](#integration-test-wip)
+ [Performance test [WIP]](#performance-test-wip)
- [Contributors 👥](#contributors-)
* [Maintainers](#maintainers)

## Technology Stack
- Java 11
- Quarkus
- other...
---

## Running the infrastructure 🚀
## Api Documentation 📖

### Prerequisites
- docker
- docker-compose
See
the [OpenApi 3 here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/pagopa/pagopa-payment-options-service/main/openapi/openapi.json)

### Run docker container
The docker compose runs:
- ELK
- elasticsearch
- logstash
- [kibana](http://localhost:5601/)
- Monitoring
- alertmanager
- [prometheus](http://localhost:9090/),
- [grafana](http://localhost:3000/) (user: ```admin```, password: ```admin```)
- Tracing
- otel-collector
- [jaeger](http://localhost:16686/)
In local env typing following url on browser for ui interface:

```http://localhost:8080/q/swagger-ui```

To run locally, from the main directory, execute
`sh run-local-infra.sh <project-name>`
or that for `yaml` version ```http://localhost:8080/q/openapi```

or that for `json` version ```http://localhost:8080/q/openapi?format=json```

---

From `./docker` directory
`sh ./run_docker.sh local|dev|uat|prod`
## Technology Stack 📚

ℹ️ Note: for PagoPa ACR is required the login `az acr login -n <acr-name>`
- Java 17 Runtime Environment GraalVM CE
- [Quarkus](https://quarkus.io/)
- quarkus-resteasy-reactive
- quarkus-smallrye-health
- quarkus-smallrye-openapi
- quarkus-resteasy-reactive-jackson
- reactor-netty
- lombok (provided)

---

## Develop Locally 💻
## Start Project Locally 🚀

### Prerequisites
- git
- maven
- jdk-11
### Running the application in dev mode

### Run the project
You can run your application in dev mode that enables live coding using:

Start the springboot application with this command:
```shell script
./mvnw compile quarkus:dev
```

`mvn spring-boot:run -Dspring-boot.run.profiles=local`
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only
> at http://localhost:8080/q/dev/.
### Run locally with Docker

#### Prerequisites

### Spring Profiles
- docker

- **local**: to develop locally.
- _default (no profile set)_: The application gets the properties from the environment (for Azure).
#### Set environment variables

`docker build -t pagopa-payments-option-service .`

### Testing 🧪
`cp .env.example .env`

and replace in `.env` with correct values

#### Unit testing
#### Run docker container

To run the **Junit** tests:
then type :

`mvn clean verify`
`docker run -p 8080:8080 --env-file=./.env pagopa-payment-options-service`

#### Integration testing
Add integration test in `.integration-test` and write here how to execute them
## Develop Locally 💻

### Prerequisites

- git
- maven (v3.9.3)
- jdk-17

### Testing 🧪

#### Unit test

Typing `mvn clean verify`

#### Performance testing
Add performance test using [k6](https://k6.io/) in `.performance-test` and write here how to execute them (e.g. `k6 run --env VARS=local.environment.json --env TEST_TYPE=./test-types/load.json main_scenario.js`)
#### Integration test [WIP]

- Run the application
- Install dependencies: `yarn install`
- Run the test: `yarn test`

#### Performance test [WIP]

---

## Contributors 👥

Made with ❤️ by PagoPa S.p.A.

### Mainteiners
### Maintainers

See `CODEOWNERS` file
55 changes: 55 additions & 0 deletions infra/04_apim_api.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
locals {
apim_payment_options = {
// GPD Payments Pull
display_name = "Payments Options"
description = "API for Payments Options"
path = "/payment-options/service"
subscription_required = true
service_url = null
}
host = "api.${var.apim_dns_zone_prefix}.${var.external_domain}"
hostname = var.hostname
}

##############
## Api Vers ##
##############

resource "azurerm_api_management_api_version_set" "api_payment_options_service" {

name = format("%s-gpd-payment-options-service-api", var.env_short)
resource_group_name = local.apim.rg
api_management_name = local.apim.name
display_name = local.apim_payment_options.display_name
versioning_scheme = "Segment"
}

##############
## OpenApi ##
##############

module "apim_payment_options_api_v1" {
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.4.1"

name = format("%s-payment-options-service-api", var.env_short)
api_management_name = local.apim.name
resource_group_name = local.apim.rg
product_ids = [local.apim.gpd_payments_pull_product_id]
subscription_required = local.api_payment_options_service.subscription_required
version_set_id = azurerm_api_management_api_version_set.api_payment_options_service.id
api_version = "v1"

description = local.apim_payment_options.description
display_name = local.apim_payment_options.display_name
path = local.apim_payment_options.path
protocols = ["https"]
service_url = local.apim_payment_options.service_url

content_format = "openapi"
content_value = file("../openapi/openapi.json")

xml_content = templatefile("./policy/_base_policy.xml", {
hostname = local.hostname
})

}
10 changes: 10 additions & 0 deletions infra/99_locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
locals {
product = "${var.prefix}-${var.env_short}"

apim = {
name = "${local.product}-apim"
rg = "${local.product}-api-rg"
payments_options_product_id = "payment-options"
}
}

28 changes: 28 additions & 0 deletions infra/99_main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.30.0"
}
azuread = {
source = "hashicorp/azuread"
version = "2.30.0"
}
azapi = {
source = "Azure/azapi"
version = "= 1.3.0"
}
}

backend "azurerm" {}
}

provider "azurerm" {
features {}
}

provider "azapi" {}

data "azurerm_subscription" "current" {}

data "azurerm_client_config" "current" {}
50 changes: 50 additions & 0 deletions infra/99_variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# general

variable "prefix" {
type = string
validation {
condition = (
length(var.prefix) <= 6
)
error_message = "Max length is 6 chars."
}
}

variable "env" {
type = string
}

variable "env_short" {
type = string
validation {
condition = (
length(var.env_short) == 1
)
error_message = "Length must be 1 chars."
}
}

variable "tags" {
type = map(any)
default = {
CreatedBy = "Terraform"
}
}

variable "apim_dns_zone_prefix" {
type = string
default = null
description = "The dns subdomain for apim."
}

variable "external_domain" {
type = string
default = null
description = "Domain for delegation"
}

variable "hostname" {
type = string
default = null
description = "Hostname for the API"
}
1 change: 1 addition & 0 deletions infra/env/itn-dev/backend.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subscription=DEV-pagoPA
4 changes: 4 additions & 0 deletions infra/env/itn-dev/backend.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource_group_name = "io-infra-rg"
storage_account_name = "pagopainfraterraformdev"
container_name = "azurermstate"
key = "pagopa-payment-options-service.infra.tfstate"
15 changes: 15 additions & 0 deletions infra/env/itn-dev/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
prefix = "pagopa"
env = "dev"
env_short = "d"

tags = {
CreatedBy = "Terraform"
Environment = "Dev"
Owner = "pagoPA"
Source = "https://github.com/pagopa/pagopa-payment-options-service"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

apim_dns_zone_prefix = "dev.platform"
external_domain = "pagopa.it"
hostname = "itndev.paymentoptions.internal.dev.platform.pagopa.it"
1 change: 1 addition & 0 deletions infra/env/itn-prod/backend.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subscription=PROD-pagoPA
4 changes: 4 additions & 0 deletions infra/env/itn-prod/backend.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource_group_name = "io-infra-rg"
storage_account_name = "pagopainfraterraformprod"
container_name = "azurermstate"
key = "pagopa-payment-options-service.infra.tfstate"
15 changes: 15 additions & 0 deletions infra/env/itn-prod/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
prefix = "pagopa"
env = "prod"
env_short = "p"

tags = {
CreatedBy = "Terraform"
Environment = "Prod"
Owner = "pagoPA"
Source = "https://github.com/pagopa/pagopa-payment-options-service"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

apim_dns_zone_prefix = "platform"
external_domain = "pagopa.it"
hostname = "itnprod.gps.internal.platform.pagopa.it"
1 change: 1 addition & 0 deletions infra/env/itn-uat/backend.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subscription=UAT-pagoPA
4 changes: 4 additions & 0 deletions infra/env/itn-uat/backend.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource_group_name = "io-infra-rg"
storage_account_name = "pagopainfraterraformuat"
container_name = "azurermstate"
key = "pagopa-payment-options-service.infra.tfstate"
15 changes: 15 additions & 0 deletions infra/env/itn-uat/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
prefix = "pagopa"
env = "uat"
env_short = "u"

tags = {
CreatedBy = "Terraform"
Environment = "Uat"
Owner = "pagoPA"
Source = "https://github.com/pagopa/pagopa-payment-options-service"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

apim_dns_zone_prefix = "uat.platform"
external_domain = "pagopa.it"
hostname = "itnuat.paymentoptions.internal.uat.platform.pagopa.it"
Loading

0 comments on commit cb7da5a

Please sign in to comment.