AWSCoreConfiguration.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/std/string/string.h>
  10. #include <AWSCoreInternalBus.h>
  11. namespace AWSCore
  12. {
  13. //! Responsible for handling configuration for AWSCore gem
  14. //! TODO: Expose internal field through edit behavior if required
  15. class AWSCoreConfiguration
  16. : AWSCoreInternalRequestBus::Handler
  17. {
  18. public:
  19. static constexpr const char AWSCoreConfigurationName[] = "AWSCoreConfiguration";
  20. static constexpr const char AWSCoreConfigurationFileName[] = "awscoreconfiguration.setreg";
  21. static constexpr const char AWSCoreResourceMappingConfigFolderName[] = "Config";
  22. static constexpr const char AWSCoreResourceMappingConfigFileNameKey[] = "/AWSCore/ResourceMappingConfigFileName";
  23. static constexpr const char AWSCoreDefaultProfileName[] = "default";
  24. static constexpr const char AWSCoreProfileNameKey[] = "/AWSCore/ProfileName";
  25. static constexpr const char AWSCoreAllowAWSMetadataCredentialsKey[] = "/AWSCore/AllowAWSMetadataCredentials";
  26. static constexpr const char ProjectSourceFolderNotFoundErrorMessage[] =
  27. "Failed to get project source folder path.";
  28. static constexpr const char ProfileNameNotFoundErrorMessage[] =
  29. "Failed to get profile name, return default value instead.";
  30. static constexpr const char ResourceMappingFileNameNotFoundErrorMessage[] =
  31. "Failed to get resource mapping config file name, return empty value instead.";
  32. static constexpr const char SettingsRegistryFileLoadFailureErrorMessage[] =
  33. "Failed to load AWSCore settings registry file.";
  34. static constexpr const char GlobalSettingsRegistryLoadFailureErrorMessage[] =
  35. "Failed to load AWSCore configurations from global settings registry.";
  36. static constexpr const char AllowAWSMetadataCredentialsNotFoundMessage[] =
  37. "Failed to get AllowAWSMetadataCredentials setting, will default to false.";
  38. AWSCoreConfiguration();
  39. ~AWSCoreConfiguration() override = default;
  40. void ActivateConfig();
  41. void DeactivateConfig();
  42. void InitConfig();
  43. // AWSCoreInternalRequestBus interface implementation
  44. AZStd::string GetResourceMappingConfigFilePath() const override;
  45. AZStd::string GetProfileName() const override;
  46. bool IsAllowedAWSMetadataCredentials() const override;
  47. void ReloadConfiguration() override;
  48. private:
  49. // Initialize source project folder path
  50. void InitSourceProjectFolderPath();
  51. // Parse values from project .setreg file
  52. void ParseSettingsRegistryValues();
  53. // Reset settings registry data
  54. void ResetSettingsRegistryData();
  55. AZStd::string m_sourceProjectFolder;
  56. AZStd::string m_profileName;
  57. AZStd::string m_resourceMappingConfigFileName;
  58. bool m_allowAWSMetadataCredentials;
  59. };
  60. } // namespace AWSCore