SiddiqSoft.CosmosClient 0.7.15

There is a newer version of this package available.
See the version list below for details.
dotnet add package SiddiqSoft.CosmosClient --version 0.7.15
                    
NuGet\Install-Package SiddiqSoft.CosmosClient -Version 0.7.15
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.CosmosClient" Version="0.7.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SiddiqSoft.CosmosClient" Version="0.7.15" />
                    
Directory.Packages.props
<PackageReference Include="SiddiqSoft.CosmosClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SiddiqSoft.CosmosClient --version 0.7.15
                    
#r "nuget: SiddiqSoft.CosmosClient, 0.7.15"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SiddiqSoft.CosmosClient@0.7.15
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SiddiqSoft.CosmosClient&version=0.7.15
                    
Install as a Cake Addin
#tool nuget:?package=SiddiqSoft.CosmosClient&version=0.7.15
                    
Install as a Cake Tool

CosmosClient: Azure Cosmos REST-API Client for Modern C++

CodeQL Build Status alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image


New to the project? Start here:

Want to build and test?

Need API documentation?


πŸ“‹ 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


πŸš€ 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


πŸ› οΈ 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

Development

Project Information


πŸ”„ 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:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: ctest --output-on-failure --verbose
  5. 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


🎯 Quick Navigation

I want to...


<p align="right"> Β© 2021 Siddiq Software LLC. All rights reserved. </p>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed