ARN.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/core/utils/ARN.h>
  6. #include <aws/core/utils/StringUtils.h>
  7. #include <aws/core/utils/logging/LogMacros.h>
  8. namespace Aws
  9. {
  10. namespace Utils
  11. {
  12. ARN::ARN(const Aws::String& arnString)
  13. {
  14. m_valid = false;
  15. // An ARN can be identified as any string starting with arn: with 6 defined segments each separated by a :
  16. const auto result = StringUtils::Split(arnString, ':', StringUtils::SplitOptions::INCLUDE_EMPTY_ENTRIES);
  17. if (result.size() < 6)
  18. {
  19. return;
  20. }
  21. if (result[0] != "arn")
  22. {
  23. return;
  24. }
  25. m_arnString = arnString;
  26. m_partition = result[1];
  27. m_service = result[2];
  28. m_region = result[3];
  29. m_accountId = result[4];
  30. m_resource = result[5];
  31. for (size_t i = 6; i < result.size(); i++)
  32. {
  33. m_resource += ":" + result[i];
  34. }
  35. m_valid = true;
  36. }
  37. }
  38. }