mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-07 22:03:09 +00:00
Refactored federation_idp{,_info} modules
Change-Id: Icbff6c799a9c33f1104633f7d9521f02228217a5
This commit is contained in:
@@ -4,25 +4,23 @@
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
DOCUMENTATION = r'''
|
||||
module: federation_idp_info
|
||||
short_description: Get the information about the available federation identity
|
||||
providers
|
||||
short_description: Fetch OpenStack federation identity providers
|
||||
author: OpenStack Ansible SIG
|
||||
description:
|
||||
- Fetch available federation identity providers.
|
||||
- Fetch OpenStack federation identity providers.
|
||||
options:
|
||||
name:
|
||||
id:
|
||||
description:
|
||||
- The name of the identity provider to fetch.
|
||||
- The ID (and name) of the identity provider to fetch.
|
||||
type: str
|
||||
aliases: ['id']
|
||||
aliases: ['name']
|
||||
extends_documentation_fragment:
|
||||
- openstack.cloud.openstack
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
EXAMPLES = r'''
|
||||
- name: Fetch a specific identity provider
|
||||
openstack.cloud.federation_idp_info:
|
||||
cloud: example_cloud
|
||||
@@ -33,35 +31,35 @@ EXAMPLES = '''
|
||||
cloud: example_cloud
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
RETURN = r'''
|
||||
identity_providers:
|
||||
description: Dictionary describing the identity providers
|
||||
returned: success
|
||||
type: list
|
||||
elements: dict
|
||||
contains:
|
||||
description:
|
||||
description: Identity provider description
|
||||
type: str
|
||||
sample: "demodescription"
|
||||
domain_id:
|
||||
description: Domain to which the identity provider belongs
|
||||
type: str
|
||||
sample: "default"
|
||||
id:
|
||||
description: Identity provider ID
|
||||
type: str
|
||||
sample: "test-idp"
|
||||
is_enabled:
|
||||
description: Indicates wether the identity provider is enabled
|
||||
type: bool
|
||||
name:
|
||||
description: Name of the identity provider, equals its ID.
|
||||
type: str
|
||||
sample: "test-idp"
|
||||
remote_ids:
|
||||
description: Remote IDs associated with the identity provider
|
||||
type: list
|
||||
description: Dictionary describing the identity providers
|
||||
returned: always
|
||||
type: list
|
||||
elements: dict
|
||||
contains:
|
||||
description:
|
||||
description: Identity provider description
|
||||
type: str
|
||||
sample: "demodescription"
|
||||
domain_id:
|
||||
description: Domain to which the identity provider belongs
|
||||
type: str
|
||||
sample: "default"
|
||||
id:
|
||||
description: Identity provider ID
|
||||
type: str
|
||||
sample: "test-idp"
|
||||
is_enabled:
|
||||
description: Indicates whether the identity provider is enabled
|
||||
type: bool
|
||||
name:
|
||||
description: Name of the identity provider, equals its ID.
|
||||
type: str
|
||||
sample: "test-idp"
|
||||
remote_ids:
|
||||
description: Remote IDs associated with the identity provider
|
||||
type: list
|
||||
'''
|
||||
|
||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||
@@ -69,24 +67,21 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
|
||||
|
||||
class IdentityFederationIdpInfoModule(OpenStackModule):
|
||||
argument_spec = dict(
|
||||
name=dict(aliases=['id']),
|
||||
id=dict(aliases=['name']),
|
||||
)
|
||||
module_kwargs = dict(
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
def run(self):
|
||||
""" Module entry point """
|
||||
|
||||
name = self.params['name']
|
||||
|
||||
query = {}
|
||||
if name:
|
||||
query["id"] = name
|
||||
|
||||
idps = self.conn.identity.identity_providers(**query)
|
||||
idps = [idp.to_dict(computed=False) for idp in idps]
|
||||
self.exit_json(changed=False, identity_providers=idps)
|
||||
kwargs = dict((k, self.params[k])
|
||||
for k in ['id']
|
||||
if self.params[k] is not None)
|
||||
identity_providers = self.conn.identity.identity_providers(**kwargs)
|
||||
self.exit_json(
|
||||
changed=False,
|
||||
identity_providers=[i.to_dict(computed=False)
|
||||
for i in identity_providers])
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user