Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enhancements:
- Add possibility to set subnet ordering for section from Ansible, even though the setting only reflects in GUI
- Add option `order_by` as choice of `subnet` and 'description'
- Add option `order_direction` as choice of `asc` and `desc`
breaking_changes:
- Remove `list_oder`, as this parameters serves no purpose
2 changes: 1 addition & 1 deletion docs/plugins/address_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Parameters

<div class="ansible-option-cell">

IP address to handle
IP address to hanle


.. raw:: html
Expand Down
116 changes: 66 additions & 50 deletions docs/plugins/section_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,21 @@ Parameters
* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-list_order"></div>
<div class="ansibleOptionAnchor" id="parameter-name"></div>

.. _ansible_collections.codeaffen.phpipam.section_module__parameter-list_order:
.. _ansible_collections.codeaffen.phpipam.section_module__parameter-name:

.. rst-class:: ansible-option-title

**list_order**
**name**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-list_order" title="Permalink to this option"></a>
<a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`integer`
:ansible-option-type:`string` / :ansible-option-required:`required`

.. raw:: html

Expand All @@ -227,7 +227,7 @@ Parameters

<div class="ansible-option-cell">

Order in sections list view
Name of the section


.. raw:: html
Expand All @@ -237,21 +237,21 @@ Parameters
* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-name"></div>
<div class="ansibleOptionAnchor" id="parameter-order_by"></div>

.. _ansible_collections.codeaffen.phpipam.section_module__parameter-name:
.. _ansible_collections.codeaffen.phpipam.section_module__parameter-order_by:

.. rst-class:: ansible-option-title

**name**
**order_by**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a>
<a class="ansibleOptionLink" href="#parameter-order_by" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`string` / :ansible-option-required:`required`
:ansible-option-type:`string`

.. raw:: html

Expand All @@ -261,7 +261,61 @@ Parameters

<div class="ansible-option-cell">

Name of the section
Specifies the field to use for sorting the returned subnets


.. rst-class:: ansible-option-line

:ansible-option-choices:`Choices:`

- :ansible-option-choices-entry:`"subnet"`
- :ansible-option-choices-entry:`"description"`


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-order_direction"></div>

.. _ansible_collections.codeaffen.phpipam.section_module__parameter-order_direction:

.. rst-class:: ansible-option-title

**order_direction**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-order_direction" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`string`

.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

Determines the sorting direction, either ascending or descending

'asc' sorts from A to Z or from smallest to largest number

'desc' sorts from Z to A or from largest to smallest number


.. rst-class:: ansible-option-line

:ansible-option-choices:`Choices:`

- :ansible-option-choices-entry:`"asc"`
- :ansible-option-choices-entry:`"desc"`


.. raw:: html
Expand Down Expand Up @@ -624,44 +678,6 @@ Parameters
- :ansible-option-choices-entry:`true`


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-subnet_ordering"></div>

.. _ansible_collections.codeaffen.phpipam.section_module__parameter-subnet_ordering:

.. rst-class:: ansible-option-title

**subnet_ordering**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-subnet_ordering" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`string`

.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

How to order subnets within this section


.. rst-class:: ansible-option-line

:ansible-option-default-bold:`Default:` :ansible-option-default:`"subnet,asc"`

.. raw:: html

</div>
Expand Down
35 changes: 24 additions & 11 deletions plugins/modules/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@
type: bool
required: false
default: no
subnet_ordering:
description: How to order subnets within this section
order_by:
description: Specifies the field to use for sorting the returned subnets
type: str
choices: [ subnet, description ]
required: false
default: "subnet,asc"
list_order:
description: Order in sections list view
type: int
order_direction:
description:
- Determines the sorting direction, either ascending or descending
- "'asc' sorts from A to Z or from smallest to largest number"
- "'desc' sorts from Z to A or from largest to smallest number"
type: str
choices: [ asc, desc ]
required: false
show_vlan:
description: Show/hide VLANs in subnet list view
Expand Down Expand Up @@ -125,17 +129,26 @@ def main():
parent=dict(type='entity', controller='sections', required=False, default=None, phpipam_name='masterSection'),
permissions=dict(type='json', required=False, default=None),
strict_mode=dict(type='bool', required=False),
subnet_ordering=dict(type='bool', required=False, phpipam_name='subnetOrdering'),
list_order=dict(type='bool', required=False, phpipam_name='order'),
order_by=dict(type=str, required=False, choices=['subnet', 'description']),
order_direction=dict(type=str, required=False, choices=['asc', 'desc']),
subnetOrdering=dict(type=str, required=False),
show_vlan=dict(type='bool', required=False, phpipam_name='showVLAN'),
show_vrf=dict(type='bool', required=False, phpipam_name='showVRF'),
show_supernets_only=dict(type='bool', required=False, phpipam_name='showSupernetOnly'),
dns_resolver=dict(type='entity', controller='tools/nameservers', required=False, phpipam_name='DNS'),
)
),
required_together=[['order_by', 'order_direction']],
)

if not module.desired_absent:
pass
module_params = module.phpipam_params

if 'order_by' in module_params and 'order_direction' in module_params:
module_params['subnetOrdering'] = module_params['order_by'] + ',' + module_params['order_direction']
del module_params['order_by']
del module_params['order_direction']

# if not module.desired_absent:
# pass

with module.api_connection():
module.run()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_playbooks/tasks/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
parent: "{{ section.parent | default(omit) }}"
permissions: "{{ section.permissions | default(omit) }}"
strict_mode: "{{ section.strict_mode | default(omit) }}"
subnet_ordering: "{{ section.subnet_ordering | default(omit) }}"
order_by: "{{ section.order_by | default(omit) }}"
order_direction: "{{ section.order_direction | default(omit) }}"
list_order: "{{ section.list_order | default(omit) }}"
show_vlan: "{{ section.show_vlan | default(omit) }}"
show_vrf: "{{ section.show_vrf | default(omit) }}"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_playbooks/vars/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
base_section_data:
name: "Example Inc."
show_supernets_only: yes
order_by: subnet
order_direction: asc

sections:
- name: "ACME Inc."
Expand Down
Loading