Skip to content

Commit

Permalink
feat: [SRTP-72] add activation api draft (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi authored Nov 5, 2024
1 parent 22e6712 commit 0e1cdbf
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/rtp/02_api_activation.tf
Original file line number Diff line number Diff line change
@@ -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"
})
}
23 changes: 23 additions & 0 deletions src/rtp/api/pagopa/activation_policy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
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>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>

0 comments on commit 0e1cdbf

Please sign in to comment.