Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [SRTP-41] Send RTP OpenAPI #3

Merged
merged 15 commits into from
Oct 21, 2024
Merged
54 changes: 54 additions & 0 deletions src/rtp/02_api_service_provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## RTP Service Provider API ##
resource "azurerm_api_management_api_version_set" "rtp_service_provider_api" {
name = "${var.env_short}-rtp-service-provider-api"
api_management_name = data.azurerm_api_management.this.name
resource_group_name = data.azurerm_api_management.this.resource_group_name

display_name = "RTP Service Provider API"
versioning_scheme = "Segment"
}

resource "azurerm_api_management_api" "rtp_service_provider_api" {
name = "${var.env_short}-rtp-service-provider-api"
api_management_name = data.azurerm_api_management.this.name
resource_group_name = data.azurerm_api_management.this.resource_group_name

version_set_id = azurerm_api_management_api_version_set.rtp_service_provider_api.id

revision = "1"
version = "v1"
description = "RTP Service Provider API"
display_name = "RTP Service Provider API"
path = "rtp"
protocols = ["https"]
subscription_required = false

depends_on = [azurerm_api_management_product.rtp]

import {
content_format = "openapi"
content_value = templatefile("./api/pagopa/openapi.yaml", {})
}
}


resource "azurerm_api_management_product_api" "rtp_service_provider_product_api" {
api_management_name = data.azurerm_api_management.this.name
resource_group_name = data.azurerm_api_management.this.resource_group_name

api_name = azurerm_api_management_api.rtp_service_provider_api.name
product_id = azurerm_api_management_product.rtp.product_id
depends_on = [azurerm_api_management_product.rtp, azurerm_api_management_api.rtp_service_provider_api]
}

## Override API Operations Policies ##
resource "azurerm_api_management_api_operation_policy" "rtp_service_provider_create_rtp_policy" {
api_name = azurerm_api_management_api.rtp_service_provider_api.name
api_management_name = azurerm_api_management_api.rtp_service_provider_api.api_management_name
resource_group_name = azurerm_api_management_api.rtp_service_provider_api.resource_group_name
operation_id = "createRtp"

xml_content = templatefile("./api/pagopa/create_rtp_mock_policy.xml", {
base_url : "${local.rtp_base_url}/${azurerm_api_management_api.rtp_service_provider_api.path}/${azurerm_api_management_api.rtp_service_provider_api.version}/rtps"
})
}
2 changes: 2 additions & 0 deletions src/rtp/99_locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ locals {

apim_name = "${local.product}-apim"
apim_rg = "${local.product}-api-rg"

rtp_base_url = "https://api-rtp.${var.dns_zone_prefix}"
}
5 changes: 5 additions & 0 deletions src/rtp/99_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ variable "domain" {
error_message = "Max length is 12 chars."
}
}

variable "dns_zone_prefix" {
type = string
description = "The DNS zone prefix e.g. dev.cstar.pagopa.it"
}
35 changes: 35 additions & 0 deletions src/rtp/api/pagopa/create_rtp_mock_policy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
IMPORTANT:
- Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.
- To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.
- To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.
- To add a policy, place the cursor at the desired insertion point and select a policy from the sidebar.
- To remove a policy, delete the corresponding policy statement from the policy document.
- Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.
- Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.
- Policies are applied in the order of their appearance, from the top down.
- Comments within policy elements are not supported and may disappear. Place your comments between policy elements or at a higher level scope.
-->
<policies>
<inbound>
<set-variable name="uuid" value="@(Guid.NewGuid().ToString())"/>
<return-response>
<set-status code="200" reason="OK" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-header name="Location" exists-action="override">
<value>@("${base_url}" + "/" + context.Variables["uuid"])</value>
</set-header>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
1 change: 1 addition & 0 deletions src/rtp/api/pagopa/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
$ref: "#/components/schemas/PayeeId"
name:
type: string
maxLength: 140
description: "The name of payee (e.g. EC name or Company Name)"
example: "Comune di Roma"
required:
Expand All @@ -75,7 +76,7 @@
description: "See idPA field"
url: "https://docs.pagopa.it/sanp/appendici/primitive#paverifypaymentnotice"

RtpId:

Check warning on line 79 in src/rtp/api/pagopa/openapi.yaml

View workflow job for this annotation

GitHub Actions / Lint (pull_request)

oas3-unused-component

Potentially unused component has been detected.
type: string
format: uuid
description: "Request to pay unique id"
Expand Down
2 changes: 2 additions & 0 deletions src/rtp/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ tags = {
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
Application = "RTP"
}

dns_zone_prefix = "dev.cstar.pagopa.it"
2 changes: 2 additions & 0 deletions src/rtp/env/prod/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ tags = {
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
Application = "RTP"
}

dns_zone_prefix = "cstar.pagopa.it"
2 changes: 2 additions & 0 deletions src/rtp/env/uat/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ tags = {
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
Application = "RTP"
}

dns_zone_prefix = "uat.cstar.pagopa.it"
Loading