AWSResourceMappingUtils.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <ResourceMapping/AWSResourceMappingConstants.h>
  9. #include <ResourceMapping/AWSResourceMappingUtils.h>
  10. namespace AWSCore
  11. {
  12. namespace AWSResourceMappingUtils
  13. {
  14. // https://docs.aws.amazon.com/general/latest/gr/apigateway.html
  15. static constexpr char RESTApiUrlFormat[] = "https://%s.execute-api.%s.amazonaws.com/%s";
  16. static constexpr char RESTApiChinaUrlFormat[] = "https://%s.execute-api.%s.amazonaws.com.cn/%s";
  17. AZStd::string FormatRESTApiUrl(
  18. const AZStd::string& restApiId, const AZStd::string& restApiRegion, const AZStd::string& restApiStage)
  19. {
  20. // https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-api.html
  21. if (!restApiId.empty() && !restApiRegion.empty() && !restApiStage.empty())
  22. {
  23. if (restApiRegion.rfind(AWSChinaRegionPrefix, 0) == 0)
  24. {
  25. return AZStd::string::format(RESTApiChinaUrlFormat,
  26. restApiId.c_str(), restApiRegion.c_str(), restApiStage.c_str());
  27. }
  28. else
  29. {
  30. return AZStd::string::format(RESTApiUrlFormat,
  31. restApiId.c_str(), restApiRegion.c_str(), restApiStage.c_str());
  32. }
  33. }
  34. return "";
  35. }
  36. } // namespace AWSResourceMappingUtils
  37. } // namespace AWSCore