Skip to content

Commit 1302819

Browse files
committed
Clarify parameter names and aliases for DW modules
Signed-off-by: Webster Mudge <wmudge@cloudera.com>
1 parent 02749f8 commit 1302819

File tree

6 files changed

+62
-52
lines changed

6 files changed

+62
-52
lines changed

plugins/modules/dw_cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
# Delete a Data Warehouse Cluster
143143
- cloudera.cloud.dw_cluster:
144144
state: absent
145-
id: my-id
145+
cluster_id: my-id
146146
147147
# Delete the Data Warehouse Cluster within the Environment
148148
- cloudera.cloud.dw_cluster:

plugins/modules/dw_cluster_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
6666
# Gather information about an identified Cluster
6767
- cloudera.cloud.dw_cluster_info:
68-
id: env-xyzabc
68+
cluster_id: env-xyzabc
6969
'''
7070

7171
RETURN = r'''

plugins/modules/dw_database_catalog.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
requirements:
3636
- cdpy
3737
options:
38-
id:
38+
catalog_id:
3939
description:
4040
- The identifier of the Database Catalog.
4141
- Required if C(state=absent).
4242
type: str
43+
aliases:
44+
- id
4345
cluster_id:
4446
description:
4547
- The identifier of the parent DW Cluster of the Database Catalog.
@@ -91,7 +93,7 @@
9193
9294
# Delete Database Catalog
9395
- cloudera.cloud.dw_database_catalog:
94-
id: example-database-id
96+
catalog_id: example-database-id
9597
cluster_id: example-cluster-id
9698
state: absent
9799
'''
@@ -127,12 +129,12 @@
127129
'''
128130

129131

130-
class DwDbc(CdpModule):
132+
class DwDatabaseCatalog(CdpModule):
131133
def __init__(self, module):
132-
super(DwDbc, self).__init__(module)
134+
super(DwDatabaseCatalog, self).__init__(module)
133135

134136
# Set variables
135-
self.id = self._get_param('id')
137+
self.catalog_id = self._get_param('catalog_id')
136138
self.cluster_id = self._get_param('cluster_id')
137139
self.name = self._get_param('name')
138140
self.load_demo_data = self._get_param('load_demo_data')
@@ -153,13 +155,13 @@ def __init__(self, module):
153155

154156
@CdpModule._Decorators.process_debug
155157
def process(self):
156-
if self.id is None:
158+
if self.catalog_id is None:
157159
dbcs = self.cdpy.dw.list_dbcs(cluster_id=self.cluster_id)
158160
for dbc in dbcs:
159161
if dbc['name'] == self.name:
160162
self.target = self.cdpy.dw.describe_dbc(cluster_id=self.cluster_id, dbc_id=dbc['id'])
161163
else:
162-
self.target = self.cdpy.dw.describe_dbc(cluster_id=self.cluster_id, dbc_id=self.id)
164+
self.target = self.cdpy.dw.describe_dbc(cluster_id=self.cluster_id, dbc_id=self.catalog_id)
163165

164166
if self.target is not None:
165167
# Begin Database Catalog Exists
@@ -222,7 +224,7 @@ def process(self):
222224
def main():
223225
module = AnsibleModule(
224226
argument_spec=CdpModule.argument_spec(
225-
id=dict(type='str'),
227+
catalog_id=dict(type='str', aliases=['catalog_id']),
226228
cluster_id=dict(required=True, type='str'),
227229
name = dict(type='str'),
228230
load_demo_data=dict(type='bool'),
@@ -239,7 +241,7 @@ def main():
239241
supports_check_mode=True
240242
)
241243

242-
result = DwDbc(module)
244+
result = DwDatabaseCatalog(module)
243245
output = dict(changed=result.changed, database_catalog=result.database_catalog)
244246

245247
if result.debug:

plugins/modules/dw_database_catalog_info.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@
3535
requirements:
3636
- cdpy
3737
options:
38-
id:
38+
catalog_id:
3939
description:
4040
- The identifier of the Database Catalog.
4141
- If undefined, will return a list of all Database Catalogs in the Cluster.
4242
- Exclusive with I(name).
4343
type: str
44+
aliases:
45+
- id
4446
cluster_id:
4547
description:
4648
- The identifier of the parent Cluster of the Database Catalog or Catalogs.
@@ -102,12 +104,12 @@
102104
'''
103105

104106

105-
class DwDbcInfo(CdpModule):
107+
class DwDatabaseCatalogInfo(CdpModule):
106108
def __init__(self, module):
107-
super(DwDbcInfo, self).__init__(module)
109+
super(DwDatabaseCatalogInfo, self).__init__(module)
108110

109111
# Set variables
110-
self.id = self._get_param('id')
112+
self.catalog_id = self._get_param('catalog_id')
111113
self.cluster_id = self._get_param('cluster_id')
112114
self.name = self._get_param('name')
113115

@@ -119,8 +121,8 @@ def __init__(self, module):
119121

120122
@CdpModule._Decorators.process_debug
121123
def process(self):
122-
if self.id is not None:
123-
target = self.cdpy.dw.describe_dbc(cluster_id=self.cluster_id, dbc_id=self.id)
124+
if self.catalog_id is not None:
125+
target = self.cdpy.dw.describe_dbc(cluster_id=self.cluster_id, dbc_id=self.catalog_id)
124126
if target is not None:
125127
self.database_catalogs.append(target)
126128
else:
@@ -136,15 +138,15 @@ def process(self):
136138
def main():
137139
module = AnsibleModule(
138140
argument_spec=CdpModule.argument_spec(
139-
id=dict(type='str'),
141+
catalog_id=dict(type='str', aliases=['id']),
140142
cluster_id=dict(required=True, type='str'),
141143
name = dict(type='str'),
142144
),
143145
mutually_exclusive=[['id', 'name']],
144146
supports_check_mode=True
145147
)
146148

147-
result = DwDbcInfo(module)
149+
result = DwDatabaseCatalogInfo(module)
148150
output = dict(changed=False, database_catalogs=result.database_catalogs)
149151

150152
if result.debug:

plugins/modules/dw_virtual_warehouse.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,26 @@
3535
requirements:
3636
- cdpy
3737
options:
38-
id:
38+
warehouse_id:
3939
description:
4040
- The identifier of the Virtual Warehouse.
4141
- Required if C(state=absent).
4242
type: str
4343
aliases:
4444
- vw_id
45+
- id
4546
cluster_id:
4647
description:
4748
- The identifier of the parent Data Warehouse Cluster of the Virtual Warehouse.
4849
type: str
4950
required: True
50-
dbc_id:
51+
catalog_id:
5152
description:
5253
- The identifier of the parent Database Catalog attached to the Virtual Warehouse.
5354
- Required if C(state=present)
5455
type: str
56+
aliases:
57+
- dbc_id
5558
type:
5659
description:
5760
- The type of Virtual Warehouse to be created.
@@ -239,7 +242,7 @@
239242
# Delete a Virtual Warehouse
240243
- cloudera.cloud.dw_virtual_warehouse:
241244
cluster_id: example-cluster-id
242-
id: example-virtual-warehouse-id
245+
warehouse_id: example-virtual-warehouse-id
243246
state: absent
244247
'''
245248

@@ -310,14 +313,14 @@
310313
'''
311314

312315

313-
class DwVw(CdpModule):
316+
class DwVirtualWarehouse(CdpModule):
314317
def __init__(self, module):
315-
super(DwVw, self).__init__(module)
318+
super(DwVirtualWarehouse, self).__init__(module)
316319

317320
# Set variables
318-
self.id = self._get_param('id')
321+
self.warehouse_id = self._get_param('warehouse_id')
319322
self.cluster_id = self._get_param('cluster_id')
320-
self.dbc_id = self._get_param('dbc_id')
323+
self.dbc_id = self._get_param('catalog_id')
321324
self.type = self._get_param('type')
322325
self.name = self._get_param('name')
323326
self.template = self._get_param('template')
@@ -345,13 +348,13 @@ def __init__(self, module):
345348

346349
@CdpModule._Decorators.process_debug
347350
def process(self):
348-
if self.id is None:
351+
if self.warehouse_id is None:
349352
vws = self.cdpy.dw.list_vws(cluster_id=self.cluster_id)
350353
for vw in vws:
351354
if self.name is not None and vw['name'] == self.name:
352355
self.target = self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=vw['id'])
353356
else:
354-
self.target = self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=self.id)
357+
self.target = self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=self.warehouse_id)
355358

356359
if self.target is not None:
357360
# Begin Virtual Warehouse Exists
@@ -422,9 +425,9 @@ def process(self):
422425
def main():
423426
module = AnsibleModule(
424427
argument_spec=CdpModule.argument_spec(
425-
id=dict(type='str', aliases=['vw_id']),
428+
warehouse_id=dict(type='str', aliases=['vw_id', 'id']),
426429
cluster_id=dict(required=True, type='str'),
427-
dbc_id=dict(type='str'),
430+
catalog_id=dict(type='str', aliases=['dbc_id']),
428431
type = dict(type='str'),
429432
name = dict(type='str'),
430433
template=dict(type='str', choices=['xsmall', 'small', 'medium', 'large']),
@@ -451,13 +454,13 @@ def main():
451454
timeout = dict(type='int', aliases=['polling_timeout'], default=3600)
452455
),
453456
required_if=[
454-
['state', 'absent', ['id']],
455-
['state', 'present', ['dbc_id', 'type', 'name']]
457+
['state', 'absent', ['warehouse_id']],
458+
['state', 'present', ['catalog_id', 'type', 'name']]
456459
],
457460
supports_check_mode=True
458461
)
459462

460-
result = DwVw(module)
463+
result = DwVirtualWarehouse(module)
461464
output = dict(changed=result.changed, virtual_warehouse=result.virtual_warehouse)
462465

463466
if result.debug:

plugins/modules/dw_virtual_warehouse_info.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,32 @@
3535
requirements:
3636
- cdpy
3737
options:
38-
id:
38+
warehouse_id:
3939
description:
4040
- The identifier of the Virtual Warehouse.
4141
- Requires I(cluster_id).
42-
- Mutually exclusive with I(name) and I(dbc_id).
42+
- Mutually exclusive with I(name) and I(catalog_id).
4343
type: str
4444
aliases:
4545
- vw_id
46+
- id
4647
cluster_id:
4748
description:
4849
- The identifier of the parent Data Warehouse Cluster of the Virtual Warehouse(s).
4950
type: str
50-
dbc_id:
51+
catalog_id:
5152
description:
5253
- The identifier of the parent Database Catalog attached to the Virtual Warehouse(s).
5354
- Requires I(cluster_id).
54-
- Mutally exclusive with I(id) and I(name).
55+
- Mutally exclusive with I(warehouse_id) and I(name).
5556
type: str
57+
aliases:
58+
- dbc_id
5659
name:
5760
description:
5861
- The name of the Virtual Warehouse.
5962
- Requires I(cluster_id).
60-
- Mutually exclusive with I(id) and I(dbc_id).
63+
- Mutually exclusive with I(warehouse_id) and I(catalog_id).
6164
type: str
6265
delay:
6366
description:
@@ -90,12 +93,12 @@
9093
# List all Virtual Warehouses associated with a Data Catalog
9194
- cloudera.cloud.dw_virtual_warehouse_info:
9295
cluster_id: example-cluster-id
93-
dbc_id: example-data-catalog-id
96+
catalog_id: example-data-catalog-id
9497
9598
# Describe a Virtual Warehouse by ID
9699
- cloudera.cloud.dw_virtual_warehouse_info:
97100
cluster_id: example-cluster-id
98-
id: example-virtual-warehouse-id
101+
warehouse_id: example-virtual-warehouse-id
99102
100103
# Describe a Virtual Warehouse by name
101104
- cloudera.cloud.dw_virtual_warehouse_info:
@@ -171,14 +174,14 @@
171174
'''
172175

173176

174-
class DwVwInfo(CdpModule):
177+
class DwVirtualWarehouseInfo(CdpModule):
175178
def __init__(self, module):
176-
super(DwVwInfo, self).__init__(module)
179+
super(DwVirtualWarehouseInfo, self).__init__(module)
177180

178181
# Set variables
179-
self.id = self._get_param('id')
182+
self.warehouse_id = self._get_param('warehouse_id')
180183
self.cluster_id = self._get_param('cluster_id')
181-
self.dbc_id = self._get_param('dbc_id')
184+
self.catalog_id = self._get_param('catalog_id')
182185
self.type = self._get_param('type')
183186
self.name = self._get_param('name')
184187
self.delay = self._get_param('delay')
@@ -192,8 +195,8 @@ def __init__(self, module):
192195

193196
@CdpModule._Decorators.process_debug
194197
def process(self):
195-
if self.id is not None:
196-
target = self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=self.id)
198+
if self.warehouse_id is not None:
199+
target = self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=self.warehouse_id)
197200
if target is not None:
198201
self.virtual_warehouses.append(target)
199202
else:
@@ -204,29 +207,29 @@ def process(self):
204207
self.virtual_warehouses.append(
205208
self.cdpy.dw.describe_vw(cluster_id=self.cluster_id, vw_id=vw['id'])
206209
)
207-
elif self.dbc_id is not None:
208-
self.virtual_warehouses =[v for v in vws if v['dbcId'] == self.dbc_id]
210+
elif self.catalog_id is not None:
211+
self.virtual_warehouses =[v for v in vws if v['dbcId'] == self.catalog_id]
209212
else:
210213
self.virtual_warehouses = vws
211214

212215

213216
def main():
214217
module = AnsibleModule(
215218
argument_spec=CdpModule.argument_spec(
216-
id=dict(type='str', aliases=['vw_id']),
219+
warehouse_id=dict(type='str', aliases=['vw_id', 'id']),
217220
cluster_id=dict(required=True, type='str'),
218-
dbc_id=dict(type='str'),
221+
catalog_id=dict(type='str', aliases=['dbc_id']),
219222
name=dict(type='str'),
220223
delay=dict(type='int', aliases=['polling_delay'], default=15),
221224
timeout=dict(type='int', aliases=['polling_timeout'], default=3600)
222225
),
223226
mutually_exclusive=[
224-
['id', 'name', 'dbc_id']
227+
['warehouse_id', 'name', 'catalog_id']
225228
],
226229
supports_check_mode=True
227230
)
228231

229-
result = DwVwInfo(module)
232+
result = DwVirtualWarehouseInfo(module)
230233
output = dict(changed=False, virtual_warehouses=result.virtual_warehouses)
231234

232235
if result.debug:

0 commit comments

Comments
 (0)