// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export async function readPartitionKeyDefinition(diagnosticNode, container) {
    const partitionKeyDefinition = await container.readPartitionKeyDefinition(diagnosticNode);
    return partitionKeyDefinition.resource;
}
export async function computePartitionKeyRangeId(diagnosticNode, partitionKey, partitionKeyRangeCache, isPartitionLevelFailOverEnabled, container, pKDefinition) {
    let partitionKeyRangeId = undefined;
    if (isPartitionLevelFailOverEnabled) {
        const partitionKeyDefinition = pKDefinition ?? (await readPartitionKeyDefinition(diagnosticNode, container));
        if (partitionKeyDefinition && partitionKey && partitionKey.length > 0) {
            partitionKeyRangeId = await partitionKeyRangeCache.getPartitionKeyRangeIdFromPartitionKey(container.url, partitionKey, partitionKeyDefinition, diagnosticNode);
        }
    }
    return partitionKeyRangeId;
}
//# sourceMappingURL=ClientUtils.js.map