
    Vh                     h    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZmZ d Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functiona  
module: manageiq_policies

short_description: Management of resource policy_profiles in ManageIQ
extends_documentation_fragment:
  - community.general.manageiq
  - community.general.attributes

author: Daniel Korn (@dkorn)
description:
  - The manageiq_policies module supports adding and deleting policy_profiles in ManageIQ.
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none

options:
  state:
    type: str
    description:
      - V(absent) - policy_profiles should not exist,
      - V(present) - policy_profiles should exist.
    choices: ['absent', 'present']
    default: 'present'
  policy_profiles:
    type: list
    elements: dict
    description:
      - List of dictionaries, each includes the policy_profile V(name) key.
      - Required if O(state) is V(present) or V(absent).
  resource_type:
    type: str
    description:
      - The type of the resource to which the profile should be [un]assigned.
    required: true
    choices:
      - provider
      - host
      - vm
      - blueprint
      - category
      - cluster
      - data store
      - group
      - resource pool
      - service
      - service template
      - template
      - tenant
      - user
  resource_name:
    type: str
    description:
      - The name of the resource to which the profile should be [un]assigned.
      - Must be specified if O(resource_id) is not set. Both options are mutually exclusive.
  resource_id:
    type: int
    description:
      - The ID of the resource to which the profile should be [un]assigned.
      - Must be specified if O(resource_name) is not set. Both options are mutually exclusive.
    version_added: 2.2.0
a"  
- name: Assign new policy_profile for a provider in ManageIQ
  community.general.manageiq_policies:
    resource_name: 'EngLab'
    resource_type: 'provider'
    policy_profiles:
      - name: openscap profile
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false # only do this when you trust the network!

- name: Unassign a policy_profile for a provider in ManageIQ
  community.general.manageiq_policies:
    state: absent
    resource_name: 'EngLab'
    resource_type: 'provider'
    policy_profiles:
      - name: openscap profile
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false # only do this when you trust the network!
a  
manageiq_policies:
  description:
    - List current policy_profile and policies for a provider in ManageIQ.
  returned: always
  type: dict
  sample:
    {
      "changed": false,
      "profiles": [
        {
          "policies": [
            {
              "active": true,
              "description": "OpenSCAP",
              "name": "openscap policy"
            },
            {
              "active": true,
              "description": "Analyse incoming container images",
              "name": "analyse incoming container images"
            },
            {
              "active": true,
              "description": "Schedule compliance after smart state analysis",
              "name": "schedule compliance after smart state analysis"
            }
          ],
          "profile_description": "OpenSCAP profile",
          "profile_name": "openscap profile"
        }
      ]
    }
)AnsibleModule)ManageIQmanageiq_argument_specmanageiq_entitiesc                     ddd} t        t        dd      t        d      t        d	      t        d
d	t        t               j                                     t        dd	ddgd            }|j	                  t                      t        |ddggddggdddgfdddgfg      }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }| |   }t               |   }	t        |      }
|
j                  ||	|      }|j                  ||      } |j                  di | y )Nassignunassign)presentabsentlistdict)typeelementsint)r   strT)requiredr   choicesFr   r   )r   r   r   default)policy_profilesresource_idresource_nameresource_typestater   r   r   r   )argument_specmutually_exclusiverequired_one_ofrequired_ifr    )r   r   r	   keysupdater   r   paramsr   policiesassign_or_unassign_profiles	exit_json)actionsr   moduler   r   resource_type_keyr   r   actionr   manageiqmanageiq_policiesres_argss                w/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/manageiq_policies.pymainr0      sj   "j9G&6:e$&Du#'(9(;(@(@(B#CEE%x0)EM /12#*O<='9:i"3!45h!2 34
	F mm$56O--.Ko6MM/2MMM'"E U^F%'(9:MH ))+}mT !<<_fUHF x     __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Cansible_collections.community.general.plugins.module_utils.manageiqr   r   r	   r0   __name__r!   r1   r/   <module>r;      sU    A @>@6!
F 5 D  D(!V zF r1   