AWSResourceMappingBus.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #pragma once
  9. #include <AzCore/EBus/EBus.h>
  10. #include <AzCore/std/string/string.h>
  11. namespace AWSCore
  12. {
  13. //! AWSResourceMapping request interface
  14. class AWSResourceMappingRequests
  15. : public AZ::EBusTraits
  16. {
  17. public:
  18. // Allow multiple threads to concurrently make requests
  19. using MutexType = AZStd::recursive_mutex;
  20. //////////////////////////////////////////////////////////////////////////
  21. // EBusTraits overrides
  22. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  23. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  24. //////////////////////////////////////////////////////////////////////////
  25. //! GetDefaultAccountId
  26. //! Get default account id which is shared among resources
  27. //! @return Default account id in string
  28. virtual AZStd::string GetDefaultAccountId() const = 0;
  29. //! GetDefaultRegion
  30. //! Get default region which is shared among resources
  31. //! @return Default region in string
  32. virtual AZStd::string GetDefaultRegion() const = 0;
  33. //! HasResource
  34. //! Check if an AWS resource is defined
  35. //! @param resourceKeyName Resource mapping key name is used to identify individual
  36. //! resource attributes
  37. //! @return True if the resource exists; otherwise false.
  38. virtual bool HasResource(const AZStd::string& resourceKeyName) const = 0;
  39. //! GetResourceAccountId
  40. //! Get individual resource account id by using its mapping key name.
  41. //! If resource account id is not present in resource attributes, will use
  42. //! default account id instead
  43. //! @param resourceKeyName Resource mapping key name is used to identify individual
  44. //! resource attributes
  45. //! @return Resource account id in string
  46. virtual AZStd::string GetResourceAccountId(const AZStd::string& resourceKeyName) const = 0;
  47. //! GetResourceNameId
  48. //! Get individual resource name/id by using its mapping key name
  49. //! @param resourceKeyName Resource mapping key name is used to identify individual
  50. //! resource attributes
  51. //! @return Resource name/id in string
  52. virtual AZStd::string GetResourceNameId(const AZStd::string& resourceKeyName) const = 0;
  53. //! GetResourceRegion
  54. //! Get individual resource region by using its mapping key name.
  55. //! If resource region is not present in resource attributes, will use
  56. //! default region instead
  57. //! @param resourceKeyName Resource mapping key name is used to identify individual
  58. //! resource attributes
  59. //! @return Resource region in string
  60. virtual AZStd::string GetResourceRegion(const AZStd::string& resourceKeyName) const = 0;
  61. //! GetResourceType
  62. //! Get individual resource type by using its mapping key name
  63. //! @param resourceKeyName Resource mapping key name is used to identify individual
  64. //! resource attributes
  65. //! @return Resource type in string
  66. virtual AZStd::string GetResourceType(const AZStd::string& resourceKeyName) const = 0;
  67. //! GetServiceUrl
  68. //! Returns the base url for a registered APIGateway service endpoint
  69. //! @param serviceName The name of the Gem or mapping name that provides the services
  70. //! @return the service URL without a trailing / character
  71. virtual AZStd::string GetServiceUrlByServiceName(const AZStd::string& serviceName) const = 0;
  72. //! GetServiceUrl
  73. //! Returns the base url for a registered APIGateway service endpoint
  74. //! @param restApiIdKeyName The resource key name of APIGateway service REST Api id
  75. //! @param restApiStageKeyName The resource key name of APIGateway service REST Api stage
  76. //! @return the service URL without a trailing / character
  77. virtual AZStd::string GetServiceUrlByRESTApiIdAndStage(
  78. const AZStd::string& restApiIdKeyName, const AZStd::string& restApiStageKeyName) const = 0;
  79. //! ReloadConfigFile
  80. //! Reload resource mapping config file without restarting application
  81. //! @param isReloadingConfigFileName Whether reload resource mapping config file name
  82. //! from AWS core configuration settings registry file
  83. virtual void ReloadConfigFile(bool isReloadingConfigFileName) = 0;
  84. };
  85. using AWSResourceMappingRequestBus = AZ::EBus<AWSResourceMappingRequests>;
  86. } // namespace AWSCore