<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2017, F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = r'''
---
module: bigiq_regkey_license_assignment
short_description: Manage regkey license assignment on BIG-IPs from a BIG-IQ.
description:
  - Manages the assignment of regkey licenses on a BIG-IQ. Assignment means that
    the license is assigned to a BIG-IP, or, it needs to be assigned to a BIG-IP.
    Additionally, this module supported revoking the assignments from BIG-IP devices.
version_added: 2.6
options:
  pool:
    description:
      - The registration key pool to use.
    required: True
  key:
    description:
      - The registration key that you want to assign from the pool.
    required: True
  device:
    description:
      - When C(managed) is C(no), specifies the address, or hostname, where the BIG-IQ
        can reach the remote device to register.
      - When C(managed) is C(yes), specifies the managed device, or device UUID, that
        you want to register.
      - If C(managed) is C(yes), it is very important that you do not have more than
        one device with the same name. BIG-IQ internally recognizes devices by their ID,
        and therefore, this module's cannot guarantee that the correct device will be
        registered. The device returned is the device that will be used.
  managed:
    description:
      - Whether the specified device is a managed or un-managed device.
      - When C(state) is C(present), this parameter is required.
    type: bool
  device_port:
    description:
      - Specifies the port of the remote device to connect to.
      - If this parameter is not specified, the default of C(443) will be used.
    default: 443
  device_username:
    description:
      - The username used to connect to the remote device.
      - This username should be one that has sufficient privileges on the remote device
        to do licensing. Usually this is the C(Administrator) role.
      - When C(managed) is C(no), this parameter is required.
  device_password:
    description:
      - The password of the C(device_username).
      - When C(managed) is C(no), this parameter is required.
  state:
    description:
      - When C(present), ensures that the device is assigned the specified license.
      - When C(absent), ensures the license is revokes from the remote device and freed
        on the BIG-IQ.
    default: present
    choices:
      - present
      - absent
extends_documentation_fragment: f5
author:
  - <NAME> (@caphrim007)
'''

EXAMPLES = r'''
- name: Register an unmanaged device
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: 1.1.1.1
    managed: no
    device_username: admin
    device_password: <PASSWORD>
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost

- name: Register an managed device, by name
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: bigi1.foo.com
    managed: yes
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost

- name: Register an managed device, by UUID
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: 7141a063-7cf8-423f-9829-9d40599fa3e0
    managed: yes
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost
'''

RETURN = r'''
param1:
  description: The new param1 value of the resource.
  returned: changed
  type: bool
  sample: true
param2:
  description: The new param2 value of the resource.
  returned: changed
  type: string
  sample: Foo is bar
'''

import re

from ansible.module_utils.basic import AnsibleModule

try:
    from library.module_utils.network.f5.bigiq import F5RestClient
    from library.module_utils.network.f5.common import F5ModuleError
    from library.module_utils.network.f5.common import AnsibleF5Parameters
    from library.module_utils.network.f5.common import f5_argument_spec
    from library.module_utils.network.f5.common import exit_json
    from library.module_utils.network.f5.common import fail_json
except ImportError:
    from ansible.module_utils.network.f5.bigiq import F5RestClient
    from ansible.module_utils.network.f5.common import F5ModuleError
    from ansible.module_utils.network.f5.common import AnsibleF5Parameters
    from ansible.module_utils.network.f5.common import f5_argument_spec
    from ansible.module_utils.network.f5.common import exit_json
    from ansible.module_utils.network.f5.common import fail_json
try:
    import netaddr
    HAS_NETADDR = True<commit_msg>Fixes bigiq doc error (#40517)<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2017, F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = r'''
---
module: bigiq_regkey_license_assignment
short_description: Manage regkey license assignment on BIG-IPs from a BIG-IQ.
description:
  - Manages the assignment of regkey licenses on a BIG-IQ. Assignment means that
    the license is assigned to a BIG-IP, or, it needs to be assigned to a BIG-IP.
    Additionally, this module supported revoking the assignments from BIG-IP devices.
version_added: 2.6
options:
  pool:
    description:
      - The registration key pool to use.
    required: True
  key:
    description:
      - The registration key that you want to assign from the pool.
    required: True
  device:
    description:
      - When C(managed) is C(no), specifies the address, or hostname, where the BIG-IQ
        can reach the remote device to register.
      - When C(managed) is C(yes), specifies the managed device, or device UUID, that
        you want to register.
      - If C(managed) is C(yes), it is very important that you do not have more than
        one device with the same name. BIG-IQ internally recognizes devices by their ID,
        and therefore, this module's cannot guarantee that the correct device will be
        registered. The device returned is the device that will be used.
  managed:
    description:
      - Whether the specified device is a managed or un-managed device.
      - When C(state) is C(present), this parameter is required.
    type: bool
  device_port:
    description:
      - Specifies the port of the remote device to connect to.
      - If this parameter is not specified, the default of C(443) will be used.
    default: 443
  device_username:
    description:
      - The username used to connect to the remote device.
      - This username should be one that has sufficient privileges on the remote device
        to do licensing. Usually this is the C(Administrator) role.
      - When C(managed) is C(no), this parameter is required.
  device_password:
    description:
      - The password of the C(device_username).
      - When C(managed) is C(no), this parameter is required.
  state:
    description:
      - When C(present), ensures that the device is assigned the specified license.
      - When C(absent), ensures the license is revokes from the remote device and freed
        on the BIG-IQ.
    default: present
    choices:
      - present
      - absent
extends_documentation_fragment: f5
author:
  - <NAME> (@caphrim007)
'''

EXAMPLES = r'''
- name: Register an unmanaged device
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: 1.1.1.1
    managed: no
    device_username: admin
    device_password: <PASSWORD>
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost

- name: Register an managed device, by name
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: bigi1.foo.com
    managed: yes
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost

- name: Register an managed device, by UUID
  bigiq_regkey_license_assignment:
    pool: my-regkey-pool
    key: <KEY>
    device: 7141a063-7cf8-423f-9829-9d40599fa3e0
    managed: yes
    password: <PASSWORD>
    server: lb.mydomain.com
    state: present
    user: admin
  delegate_to: localhost
'''

RETURN = r'''
# only common fields returned
'''

import re

from ansible.module_utils.basic import AnsibleModule

try:
    from library.module_utils.network.f5.bigiq import F5RestClient
    from library.module_utils.network.f5.common import F5ModuleError
    from library.module_utils.network.f5.common import AnsibleF5Parameters
    from library.module_utils.network.f5.common import f5_argument_spec
    from library.module_utils.network.f5.common import exit_json
    from library.module_utils.network.f5.common import fail_json
except ImportError:
    from ansible.module_utils.network.f5.bigiq import F5RestClient
    from ansible.module_utils.network.f5.common import F5ModuleError
    from ansible.module_utils.network.f5.common import AnsibleF5Parameters
    from ansible.module_utils.network.f5.common import f5_argument_spec
    from ansible.module_utils.network.f5.common import exit_json
    from ansible.module_utils.network.f5.common import fail_json
try:
    import netaddr
    HAS_NETADDR = True
{'fraction_non_alphanumeric': 0.07473200612557428, 'fraction_numerical': 0.01582440020418581, 'mean_word_length': 3.143824027072758, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014712', 'n_tokens_mistral': 2999, 'n_tokens_neox': 2872, 'n_words': 1025}