From 0e1cdbf0287749125176148cab14a58624a4377e Mon Sep 17 00:00:00 2001 From: Luca Consalvi <117908483+lucaconsalvi@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:28:28 +0100 Subject: [PATCH] feat: [SRTP-72] add activation api draft (#5) --- src/rtp/02_api_activation.tf | 54 ++++++++++++++++++++++++ src/rtp/api/pagopa/activation_policy.xml | 23 ++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/rtp/02_api_activation.tf create mode 100644 src/rtp/api/pagopa/activation_policy.xml diff --git a/src/rtp/02_api_activation.tf b/src/rtp/02_api_activation.tf new file mode 100644 index 0000000..619435e --- /dev/null +++ b/src/rtp/02_api_activation.tf @@ -0,0 +1,54 @@ +## RTP Activation API ## +resource "azurerm_api_management_api_version_set" "rtp_activation_api" { + name = "${var.env_short}-rtp-activation-api" + api_management_name = data.azurerm_api_management.this.name + resource_group_name = data.azurerm_api_management.this.resource_group_name + + display_name = "RTP Activation API" + versioning_scheme = "Header" + version_header_name = "Version" +} + + +resource "azurerm_api_management_api" "rtp_activation_api" { + name = "${var.env_short}-rtp-activation-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_activation_api.id + + revision = "1" + version = "v1" + description = "RTP Activation API" + display_name = "RTP Activation API" + path = "rtp/activation" + protocols = ["https"] + subscription_required = false + + depends_on = [azurerm_api_management_product.rtp] + + import { + content_format = "openapi" + content_value = templatefile("./api/pagopa/activation.yaml", {}) + } +} + +resource "azurerm_api_management_product_api" "rtp_activation_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_activation_api.name + product_id = azurerm_api_management_product.rtp.product_id + depends_on = [azurerm_api_management_product.rtp, azurerm_api_management_api.rtp_activation_api] +} + +## Override API Operations Policies ## +resource "azurerm_api_management_api_operation_policy" "rtp_activate_policy" { + api_name = azurerm_api_management_api.rtp_activation_api.name + api_management_name = data.azurerm_api_management.this.name + resource_group_name = data.azurerm_api_management.this.resource_group_name + operation_id = "activate" + + xml_content = templatefile("./api/pagopa/activation_policy.xml", { + base_url : "${local.rtp_base_url}/${azurerm_api_management_api.rtp_activation_api.path}/${azurerm_api_management_api.rtp_activation_api.version}/rtps" + }) +} diff --git a/src/rtp/api/pagopa/activation_policy.xml b/src/rtp/api/pagopa/activation_policy.xml new file mode 100644 index 0000000..0559759 --- /dev/null +++ b/src/rtp/api/pagopa/activation_policy.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + \ No newline at end of file