def create_zone(module, gcdns, zone):
 description = module.params['description']
 extra = dict(description=description)
 zone_name = module.params['zone']
 if (zone_name[(-1)] != '.'):
  zone_name = (zone_name + '.')
 if (zone is not None):
  return False
 try:
  if (not module.check_mode):
   gcdns.create_zone(domain=zone_name, extra=extra)
  return True
 except ResourceExistsError:
  return False
 except InvalidRequestError as error:
  if (error.code == 'invalid'):
   module.fail_json(msg=('zone name is not a valid DNS name: %s' % zone_name), changed=False)
  elif (error.code == 'managedZoneDnsNameNotAvailable'):
   module.fail_json(msg=('zone name is reserved or already in use: %s' % zone_name), changed=False)
  elif (error.code == 'verifyManagedZoneDnsNameOwnership'):
   module.fail_json(msg=('ownership of zone %s needs to be verified at %s' % (zone_name, ZONE_VERIFICATION_URL)), changed=False)
  else:
   raise

def create_zone ( module , gcdns , zone ) : description = module . params [ 'description' ] extra = dict ( description = description ) zone_name = module . params [ 'zone' ] if ( zone_name [ ( - 1 ) ] != '.' ) : zone_name = ( zone_name + '.' ) if ( zone is not None ) : return False try : if ( not module . check_mode ) : gcdns . create_zone ( domain = zone_name , extra = extra ) return True except ResourceExistsError : return False except InvalidRequestError as error : if ( error . code == 'invalid' ) : module . fail_json ( msg = ( 'zone name is not a valid DNS name: %s' % zone_name ) , changed = False ) elif ( error . code == 'managedZoneDnsNameNotAvailable' ) : module . fail_json ( msg = ( 'zone name is reserved or already in use: %s' % zone_name ) , changed = False ) elif ( error . code == 'verifyManagedZoneDnsNameOwnership' ) : module . fail_json ( msg = ( 'ownership of zone %s needs to be verified at %s' % ( zone_name , ZONE_VERIFICATION_URL ) ) , changed = False ) else : raise
create a new zone .