{% extends "common/base_resource.tf.j2" %}

{% block resources %}
{% for resource in resources %}
{{ resource_spacer() }}
resource "azurerm_servicebus_topic" "{{ resource.name }}" {
  name         = "{{ resource.properties.name }}"
  namespace_id = "{{ resource.properties.namespace_id }}"
  
  {% if resource.properties.status is defined %}
  status = "{{ resource.properties.status }}"
  {% endif %}
  
  {% if resource.properties.auto_delete_on_idle is defined %}
  auto_delete_on_idle = "{{ resource.properties.auto_delete_on_idle }}"
  {% endif %}
  
  {% if resource.properties.default_message_ttl is defined %}
  default_message_ttl = "{{ resource.properties.default_message_ttl }}"
  {% endif %}
  
  {% if resource.properties.duplicate_detection_history_time_window is defined %}
  duplicate_detection_history_time_window = "{{ resource.properties.duplicate_detection_history_time_window }}"
  {% endif %}
  
  {% if resource.properties.enable_batched_operations is defined %}
  enable_batched_operations = {{ resource.properties.enable_batched_operations | lower }}
  {% endif %}
  
  {% if resource.properties.enable_express is defined %}
  enable_express = {{ resource.properties.enable_express | lower }}
  {% endif %}
  
  {% if resource.properties.enable_partitioning is defined %}
  enable_partitioning = {{ resource.properties.enable_partitioning | lower }}
  {% endif %}
  
  {% if resource.properties.max_message_size_in_kilobytes is defined %}
  max_message_size_in_kilobytes = {{ resource.properties.max_message_size_in_kilobytes }}
  {% endif %}
  
  {% if resource.properties.max_size_in_megabytes is defined %}
  max_size_in_megabytes = {{ resource.properties.max_size_in_megabytes }}
  {% endif %}
  
  {% if resource.properties.requires_duplicate_detection is defined %}
  requires_duplicate_detection = {{ resource.properties.requires_duplicate_detection | lower }}
  {% endif %}
  
  {% if resource.properties.support_ordering is defined %}
  support_ordering = {{ resource.properties.support_ordering | lower }}
  {% endif %}
}

{% endfor %}
{% endblock %}
