{#
This template renders (commented out) Managed Objects Instances
for scalar and columnar Managed Objects.

The user is expected to provide:

 * values for all Managed Objects
 * proper indices and values for zero or more tables rows

#}
{% include "pysnmp/base.j2" %}

{% block smi_imports scoped %}

MibScalarInstance, = mibBuilder.importSymbols(
    'SNMPv2-SMI',
    'MibScalarInstance'
)

# Import Managed Objects to base Managed Objects Instances on

{% for symbol, definition in mib.items()|sort
   if definition['class'] == 'objecttype' and
      definition['nodetype'] in ('scalar', 'column') %}
    {% if loop.first and loop.last %}
({{ symbol|replace('-', '_') }},) = mibBuilder.importSymbols(
    "{{ mib['meta']['module'] }}",
    {% elif loop.first %}
({{ symbol|replace('-', '_') }},
    {% elif loop.last %}
 {{ symbol|replace('-', '_') }}) = mibBuilder.importSymbols(
    "{{ mib['meta']['module'] }}",
    {%  else %}
 {{ symbol|replace('-', '_') }},
    {%  endif %}
{% endfor %}
{% for symbol, definition in mib.items()|sort
       if definition['class'] == 'objecttype' and
           definition['nodetype'] in ('scalar', 'column') %}
    {% if loop.last %}
    "{{ symbol }}")
    {% else %}
    "{{ symbol }}",
    {% endif %}
{% endfor %}

{% endblock %}
{% block managed_objects_instances scoped %}

# MIB Managed Objects in the order of their OIDs
{% for symbol, definition in mib.items() %}
    {% if definition['nodetype'] == 'scalar' %}
        {% block mib_scalar_object_instance_definition scoped %}
{{ symbol|replace('-', '_')|capfirst }}_ObjectInstance = MibScalarInstance
        {% endblock %}
        {% block mib_scalar_object_instantiation scoped %}
# TODO: uncomment Managed Object Instance instantiation optionally
#       setting a default value (via `.syntax.clone()`)
# _{{ symbol|replace('-', '_') }} = {{ symbol|replace('-', '_')|capfirst }}_ObjectInstance(
#      {{ symbol|replace('-', '_') }}.name,
#      (0,),
#      {{ symbol|replace('-', '_') }}.syntax
# )
        {% endblock %}
    {% elif definition['nodetype'] == 'column' %}
        {% block mib_table_column_object_instance_definition scoped %}
{{ symbol|replace('-', '_')|capfirst }}_ObjectInstance = MibScalarInstance
        {% endblock %}
        {% block mib_column_instantiation scoped %}
# TODO: Set proper OID for Managed Object Instance (see INDEX clause in MIB)
# TODO: Initialize Managed Object Instance value (via `.syntax.clone()`)
# _{{ symbol|replace('-', '_') }} = {{ symbol|replace('-', '_')|capfirst }}_ObjectInstance(
#     {{ symbol|replace('-', '_') }}.name,
#     (<add columnar indices here>,),
#     {{ symbol|replace('-', '_') }}.syntax
# )
        {% endblock %}
    {% endif %}
{% endfor %}
{% endblock %}

{% block exports scoped %}

# Export Managed Objects Instances to the MIB builder

# TODO: complete Managed Objects Instances initialization above
# and uncomment the exports below

mibBuilder.exportSymbols(
    "__{{ mib['meta']['module'] }}",
    {% for symbol, definition in mib.items()
       if definition['class'] == 'objecttype' and
           definition['nodetype'] in ('scalar', 'column') %}
        {% if loop.first and loop.last %}
    # **{"{{ symbol }}": _{{ symbol|replace('-', '_') }}}
        {% elif loop.first %}
    # **{"{{ symbol }}": _{{ symbol|replace('-', '_') }},
        {% elif loop.last %}
    # "{{ symbol }}": _{{ symbol|replace('-', '_') }}}
        {% else %}
    # "{{ symbol }}": _{{ symbol|replace('-', '_') }},
        {% endif %}
    {%  endfor %}
)
{% endblock %}
