1#!/usr/local/bin/python3.8
2#
3# @author: Gaurav Rastogi (grastogi@avinetworks.com)
4#          Eric Anderson (eanderson@avinetworks.com)
5# module_check: supported
6#
7# Copyright: (c) 2017 Gaurav Rastogi, <grastogi@avinetworks.com>
8# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
9#
10
11from __future__ import (absolute_import, division, print_function)
12__metaclass__ = type
13
14DOCUMENTATION = '''
15---
16module: avi_ipamdnsproviderprofile
17author: Gaurav Rastogi (@grastogi23) <grastogi@avinetworks.com>
18
19short_description: Module for setup of IpamDnsProviderProfile Avi RESTful Object
20description:
21    - This module is used to configure IpamDnsProviderProfile object
22    - more examples at U(https://github.com/avinetworks/devops)
23requirements: [ avisdk ]
24options:
25    state:
26        description:
27            - The state that should be applied on the entity.
28        default: present
29        choices: ["absent", "present"]
30    avi_api_update_method:
31        description:
32            - Default method for object update is HTTP PUT.
33            - Setting to patch will override that behavior to use HTTP PATCH.
34        default: put
35        choices: ["put", "patch"]
36    avi_api_patch_op:
37        description:
38            - Patch operation to use when using avi_api_update_method as patch.
39        choices: ["add", "replace", "delete"]
40    allocate_ip_in_vrf:
41        description:
42            - If this flag is set, only allocate ip from networks in the virtual service vrf.
43            - Applicable for avi vantage ipam only.
44            - Field introduced in 17.2.4.
45            - Default value when not specified in API or module is interpreted by Avi Controller as False.
46        type: bool
47    aws_profile:
48        description:
49            - Provider details if type is aws.
50    azure_profile:
51        description:
52            - Provider details if type is microsoft azure.
53            - Field introduced in 17.2.1.
54    custom_profile:
55        description:
56            - Provider details if type is custom.
57            - Field introduced in 17.1.1.
58    gcp_profile:
59        description:
60            - Provider details if type is google cloud.
61    infoblox_profile:
62        description:
63            - Provider details if type is infoblox.
64    internal_profile:
65        description:
66            - Provider details if type is avi.
67    name:
68        description:
69            - Name for the ipam/dns provider profile.
70        required: true
71    oci_profile:
72        description:
73            - Provider details for oracle cloud.
74            - Field introduced in 18.2.1,18.1.3.
75    openstack_profile:
76        description:
77            - Provider details if type is openstack.
78    proxy_configuration:
79        description:
80            - Field introduced in 17.1.1.
81    tenant_ref:
82        description:
83            - It is a reference to an object of type tenant.
84    tencent_profile:
85        description:
86            - Provider details for tencent cloud.
87            - Field introduced in 18.2.3.
88    type:
89        description:
90            - Provider type for the ipam/dns provider profile.
91            - Enum options - IPAMDNS_TYPE_INFOBLOX, IPAMDNS_TYPE_AWS, IPAMDNS_TYPE_OPENSTACK, IPAMDNS_TYPE_GCP, IPAMDNS_TYPE_INFOBLOX_DNS, IPAMDNS_TYPE_CUSTOM,
92            - IPAMDNS_TYPE_CUSTOM_DNS, IPAMDNS_TYPE_AZURE, IPAMDNS_TYPE_OCI, IPAMDNS_TYPE_TENCENT, IPAMDNS_TYPE_INTERNAL, IPAMDNS_TYPE_INTERNAL_DNS,
93            - IPAMDNS_TYPE_AWS_DNS, IPAMDNS_TYPE_AZURE_DNS.
94        required: true
95    url:
96        description:
97            - Avi controller URL of the object.
98    uuid:
99        description:
100            - Uuid of the ipam/dns provider profile.
101extends_documentation_fragment:
102- community.network.avi
103
104'''
105
106EXAMPLES = """
107  - name: Create IPAM DNS provider setting
108    community.network.avi_ipamdnsproviderprofile:
109      controller: '{{ controller }}'
110      username: '{{ username }}'
111      password: '{{ password }}'
112      internal_profile:
113        dns_service_domain:
114        - domain_name: ashish.local
115          num_dns_ip: 1
116          pass_through: true
117          record_ttl: 100
118        - domain_name: guru.local
119          num_dns_ip: 1
120          pass_through: true
121          record_ttl: 200
122        ttl: 300
123      name: Ashish-DNS
124      tenant_ref: Demo
125      type: IPAMDNS_TYPE_INTERNAL
126"""
127
128RETURN = '''
129obj:
130    description: IpamDnsProviderProfile (api/ipamdnsproviderprofile) object
131    returned: success, changed
132    type: dict
133'''
134
135from ansible.module_utils.basic import AnsibleModule
136try:
137    from ansible_collections.community.network.plugins.module_utils.network.avi.avi import (
138        avi_common_argument_spec, avi_ansible_api, HAS_AVI)
139except ImportError:
140    HAS_AVI = False
141
142
143def main():
144    argument_specs = dict(
145        state=dict(default='present',
146                   choices=['absent', 'present']),
147        avi_api_update_method=dict(default='put',
148                                   choices=['put', 'patch']),
149        avi_api_patch_op=dict(choices=['add', 'replace', 'delete']),
150        allocate_ip_in_vrf=dict(type='bool',),
151        aws_profile=dict(type='dict',),
152        azure_profile=dict(type='dict',),
153        custom_profile=dict(type='dict',),
154        gcp_profile=dict(type='dict',),
155        infoblox_profile=dict(type='dict',),
156        internal_profile=dict(type='dict',),
157        name=dict(type='str', required=True),
158        oci_profile=dict(type='dict',),
159        openstack_profile=dict(type='dict',),
160        proxy_configuration=dict(type='dict',),
161        tenant_ref=dict(type='str',),
162        tencent_profile=dict(type='dict',),
163        type=dict(type='str', required=True),
164        url=dict(type='str',),
165        uuid=dict(type='str',),
166    )
167    argument_specs.update(avi_common_argument_spec())
168    module = AnsibleModule(
169        argument_spec=argument_specs, supports_check_mode=True)
170    if not HAS_AVI:
171        return module.fail_json(msg=(
172            'Avi python API SDK (avisdk>=17.1) or requests is not installed. '
173            'For more details visit https://github.com/avinetworks/sdk.'))
174    return avi_ansible_api(module, 'ipamdnsproviderprofile',
175                           set([]))
176
177
178if __name__ == '__main__':
179    main()
180