Skip to content

Commit

Permalink
fix: Added new info resource zpa_customer_version_profile_info (#43)
Browse files Browse the repository at this point in the history
* fix: Added new info resource zpa_customer_version_profile_info
  • Loading branch information
willguibr authored Sep 17, 2024
1 parent 059a281 commit 08171f7
Show file tree
Hide file tree
Showing 25 changed files with 1,227 additions and 815 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ansible-test-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
python_ver: "3.11"
- ansible: "2.16"
python_ver: "3.11"
- ansible: "2.17"
python_ver: "3.11"
defaults:
run:
working-directory: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
python_ver: "3.11"
- ansible: "2.16"
python_ver: "3.11"
- ansible: "2.17"
python_ver: "3.11"
runs-on: ubuntu-latest
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zpa-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Install Poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: 1.8.2
poetry-version: 1.8.3

- name: Get poetry cache directory
id: poetry-cache
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Zscaler Private Access (ZPA) Ansible Collection Changelog

## 1.3.1 (September, 16 2024)

### Notes

- Python Versions: **v3.9, v3.10, v3.11**

### New Feature

- [PR #43](https://github.com/zscaler/zscaler-sdk-go/pull/43) Added new info resource `zpa_customer_version_profile_info` to retrieve visible app connector group version profiles.

## 1.3.0 (August, 20 2024)

### Notes
Expand Down
16 changes: 16 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ Releases
Zscaler Private Access (ZPA) Ansible Collection Changelog
---------------------------------------------------------

Version 1.3.1
==============

1.3.1 (September, 16 2024)
---------------------------

Notes
-----

- Python Versions: **v3.8, v3.9, v3.10, v3.11**

New Feature
------------

* (`#43 <https://github.com/zscaler/zpacloud-ansible/pull/43>`_) Added new info resource `zpa_customer_version_profile_info` to retrieve visible app connector group version profiles.

Version 1.3.0
=============

Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: zscaler
name: zpacloud

# The version of the collection. Must be compatible with semantic versioning
version: 1.3.0
version: 1.3.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/zpa_ba_certificate_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@

EXAMPLES = """
- name: Gather Details of All Browser Certificates
zscaler.zpacloud.zpa_ba_certificate_facts:
zscaler.zpacloud.zpa_ba_certificate_info:
provider: "{{ zpa_cloud }}"
- name: Gather Details of a Specific Browser Certificates by Name
zscaler.zpacloud.zpa_ba_certificate_facts:
zscaler.zpacloud.zpa_ba_certificate_info:
provider: "{{ zpa_cloud }}"
name: crm.acme.com
- name: Gather Details of a Specific Browser Certificates by ID
zscaler.zpacloud.zpa_ba_certificate_facts:
zscaler.zpacloud.zpa_ba_certificate_info:
provider: "{{ zpa_cloud }}"
id: "216196257331282583"
"""
Expand Down
168 changes: 168 additions & 0 deletions plugins/modules/zpa_customer_version_profile_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023 Zscaler Inc, <[email protected]>

# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from __future__ import absolute_import, division, print_function

__metaclass__ = type

DOCUMENTATION = """
---
module: zpa_customer_version_profile_info
short_description: Retrieves visible version profiles.
description:
- This module will allow the retrieval visible version profiles to be associated with app connector groups.
author:
- William Guilherme (@willguibr)
version_added: "1.0.0"
requirements:
- Zscaler SDK Python can be obtained from PyPI U(https://pypi.org/project/zscaler-sdk-python/)
notes:
- Check mode is not supported.
extends_documentation_fragment:
- zscaler.zpacloud.fragments.provider
- zscaler.zpacloud.fragments.documentation
options:
name:
description:
- The name of the version profile.
required: false
type: str
id:
description:
- The unique identifier of the version profile.
required: false
type: str
"""

EXAMPLES = """
- name: Gather Details of All Visible Version Profiles
zscaler.zpacloud.zpa_customer_version_profile_info:
provider: "{{ zpa_cloud }}"
- name: Gather Details of a Specific Visible Version Profiles by Name
zscaler.zpacloud.zpa_customer_version_profile_info:
provider: "{{ zpa_cloud }}"
name: crm.acme.com
- name: Gather Details of a Specific Visible Version Profiles by ID
zscaler.zpacloud.zpa_customer_version_profile_info:
provider: "{{ zpa_cloud }}"
id: "216196257331282583"
"""

RETURN = r"""
# ANY INFORMATION IN THIS DOCUMENT IS FOR EXAMPLE PURPOSES ONLY AND NOT USED IN PRODUCTION
profiles:
description: List of version profiles based on the search criteria or all available profiles if no criteria are provided.
returned: always
type: list
elements: dict
contains:
creation_time:
description: The Unix timestamp when the profile was created.
type: str
returned: always
customer_id:
description: The unique identifier for the customer to whom the profile belongs.
type: str
returned: always
id:
description: The unique identifier for the profile.
type: str
returned: always
modified_by:
description: The unique identifier of the user who last modified the profile.
type: str
returned: always
modified_time:
description: The Unix timestamp when the profile was last modified.
type: str
returned: always
name:
description: The name of the profile.
type: str
returned: always
upgrade_priority:
description: The priority of upgrades for this profile, which can be 'WEEK', 'DAY', or other intervals.
type: str
returned: always
visibility_scope:
description: The scope of visibility for the profile, such as 'ALL', 'NONE', or other specific scopes.
type: str
returned: always
"""

from traceback import format_exc

from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.zscaler.zpacloud.plugins.module_utils.zpa_client import (
ZPAClientHelper,
)


def core(module):
profile_id = module.params.get("id", None)
profile_name = module.params.get("name", None)
client = ZPAClientHelper(module)

# If profile_id is provided, search by id
if profile_id is not None:
profiles = client.connectors.list_version_profiles(
search=profile_id, pagesize=500
).to_list()
if not profiles:
module.fail_json(msg="Failed to retrieve profile by ID: '%s'" % profile_id)
# If profile_name is provided, search by name
elif profile_name is not None:
profiles = client.connectors.list_version_profiles(
search=profile_name, pagesize=500
).to_list()
if not profiles:
module.fail_json(
msg="Failed to retrieve profile by Name: '%s'" % profile_name
)
# If neither profile_id nor profile_name is provided, retrieve all profiles
else:
profiles = client.connectors.list_version_profiles(pagesize=500).to_list()

module.exit_json(changed=False, profiles=profiles)


def main():
argument_spec = ZPAClientHelper.zpa_argument_spec()
argument_spec.update(
name=dict(type="str", required=False),
id=dict(type="str", required=False),
)
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
try:
core(module)
except Exception as e:
module.fail_json(msg=to_native(e), exception=format_exc())


if __name__ == "__main__":
main()
36 changes: 27 additions & 9 deletions plugins/modules/zpa_pra_console_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,42 @@
required: false
"""

EXAMPLES = """
EXAMPLES = r"""
- name: Gather Details of a Specific Browser Certificates by Name
zscaler.zpacloud.zpa_ba_certificate_facts:
provider: '{{ zpa_cloud }}'
zscaler.zpacloud.zpa_ba_certificate_info:
provider: "{{ zpa_cloud }}"
name: 'portal.acme.com'
register: cert_name
register: cert_name
- name: Get details of a specific SECURE_REMOTE_ACCESS application segment by name
zscaler.zpacloud.zpa_application_segment_by_type_info:
provider: "{{ zpa_cloud }}"
application_type: SECURE_REMOTE_ACCESS
name: pra_app_segment01
register: pra_app_segment01
- name: Create/Update/Delete PRA Portal
zscaler.zpacloud.zpa_pra_portal_controller:
provider: '{{ zpa_cloud }}'
provider: "{{ zpa_cloud }}"
name: 'portal.acme.com'
description: 'Created with Ansible'
description: 'PRA Portal'
enabled: true
domain: 'portal.acme.com'
certificate_id: "{{ cert_name.data[0].id }}"
user_notification: 'Created with Ansible'
certificate_id: "{{ cert_name.certificates[0].id }}"
user_notification: 'PRA Portal'
user_notification_enabled: true
register: result
register: portal
- name: Create PRA Console
zscaler.zpacloud.zpa_pra_console_controller:
provider: "{{ zpa_cloud }}"
name: 'PRA Console'
description: 'PRA Console'
enabled: true
pra_application_id: "{{ pra_app_segment01.apps[0].id }}"
pra_portal_ids:
- "{{ portal.data.id }}"
register: result
"""

RETURN = """
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/zpa_pra_console_controller_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@

EXAMPLES = """
- name: Get Detail Information of All PRA Consoles
zscaler.zpacloud.zpa_pra_console_controller_facts:
zscaler.zpacloud.zpa_pra_console_controller_info:
provider: "{{ zpa_cloud }}"
- name: Get Details of a PRA Console by Name
zscaler.zpacloud.zpa_pra_console_controller_facts:
zscaler.zpacloud.zpa_pra_console_controller_info:
provider: "{{ zpa_cloud }}"
name: "Example"
- name: Get Details of a PRA Console by ID
zscaler.zpacloud.zpa_pra_console_controller_facts:
zscaler.zpacloud.zpa_pra_console_controller_info:
provider: "{{ zpa_cloud }}"
id: "216196257331291969"
"""
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_pra_portal_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

EXAMPLES = """
- name: Gather Details of a Specific Browser Certificates by Name
zscaler.zpacloud.zpa_ba_certificate_facts:
zscaler.zpacloud.zpa_ba_certificate_info:
provider: '{{ zpa_cloud }}'
name: 'portal.acme.com'
register: cert_name
Expand Down
3 changes: 0 additions & 3 deletions plugins/modules/zpa_provisioning_key_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ def core(module):
else:
provisioning_keys = all_keys

if not provisioning_keys:
module.fail_json(msg="No provisioning keys found.")

module.exit_json(changed=False, provisioning_keys=provisioning_keys)


Expand Down
Loading

0 comments on commit 08171f7

Please sign in to comment.