Create module ansible

Hi guys,

I maned be creating ansible module for generating name my resources a cloud, but need before defined fields know this type of resource.
I wanna valid field type before declared other fields.

Ex.:
fields = {“type”: {“required”: False, “type”: “str”}}
module = AnsibleModule(argument_spec=fields)

if module.params[‘type’] == ‘vm’:
fields = {
“entity”: {“required”: False, “type”: “str”},
“region”: {“required”: False, “type”: “str”},
“product”: {“default”: False, “type”: “str” },
“environment”: {“default”: False, “type”: “str” },
“resource”: {“required”: False, “type”: “str” },
“os”: {“default”: False, “type”: “str” },
“type”: {“required”: True, “type”: “str”},
}
else:
fields = {
“entity”: {“required”: True, “type”: “str”},
“region”: {“required”: True, “type”: “str”},
“product”: {“default”: True, “type”: “str” },
“environment”: {“default”: True, “type”: “str” },
“purpose”: {“default”: True, “type”: “str” },
“resource”: {“required”: True, “type”: “str” },
“acronym”: {“default”: True, “type”: “str” },
“type”: {“required”: True, “type”: “str”},
}

module = AnsibleModule(argument_spec=fields)

but return error msg: ‘Unsupported parameters for (generate_name) module: entity, environment, os, product, region, resource Supported parameters include: type’

How can valid type value?