Move the ResourceIdentifier type from Azure::Identity to Azure::Core. (#5864)

* Move the ResourceIdentifier type from Identity to Azure::Core.

* Fix the namespace in the source cpp file.

* Fix managed identity credential tests.

* Fix clang format.
This commit is contained in:
Ahson Khan 2024-09-05 15:22:18 -04:00 committed by GitHub
parent 01d0ac359f
commit ea3f1442b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 43 additions and 26 deletions

View File

@ -20,6 +20,7 @@
### Features Added
- Added new constructor for `Azure::Core::Context` that takes a `std::chrono::system_clock::time_point` deadline. This enables creating a new context directly with a deadline.
- Added an `Azure::Core::ResourceIdentifier` type.
### Breaking Changes

View File

@ -108,6 +108,7 @@ set(
inc/azure/core/paged_response.hpp
inc/azure/core/platform.hpp
inc/azure/core/response.hpp
inc/azure/core/resource_identifier.hpp
inc/azure/core/rtti.hpp
inc/azure/core/tracing/tracing.hpp
inc/azure/core/url.hpp

View File

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @file
* @brief An Azure Resource Manager resource identifier.
*/
#pragma once
#include <string>
namespace Azure { namespace Core {
/**
* @brief An Azure Resource Manager resource identifier.
*/
class ResourceIdentifier final {
std::string m_resourceId;
public:
/**
* @brief Constructs a resource identifier.
*
* @param resourceId The id string to create the ResourceIdentifier from.
*/
explicit ResourceIdentifier(std::string const& resourceId) : m_resourceId(resourceId){};
/**
* @brief The string representation of this resource identifier.
*
* @return The resource identifier string.
*/
std::string ToString() const { return m_resourceId; }
};
}} // namespace Azure::Core

View File

@ -82,6 +82,7 @@ add_executable (
policy_test.cpp
request_activity_policy_test.cpp
request_id_policy_test.cpp
resource_identifier_test
response_t_test.cpp
retry_policy_test.cpp
service_tracing_test.cpp

View File

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "azure/identity/managed_identity_credential.hpp"
#include "azure/core/resource_identifier.hpp"
#include <string>
#include <gtest/gtest.h>
using namespace Azure::Identity;
using namespace Azure::Core;
TEST(ResourceIdentifier, Basic)
{

View File

@ -10,6 +10,7 @@
#include <azure/core/credentials/credentials.hpp>
#include <azure/core/credentials/token_credential_options.hpp>
#include <azure/core/resource_identifier.hpp>
#include <memory>
#include <string>
@ -19,29 +20,6 @@ namespace Azure { namespace Identity {
class ManagedIdentitySource;
}
// This will move to Azure::Core.
/**
* @brief An Azure Resource Manager resource identifier.
*/
class ResourceIdentifier final {
std::string m_resourceId;
public:
/**
* @brief Constructs a resource identifier.
*
* @param resourceId The id string to create the ResourceIdentifier from.
*/
explicit ResourceIdentifier(std::string const& resourceId) : m_resourceId(resourceId){};
/**
* @brief The string representation of this resource identifier.
*
* @return The resource identifier string.
*/
std::string ToString() const { return m_resourceId; }
};
/**
* @brief The type of managed identity identifier depending on how the managed identity is
* configured.

View File

@ -28,7 +28,6 @@ add_executable (
environment_credential_test.cpp
macro_guard_test.cpp
managed_identity_credential_test.cpp
resource_identifier_test.cpp
simplified_header_test.cpp
tenant_id_resolver_test.cpp
token_cache_test.cpp