Can you create AWSBehavior API calls from C++?

Hi,

Is the feature of creating api calls with the CloudGemAWSScriptBehaviors intended to only be used by Lua? I am having trouble instantiating a CloudGemAWSScriptBehaviors::AWSBehaviorAPI class to begin structuring an API call and was curious if this was a feature intended for C++ or strictly for Lua.

My personal gem is currently connected to the APINotificationBus and am able to override the pure virtual functions such as GetResponse, OnError, and OnSuccess.

Error when trying to instantiate an API class:

Creating library c:\Amazon\Lumberyard\1.13.0.0\dev\Bin64vc140\Gem.IwMMO.de27effa01ec4b18ba00cd993b8adb63.v0.1.0.lib and object c:\Amazon\Lumberyard\1.13.0.0\dev\Bin64vc140\Gem.IwMMO.de27effa01ec4b18ba00cd993b8adb63.v0.1.0.exp
LoginManagerSystemComponent.cpp.162.obj : error LNK2019: unresolved external symbol "public: __cdecl CloudGemAWSScriptBehaviors::AWSBehaviorAPI::AWSBehaviorAPI(void)" (??0AWSBehaviorAPI@CloudGemAWSScriptBehaviors@@QEAA@XZ) referenced in function "protected: virtual void __cdecl IwMMO::LoginManagerSystemComponent::GetPlayerProfile(int)" (?GetPlayerProfile@LoginManagerSystemComponent@IwMMO@@MEAAXH@Z)
c:\Amazon\Lumberyard\1.13.0.0\dev\Bin64vc140\Gem.IwMMO.de27effa01ec4b18ba00cd993b8adb63.v0.1.0.dll : fatal error LNK1120: 1 unresolved externals

Hi @naotoy,

All ebuses are accessible in C++, functions that are refelcted to the behavior context are accessible in Lua and Script Canvas as well

Ex: the ones reflected in void AWSBehaviorHTTP::ReflectBehaviors(AZ::BehaviorContext* behaviorContext)

Just to be sure you have the CloudGemFramework and CloudCanvasCommon dependencies in your project as well right?

dev\Gems\CloudGemAWSScriptBehaviors\gems.json.

Hi naotoy,

Thanks for posting! From my understanding that class was intended to allow developers to execute service API’s directly from LUA. I’ll confirm with the rest of the team and get back to you on Monday.

Cheers!

Hi @FelixLYCC !

I do have both of those dependencies included and have my handlers set as well as the pure virtual functions in place to receive notifications.

Could you possibly explain to me how you would do the C++ equivalent of this Lua example?

        local apiCall = AWSBehaviorAPI()
apiCall.ResourceName = "myResource.ServiceApi"
apiCall.Query = "/my/personal/api/path/"
apiCall:Execute()

I imagined it would have been with utilizing the ‘CloudGemAWSScriptBehaviors::AWSBehaviorAPI’ class from ‘Gems\CloudGemAWSScriptBehaviors\Code\Source\AWSBehaviorAPI.h’ looking something like this:

const CloudGemAWSScriptBehaviors::AWSBehaviorAPI apiCall;
apiCall.m_resourceName = "myResource.ServiceApi"
apiCall.m_query = "my/personal/api/path"
apiCall.m_httpMethod = "GET"

… or something like that?

Hi @naotoy,

So after digging a little more into this, you would need to add an ebus handler to the AWSScriptBehavior gem to set those variables. Given that the AWSScriptBehavior is mainly a wrapper around the AWS C++ sdk functions to make them available to Lua and Scipt Canvas you might just want to call the C++ functions rather than use the AWSScriptBehavior.

Hope that helps

Hi @FelixLYCC

Makes a lot of sense! Thank you!