local json = require "cjson" 
require "luis.logger" -- require utilizado para pm-cli/provisioningmanager
local utils = require "luis.utils"

--------------------
-- version API 2.0
local apps2_0 = require "luis.v2_0.apps"
local azure2_0 = require "luis.v2_0.azure"
local entitiesSimple2_0 = require "luis.v2_0.entitiesSimple"
local entitiesComposite2_0 = require "luis.v2_0.entitiesComposite"
local entitiesHierarchical2_0 = require "luis.v2_0.entitiesHierarchical"
local entitiesPrebuilt2_0 = require "luis.v2_0.entitiesPrebuilt"
local features2_0 = require "luis.v2_0.features"
local intents2_0 = require "luis.v2_0.intents"
local webapi2_0 = require "luis.v2_0.webapi"
--------------------
-- version API 3.0-PREVIEW
local apps3_0 = require "luis.v3_0.apps"
local azure3_0 = require "luis.v3_0.azure"
local entitiesMachineLearned3_0 = require "luis.v3_0.entitiesMachineLearned"
local entitiesComposite3_0 = require "luis.v3_0.entitiesComposite"
local entitiesHierarchical3_0 = require "luis.v3_0.entitiesHierarchical"
local entitiesPrebuilt3_0 = require "luis.v3_0.entitiesPrebuilt"
local features3_0 = require "luis.v3_0.features"
local intents3_0 = require "luis.v3_0.intents"
local webapi3_0 = require "luis.v3_0.webapi"
--------------------
-- version API 2022-10-01-preview
local apps4_0 = require "luis.v4_0.apps"
local azure4_0 = require "luis.v4_0.azure"
local entitiesMachineLearned4_0 = require "luis.v4_0.entitiesMachineLearned"
local entitiesComposite4_0 = require "luis.v4_0.entitiesComposite"
local entitiesPrebuilt4_0 = require "luis.v4_0.entitiesPrebuilt"
local features4_0 = require "luis.v4_0.features"
local intents4_0 = require "luis.v4_0.intents"
local webapi4_0 = require "luis.v4_0.webapi"
--------------------

local LUIS_API_VERSIONS = {
	["DEFAULT"] = {
		apps = apps2_0,
		azure = azure2_0,
		entitiesSimple = entitiesSimple2_0,
		entitiesComposite = entitiesComposite2_0,
		entitiesHierarchical = entitiesHierarchical2_0,
		entitiesPrebuilt = entitiesPrebuilt2_0,
		features = features2_0,
		intents = intents2_0,
		webapi = webapi2_0
	},
	["2.0"] = {
		apps = apps2_0,
		azure = azure2_0,
		entitiesSimple = entitiesSimple2_0,
		entitiesComposite = entitiesComposite2_0,
		entitiesHierarchical = entitiesHierarchical2_0,
		entitiesPrebuilt = entitiesPrebuilt2_0,
		features = features2_0,
		intents = intents2_0,
		webapi = webapi2_0
	},
	["3.0-PREVIEW"] = {
		apps = apps3_0,
		azure = azure3_0,
		entitiesSimple = entitiesSimple3_0,
		entitiesMachineLearned = entitiesMachineLearned3_0,
		entitiesComposite = entitiesComposite3_0,
		entitiesHierarchical = entitiesHierarchical3_0,
		entitiesPrebuilt = entitiesPrebuilt3_0,
		features = features3_0,
		intents = intents3_0,
		webapi = webapi3_0
	},
	["2022-10-01-preview"] = {
		apps = apps4_0,
		azure = azure4_0,
		entitiesSimple = entitiesSimple4_0,
		entitiesMachineLearned = entitiesMachineLearned4_0,
		entitiesComposite = entitiesComposite4_0,
		entitiesPrebuilt = entitiesPrebuilt4_0,
		features = features4_0,
		intents = intents4_0,
		webapi = webapi4_0
	},
	["LAST"] = {
		apps = apps4_0,
		azure = azure4_0,
		entitiesSimple = entitiesSimple4_0,
		entitiesMachineLearned = entitiesMachineLearned4_0,
		entitiesComposite = entitiesComposite4_0,
		entitiesPrebuilt = entitiesPrebuilt4_0,
		features = features4_0,
		intents = intents4_0,
		webapi = webapi4_0
	}
}

local m_instanceOwner
function SetOwner (instanceOwner)
	LogDebug("[LUIS_APPS_BASE] SetOwner Base")
	m_instanceOwner = instanceOwner

	for n, m in pairs(LUIS_API_VERSIONS) do
		for name, module in pairs(m) do
			if type(module) == "table" and module.SetOwner then
				module.SetOwner(m_instanceOwner)
			end
		end
	end
end

module(..., package.seeall)

function GetAssignedAzureAccountsResourceInApp (appId, info, vcc, api_version)
	LogInfo(" ------> BASE.GetAssignedAzureAccountsResourceInApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.GetAssignedAzureAccountsResource(appId, info, vcc)
end

function GetApp (appId, vcc, api_version)
	LogInfo(" ------> BASE.GetApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.Get(appId, vcc)
end

function AddApp (info, vcc, api_version)
	LogInfo(" ------> BASE.AddApp - info: %s", json.encode(info))
	LogInfo(" ------> BASE.AddApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.Add(info, vcc)
end

function ExecuteApiLCU (endpointUrl, message, appId, subscriptionKey, language, verbose, timezone)
	return LUIS_API_VERSIONS["2022-10-01-preview"].apps.ExecuteApiLCU(endpointUrl, message, appId, subscriptionKey, language, verbose, timezone)
end

function RenameApp (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.Rename(info, vcc)
end

function DeleteApp (appId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.Delete(appId, vcc)
end

function UnassignAzureAccountsResourceOfApp (appId, vcc, api_version)
	LogInfo(" ------> BASE.UnassignAzureAccountsResourceOfApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.UnassignAzureAccountsResourceOfApp(appId, vcc)
end

function UnassignAzureAccountsResourceOfAppWebApi (appId, vcc, api_version)
	LogInfo(" ------> BASE.UnassignAzureAccountsResourceOfAppWebApi - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].webapi.UnassignAzureAccountsResourceOfApp(appId, vcc)
end

function AssignAzureAccountsResourceToApp (appId, vcc, api_version)
	LogInfo(" ------> BASE.AssignAzureAccountsResourceToApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.AssignAzureAccountsResourceToApp(appId, vcc)
end

function AssignAzureAccountsResourceToAppWebApi (appId, vcc, api_version)
	LogInfo(" ------> BASE.AssignAzureAccountsResourceToAppWebApi - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].webapi.AssignAzureAccountsResourceToApp(appId, vcc)
end

function PublishApp (appId, info, vcc, api_version)
	LogInfo(" ------> BASE.PublishApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.PublishApp(appId, info, vcc)
end

function GetTrainApp (appId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetTrainApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.GetTrainApp(appId, versionId, vcc)
end

function TrainApp (info, vcc, api_version)
	LogInfo(" ------> BASE.TrainApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.TrainApp(info, vcc)
end

function GetTrainStatus (info, vcc, api_version, operationLocation)
	LogInfo(" ------> BASE.GetTrainStatus - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.GetTrainStatus(info, vcc, operationLocation)
end

function GetAppVersion (appId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppVersion - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.GetAppVersion(appId, versionId, vcc)
end

function LoadAppVersions (appId, paginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAppVersions - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.LoadAppVersions(appId, paginated, vcc)
end

function ExportApp (appId, versionId, exportFormat, vcc, api_version)
	LogInfo(" ------> BASE.ExportApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.ExportApp(appId, versionId, exportFormat, vcc)
end

function ImportApp (vcc, appData, optionalName, api_version)
	LogInfo(" ------> BASE.ImportApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.ImportApp(appData, optionalName, vcc)
end

function LoadAppCultures (vcc, api_version)
	LogInfo(" ------> BASE.LoadAppCultures - api_version: %s, vcc: %s", api_version, vcc)

	local status, response = LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "LAST"].apps.LoadAppCultures(vcc, api_version)

	if not status then
		status, response = LUIS_API_VERSIONS["DEFAULT"].apps.LoadAppCultures(vcc, api_version)
	end

	return status, response
end

function LoadAppCulturesForIntents (vcc)
	LogInfo(" ------> BASE.LoadAppCulturesForIntents - vcc: %s", vcc)
	
	local status, response = LUIS_API_VERSIONS["LAST"].apps.LoadAppCulturesForIntents(vcc, api_version)

	if not status then
		status, response = LUIS_API_VERSIONS["DEFAULT"].apps.LoadAppCultures(vcc, api_version)
	end

	return status, response
end

function DeleteAppSuggestedUtterance (appId, utteranceName, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppSuggestedUtterance - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].apps.DeleteAppSuggestedUtterance(appId, utteranceName, versionId, vcc)
end

function LoadAllAppIntents (appId, versionId, paginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppIntents - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.LoadAllAppIntents(appId, versionId, paginated, vcc)
end

function GetAppIntent (appId, intentId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.GetAppIntent(appId, intentId, versionId, vcc)
end

function CreateAppIntent (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppIntent - info: %s", json.encode(info))
	LogInfo(" ------> BASE.CreateAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.CreateAppIntent(info, vcc)
end

function RenameAppIntent (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.RenameAppIntent(info, vcc)
end

function DeleteAppIntent (appId, intentId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.DeleteAppIntent(appId, intentId, versionId, vcc)
end

function LoadPagingUtterancesForApp (appId, versionId, paginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadPagingUtterancesForApp - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.LoadPagingUtterancesForApp(appId, versionId, paginated, vcc)
end

function LoadUtterancesByAppIntent (appId, intentId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.LoadUtterancesByAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.LoadUtterancesByAppIntent(appId, versionId, intentId, vcc)
end

function LoadSuggestedUtterancesByAppIntent (appId, intentId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.LoadSuggestedUtterancesByAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.LoadSuggestedUtterancesByAppIntent(appId, versionId, intentId, vcc)
end

function AddUtteranceAppIntent (info, vcc, api_version)
	LogInfo(" ------> BASE.AddUtteranceAppIntent - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.AddUtteranceAppIntent(info, vcc)
end

function DeleteAppUtterance (appId, utteranceId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppUtterance - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].intents.DeleteAppUtterance(appId, utteranceId, versionId, vcc)
end

function LoadAllAppEntitiesSimple (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppEntitiesSimple - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesSimple.LoadAllAppEntities(appId, versionId, encodedPaginated, vcc)
end

function LoadAllAppEntitiesMachineLearned (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppEntitiesMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.LoadAllAppEntities(appId, versionId, encodedPaginated, vcc)
end

function GetAppEntitySimple (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppEntitySimple - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesSimple.GetAppEntity(appId, entityId, versionId, vcc)
end

function GetAppEntityMachineLearned (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppEntityMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.GetAppEntity(appId, entityId, versionId, vcc)
end

function CreateAppEntitySimple (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppEntitySimple - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesSimple.CreateAppEntity(info, vcc)
end

function CreateAppEntityMachineLearned (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppEntityMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.CreateAppEntity(info, vcc)
end

function RenameAppEntitySimple (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameAppEntitySimple - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesSimple.RenameAppEntity(info, vcc)
end

function RenameAppEntityMachineLearned (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameAppEntityMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.RenameAppEntity(info, vcc)
end

function DeleteAppEntitySimple (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppEntitySimple - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesSimple.DeleteAppEntity(appId, entityId, versionId, vcc)
end

function DeleteAppEntityMachineLearned (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppEntityMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.DeleteAppEntity(appId, entityId, versionId, vcc)
end

function CreateAppEntityChildMachineLearned (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppEntityChildMachineLearned - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesMachineLearned.CreateAppEntityChild(info, vcc)
end

function LoadAllAppEntitiesComposite (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppEntitiesComposite - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesComposite.LoadAllAppEntities(appId, versionId, encodedPaginated, vcc)
end

function GetAppEntityComposite (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppEntityComposite - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesComposite.GetAppEntity(appId, entityId, versionId, vcc)
end

function CreateAppEntityComposite (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppEntityComposite - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesComposite.CreateAppEntity(info, vcc)
end

function RenameAppEntityComposite (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameAppEntityComposite - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesComposite.RenameAppEntity(info, vcc)
end

function DeleteAppEntityComposite (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppEntityComposite - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesComposite.DeleteAppEntity(appId, entityId, versionId, vcc)
end

function LoadAllAppEntitiesHierarchical (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppEntitiesHierarchical - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesHierarchical.LoadAllAppEntities(appId, versionId, encodedPaginated, vcc)
end

function GetAppEntityHierarchical (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.GetAppEntityHierarchical - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesHierarchical.GetAppEntity(appId, entityId, versionId, vcc)
end

function CreateAppEntityHierarchical (info, vcc, api_version)
	LogInfo(" ------> BASE.CreateAppEntityHierarchical - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesHierarchical.CreateAppEntity(info, vcc)
end

function RenameAppEntityHierarchical (info, vcc, api_version)
	LogInfo(" ------> BASE.RenameAppEntityHierarchical - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesHierarchical.RenameAppEntity(info, vcc)
end

function DeleteAppEntityHierarchical (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppEntityHierarchical - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesHierarchical.DeleteAppEntity(appId, entityId, versionId, vcc)
end

function LoadAllAppEntitiesPrebuilt (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppEntitiesPrebuilt - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesPrebuilt.LoadAllAppEntities(appId, versionId, encodedPaginated, vcc)
end

function AddAppEntityPrebuilt (info, vcc, api_version)
	LogInfo(" ------> BASE.AddAppEntityPrebuilt - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesPrebuilt.CreateAppEntity(info, vcc)
end

function DeleteAppEntityPrebuilt (appId, entityId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeleteAppEntityPrebuilt - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesPrebuilt.DeleteAppEntity(appId, entityId, versionId, vcc)
end

function LoadAvailablePrebuiltEntityList (appId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.LoadAvailablePrebuiltEntityList - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].entitiesPrebuilt.LoadAvailablePrebuiltList(appId, versionId, vcc)
end

function LoadAllAppFeatures (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppFeatures - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].features.LoadAllAppFeatures(appId, versionId, encodedPaginated, vcc)
end

function LoadAllAppFeaturesPhraselist (appId, versionId, encodedPaginated, vcc, api_version)
	LogInfo(" ------> BASE.LoadAllAppFeaturesPhraselist - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].features.LoadAllAppFeaturesPhraselist(appId, versionId, encodedPaginated, vcc)
end

function CreatePhraselist (info, vcc, api_version)
	LogInfo(" ------> BASE.CreatePhraselist - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].features.CreatePhraselist(info, vcc)
end

function UpdatePhraselist (info, vcc, api_version)
	LogInfo(" ------> BASE.UpdatePhraselist - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].features.UpdatePhraselist(info, vcc)
end

function DeletePhraselist (appId, phraseListId, versionId, vcc, api_version)
	LogInfo(" ------> BASE.DeletePhraselist - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].features.DeletePhraselist(appId, phraseListId, versionId, vcc)
end

function LoadDefaultTenantAzureAccount (vcc, api_version)
	LogInfo(" ------> BASE.LoadDefaultTenantAzureAccount - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].azure.LoadDefaultTenantAzureAccount(vcc)
end

function LoadTenantAndAzureAccountAndToken (vcc, api_version)
	LogInfo(" ------> BASE.LoadTenantAndAzureAccountAndToken - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].azure.LoadAzureAccountAndToken(vcc)
end

function LoadAzureAccounts (info, vcc, api_version)
	LogInfo(" ------> BASE.LoadAzureAccounts - api_version: %s, vcc: %s", api_version, vcc)
	return LUIS_API_VERSIONS[(#tostring(api_version) > 0 and tostring(api_version) ~= "undefined") and api_version or "DEFAULT"].azure.LoadAzureAccounts(info, vcc)
end
