SiddiqSoft.CosmosClient
0.8.1
dotnet add package SiddiqSoft.CosmosClient --version 0.8.1
NuGet\Install-Package SiddiqSoft.CosmosClient -Version 0.8.1
<PackageReference Include="SiddiqSoft.CosmosClient" Version="0.8.1" />
<PackageVersion Include="SiddiqSoft.CosmosClient" Version="0.8.1" />
<PackageReference Include="SiddiqSoft.CosmosClient" />
paket add SiddiqSoft.CosmosClient --version 0.8.1
#r "nuget: SiddiqSoft.CosmosClient, 0.8.1"
#:package SiddiqSoft.CosmosClient@0.8.1
#addin nuget:?package=SiddiqSoft.CosmosClient&version=0.8.1
#tool nuget:?package=SiddiqSoft.CosmosClient&version=0.8.1
CosmosClient: Azure Cosmos REST-API Client for Modern C++
π― Quick Links
New to the project? Start here:
- π START_HERE.md - Main entry point for all developers
- β‘ QUICK_START.md - Get started in 5 minutes
- π DOCUMENTATION_INDEX.md - Find what you need
Want to build and test?
- π§ DEVELOPER_BUILD_GUIDE.md - Complete build guide
- π SCRIPTS_README.md - Automated build script
Need API documentation?
- π API Documentation - Full API reference
π Overview
A lightweight, modern C++ client for Azure Cosmos DB REST API. Designed for C++ developers who want a simple, functional interface without unnecessary abstractions.
Key Features
- C++23 Native - Modern C++ with structured bindings and initializer lists
- JSON-First - Configuration, I/O, and results all use JSON
- Simple Interface - Minimal abstractions, maximum clarity
- Full Cosmos SQL API - Complete REST API implementation
- Single Header - Easy integration
- Cross-Platform - Windows, macOS, and Linux support
- Async Operations - Built-in async/await support
- Zero-Cost Abstractions - Only pay for what you use
Dependencies
- nlohmann/json - JSON library
- SplitUri - URI parsing utilities
- StringHelpers - String manipulation utilities
- AzureCppUtils - Azure utilities
- string2map - String to map conversion
- RunOnEnd - RAII scope guard utility
- asynchrony - Async/await support
- timethis - Timing utilities
- restcl - REST client library
π Quick Start
Installation
# Clone the repository
git clone https://github.com/SiddiqSoft/CosmosClient.git
cd CosmosClient
git submodule update --init --recursive
Build
# macOS
mkdir -p build && cd build
cmake --preset Apple-Debug ..
cmake --build .
# Linux
mkdir -p build && cd build
cmake --preset Linux-Clang-Debug ..
cmake --build .
Usage Example
#include "nlohmann/json.hpp"
#include "siddiqsoft/cosmoscl.hpp"
int main() {
// Create client instance
siddiqsoft::CosmosClient cc;
// Configure with connection strings
cc.configure({
{"partitionKeyNames", {"__pk"}},
{"connectionStrings", {primaryCS, secondaryCS}}
});
// Create a document
auto response = cc.createDocument({
.database = "mydb",
.collection = "mycoll",
.document = {
{"id", "doc1"},
{"__pk", "partition1"},
{"name", "My Document"},
{"value", 42}
}
});
if (response.statusCode == 201) {
std::cout << "Document created!" << std::endl;
}
return 0;
}
π Documentation
For Developers
| Document | Purpose | Time |
|---|---|---|
| START_HERE.md | Main entry point | 2 min |
| QUICK_START.md | 5-minute quick start | 5 min |
| DEVELOPER_BUILD_GUIDE.md | Comprehensive guide | 30 min |
| DOCUMENTATION_INDEX.md | Navigation hub | 5 min |
| SCRIPTS_README.md | Automated scripts | 2 min |
For Understanding Changes
| Document | Purpose | Time |
|---|---|---|
| TEST_CONSOLIDATION_SUMMARY.md | Test consolidation | 10 min |
| PIPELINE_CONSOLIDATION_UPDATE.md | CI/CD updates | 10 min |
| COMPLETE_CONSOLIDATION_SUMMARY.md | Complete overview | 15 min |
API Reference
- Full API Documentation - Complete API reference
π οΈ Development
Prerequisites
macOS:
brew install cmake llvm docker
Linux (Ubuntu/Debian):
sudo apt-get install cmake clang-15 docker.io
Build & Test
# Automated build and test
./build_and_test.sh debug macos # or linux
# Manual build
mkdir -p build && cd build
cmake --preset Apple-Debug ..
cmake --build . -j$(nproc)
# Run tests
ctest --output-on-failure --verbose
Test Suite
- 100+ Tests - Comprehensive test coverage
- 5 Categories - Validation, Connection, Endpoint, Integration, Comprehensive
- Unified Setup - Single shared database for all tests
- No Emulator Required - Validation tests run without Azure Cosmos Emulator
Windows Docker Tests
Docker-based tests are disabled on Windows in the CI/CD pipeline. This is because the Azure Cosmos DB Emulator Docker image is only available for Linux containers, and Windows agents cannot run Linux containers without additional virtualization overhead. Windows builds focus on compilation and packaging validation. For full integration testing, use macOS or Linux environments.
For detailed testing information, see DEVELOPER_BUILD_GUIDE.md.
π API Usage
Basic Operations
// Create document
auto resp = cc.createDocument({
.database = "db",
.collection = "coll",
.document = {{"id", "1"}, {"__pk", "pk1"}}
});
// Find document
auto resp = cc.findDocument({
.database = "db",
.collection = "coll",
.id = "1",
.partitionKey = "pk1"
});
// Update document
auto resp = cc.updateDocument({
.database = "db",
.collection = "coll",
.id = "1",
.partitionKey = "pk1",
.document = updatedDoc
});
// Delete document
auto resp = cc.removeDocument({
.database = "db",
.collection = "coll",
.id = "1",
.partitionKey = "pk1"
});
// Query documents
auto resp = cc.queryDocuments({
.database = "db",
.collection = "coll",
.partitionKey = "*",
.queryStatement = "SELECT * FROM c WHERE c.status = @status",
.queryParameters = {{{"name", "@status"}, {"value", "active"}}}
});
Async Operations
cc.async({
.operation = siddiqsoft::CosmosOperation::create,
.database = "db",
.collection = "coll",
.document = {{"id", "1"}, {"__pk", "pk1"}},
.onResponse = [](auto const& ctx, auto const& resp) {
if (resp.statusCode == 201) {
std::cout << "Document created!" << std::endl;
}
}
});
For complete API documentation, see https://siddiqsoft.github.io/CosmosClient/.
ποΈ Architecture
Design Principles
- Simplicity First - Minimal abstractions, maximum clarity
- JSON Everywhere - Configuration, I/O, and results use JSON
- Modern C++ - Leverage C++23 features
- Zero-Cost - Only pay for what you use
- Functional - Focus on solving problems, not performance
Project Structure
CosmosClient/
βββ include/
β βββ siddiqsoft/
β βββ cosmoscl.hpp # Main header
βββ tests/
β βββ testall.cpp # Unified test suite (100+ tests)
β βββ test_common.hpp # Test utilities
β βββ CMakeLists.txt # Test configuration
βββ CMakeLists.txt # Build configuration
βββ CMakePresets.json # CMake presets
βββ [Documentation files] # See below
π Documentation Files
Getting Started
- START_HERE.md - Main entry point
- QUICK_START.md - 5-minute quick start
- DEVELOPER_BUILD_GUIDE.md - Comprehensive guide
- DOCUMENTATION_INDEX.md - Navigation hub
Development
- SCRIPTS_README.md - Automated scripts
- build_and_test.sh - Build script
Project Information
- TEST_CONSOLIDATION_SUMMARY.md - Test consolidation
- PIPELINE_CONSOLIDATION_UPDATE.md - CI/CD updates
- COMPLETE_CONSOLIDATION_SUMMARY.md - Complete overview
π Development Workflow
1. Setup (One-time)
# Install tools
brew install cmake llvm docker # macOS
# or
sudo apt-get install cmake clang-15 docker.io # Linux
# Clone repository
git clone https://github.com/SiddiqSoft/CosmosClient.git
cd CosmosClient
git submodule update --init --recursive
2. Build
mkdir -p build && cd build
cmake --preset Apple-Debug ..
cmake --build . -j$(nproc)
3. Test
# Start emulator
docker run --publish 8081:8081 --publish 10250-10255:10250-10255 \
--name cosmos-emulator --rm --detach \
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
sleep 60
# Run tests
ctest --output-on-failure --verbose
# Stop emulator
docker stop cosmos-emulator
4. Develop
# Make changes
# Rebuild
cmake --build build/Apple-Debug -j$(nproc)
# Run specific tests
ctest --output-on-failure -R "YourTestName"
For detailed instructions, see DEVELOPER_BUILD_GUIDE.md.
π Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| CMake not found | brew install cmake (macOS) or sudo apt-get install cmake (Linux) |
| Compiler not found | brew install llvm (macOS) or sudo apt-get install clang-15 (Linux) |
| Emulator not reachable | Check: docker ps, docker logs cosmos-emulator |
| Tests timeout | Increase timeout: ctest --timeout 1800 |
| Docker permission denied | sudo usermod -aG docker $USER && newgrp docker |
For more troubleshooting, see DEVELOPER_BUILD_GUIDE.md#troubleshooting.
πΊοΈ Roadmap
- Documentation
- Unified test suite (100+ tests)
- Cross-platform support (Windows, macOS, Linux)
- Async operations with auto-retry
- C++20 modules support
- Co-routines support
- OpenSSL for non-Windows platforms
π Project Statistics
- 100+ Tests - Comprehensive test coverage
- 5 Test Categories - Validation, Connection, Endpoint, Integration, Comprehensive
- Single Database - Unified test setup
- Cross-Platform - Windows, macOS, Linux
- Modern C++ - C++23 features
π€ Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
ctest --output-on-failure --verbose - Submit a pull request
For development guidelines, see DEVELOPER_BUILD_GUIDE.md.
π License
This project is licensed under the BSD 3-Clause License. See LICENSE file for details.
π Support
- Documentation: See START_HERE.md
- API Reference: https://siddiqsoft.github.io/CosmosClient/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
π― Quick Navigation
I want to...
- Build and test RIGHT NOW β QUICK_START.md
- Understand the complete process β DEVELOPER_BUILD_GUIDE.md
- Use automated scripts β SCRIPTS_README.md
- Find specific documentation β DOCUMENTATION_INDEX.md
- Understand the API β API Documentation
<p align="right"> Β© 2021 Siddiq Software LLC. All rights reserved. </p>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native is compatible. |
-
- nlohmann.json (>= 3.12.0)
- SiddiqSoft.asynchrony (>= 2.1.1)
- SiddiqSoft.AzureCppUtils (>= 3.2.6)
- SiddiqSoft.format-helpers (>= 1.0.0)
- SiddiqSoft.restcl (>= 2.3.4)
- SiddiqSoft.RunOnEnd (>= 1.4.2)
- SiddiqSoft.SplitUri (>= 3.0.3)
- SiddiqSoft.string2map (>= 2.5.0)
- SiddiqSoft.StringHelpers (>= 1.2.2)
- SiddiqSoft.TimeThis (>= 2.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.8.1 | 0 | 5/20/2026 |
| 0.7.15 | 110 | 5/4/2026 |
| 0.7.14 | 1,785 | 12/23/2021 |
| 0.7.13 | 1,654 | 12/21/2021 |
| 0.7.12 | 1,759 | 12/20/2021 |
| 0.7.11 | 1,790 | 12/20/2021 |
| 0.7.10 | 1,842 | 12/18/2021 |
| 0.7.9 | 1,744 | 12/15/2021 |
| 0.7.8 | 2,084 | 11/20/2021 |
| 0.7.7 | 1,912 | 10/11/2021 |
| 0.7.6 | 1,601 | 10/8/2021 |
| 0.7.5 | 1,840 | 10/7/2021 |
| 0.7.4 | 1,887 | 10/5/2021 |
| 0.7.3 | 1,841 | 10/5/2021 |
| 0.7.2 | 1,871 | 9/28/2021 |
| 0.7.2-pullrequest0008-0005 | 1,746 | 9/28/2021 |
| 0.7.1 | 1,920 | 9/26/2021 |
| 0.6.1-pullrequest0007-0006 | 1,775 | 9/23/2021 |
| 0.6.1-pullrequest0007-0005 | 1,741 | 9/23/2021 |
| 0.6.0 | 1,951 | 9/11/2021 |
Documentation is over at https://siddiqsoft.github.io/CosmosClient/