TAF.MetaData.SDK 4.1.0

dotnet add package TAF.MetaData.SDK --version 4.1.0
                    
NuGet\Install-Package TAF.MetaData.SDK -Version 4.1.0
                    
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="TAF.MetaData.SDK" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TAF.MetaData.SDK" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="TAF.MetaData.SDK" />
                    
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 TAF.MetaData.SDK --version 4.1.0
                    
#r "nuget: TAF.MetaData.SDK, 4.1.0"
                    
#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 TAF.MetaData.SDK@4.1.0
                    
#: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=TAF.MetaData.SDK&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TAF.MetaData.SDK&version=4.1.0
                    
Install as a Cake Tool

TAF Metadata Client SDK

NuGet Version .NET

A professional, HTTP-based SDK for consuming TAF Metadata Service APIs. This SDK follows Clean Architecture and SOLID principles, providing enterprise-grade metadata retrieval capabilities with automatic context resolution.

๐Ÿ—๏ธ Architecture & Design Principles

โœ… Clean Architecture - Proper separation of layers: Client, Infrastructure, Services, Interfaces, Core
โœ… SOLID Principles - Single responsibility, dependency inversion, interface segregation
โœ… Industry Standards - Follows AWS, Azure, Stripe SDK naming conventions
โœ… HTTP-First - Lightweight, direct API communication
โœ… Auto Context Resolution - Automatic TenantId/AppId extraction from headers
โœ… Comprehensive Error Handling - Proper exception mapping and status codes
โœ… Dependency Injection - Seamless .NET DI integration with validation

๐Ÿ“ฆ Installation

dotnet add package TAF.MetaData.SDK

๐Ÿš€ Quick Start

1. Configuration

Add metadata service configuration to your appsettings.json:

{
  "MetadataService": {
    "BaseUrl": "https://your-metadata-service.com",
    "Timeout": 30
  }
}

2. Service Registration

Simple configuration from appsettings:

using TAF.MetaData.SDK.Extensions;

var builder = WebApplication.CreateBuilder(args);

// One-line registration with appsettings
builder.Services.AddMetadataClient(builder.Configuration);

var app = builder.Build();

Advanced manual configuration:

// Custom configuration
builder.Services.AddMetadataClient(options =>
{
    options.BaseUrl = "https://metadata-api.production.com";
    options.TimeoutSeconds = 45;
});

3. Usage

Inject and use the client in your services:

public class MyService
{
    private readonly IMetadataClient _metadataClient;
    
    public MyService(IMetadataClient metadataClient)
    {
        _metadataClient = metadataClient;
    }
    
    public async Task<AppObjectResponse?> GetUserProfile()
    {
        // Context (TenantId, AppId) automatically resolved from HTTP headers
        return await _metadataClient.GetAppObjectAsync(
            appObjectName: "UserProfile", 
            version: "1.2.0" // optional
        );
    }
}

4. HTTP Headers (Required)

Ensure your HTTP requests include the required context headers:

GET /api/myendpoint
TenantId: 123e4567-e89b-12d3-a456-426614174000
AppId: 987fcdeb-51a2-43d1-9f12-345678901234
CorrelationId: req-12345-67890 (optional)

๐Ÿ“š API Reference

IMetadataClient

GetAppObjectAsync
Task<AppObjectResponse?> GetAppObjectAsync(
    string appObjectName,
    string? version = null,
    CancellationToken cancellationToken = default)

Parameters:

  • appObjectName - Name of the application object to retrieve
  • version - Optional version filter (default: null)
  • cancellationToken - Cancellation token

Returns: AppObjectResponse if found, null if not found

Throws:

  • ArgumentException - When appObjectName is null/empty
  • InvalidOperationException - When required headers are missing
  • MetadataServiceException - When service operation fails

๐Ÿ“‹ Response Models

AppObjectResponse

public class AppObjectResponse
{
    public Guid Id { get; set; }
    public Guid TenantId { get; set; }
    public Guid AppId { get; set; }
    public Guid AppObjectId { get; set; }
    public string AppObjectName { get; set; }
    public string AppObjectJson { get; set; }
    public string? Version { get; set; }
    public bool IsCustom { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }
}

๐Ÿ›๏ธ Clean Architecture Structure

TAF.Metadata.SDK/
โ”œโ”€โ”€ Client/              # Consumer-facing implementations
โ”‚   โ””โ”€โ”€ HttpMetadataClient.cs
โ”œโ”€โ”€ Infrastructure/      # External dependencies (HTTP context)
โ”‚   โ””โ”€โ”€ HttpContextProvider.cs
โ”œโ”€โ”€ Services/           # Internal business services
โ”‚   โ”œโ”€โ”€ MetadataUrlBuilder.cs
โ”‚   โ”œโ”€โ”€ MetadataHttpRequestFactory.cs
โ”‚   โ””โ”€โ”€ MetadataResponseProcessor.cs
โ”œโ”€โ”€ Interfaces/         # Contracts/abstractions
โ”‚   โ”œโ”€โ”€ IMetadataClient.cs
โ”‚   โ”œโ”€โ”€ IContextProvider.cs
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ Core/              # Domain objects
โ”‚   โ””โ”€โ”€ MetadataContext.cs
โ”œโ”€โ”€ Configuration/     # Options pattern
โ”‚   โ””โ”€โ”€ MetadataServiceOptions.cs
โ””โ”€โ”€ Extensions/        # DI registration
    โ””โ”€โ”€ ServiceCollectionExtensions.cs

๐ŸŽฏ SOLID Principles Implementation

Single Responsibility Principle (SRP)

  • HttpMetadataClient - Orchestrates the request flow
  • MetadataUrlBuilder - Builds URLs only
  • MetadataHttpRequestFactory - Creates HTTP requests only
  • MetadataResponseProcessor - Processes responses only
  • HttpContextProvider - Resolves context from headers only

Open/Closed Principle (OCP)

  • SDK is extensible via interfaces
  • New response processors or context providers can be added

Dependency Inversion Principle (DIP)

  • All dependencies via abstractions (IMetadataClient, IContextProvider)
  • Easy to mock and test

Interface Segregation Principle (ISP)

  • Small, focused interfaces
  • Each interface has a single responsibility

โšก Auto Context Resolution

The SDK automatically extracts context from HTTP request headers:

// No manual context needed - extracted automatically!
var appObject = await _metadataClient.GetAppObjectAsync("UserProfile");

// Behind the scenes:
// 1. HttpContextProvider reads Request.Headers["TenantId"]
// 2. HttpContextProvider reads Request.Headers["AppId"] 
// 3. HttpContextProvider reads Request.Headers["CorrelationId"] (optional)
// 4. Context passed to metadata service automatically

๐Ÿ›ก๏ธ Error Handling

try
{
    var userProfile = await _metadataClient.GetAppObjectAsync("UserProfile");
    if (userProfile == null)
    {
        // Object not found (404)
        Console.WriteLine("UserProfile not found");
    }
}
catch (InvalidOperationException ex)
{
    // Missing required headers
    Console.WriteLine($"Missing context: {ex.Message}");
}
catch (MetadataServiceException ex)
{
    // Service errors (network, timeout, API errors)
    Console.WriteLine($"Service error: {ex.Message}, Status: {ex.StatusCode}");
}

๐Ÿ”ง Configuration Options

MetadataServiceOptions

public class MetadataServiceOptions
{
    public string BaseUrl { get; set; } = string.Empty;
    public int TimeoutSeconds { get; set; } = 30;
}

Configuration validation:

  • BaseUrl - Required, must be valid URL
  • TimeoutSeconds - Must be between 1 and 300 seconds

๐ŸŒŸ Key Features

  • ๐Ÿ”„ Industry Standard Naming - IMetadataClient follows AWS/Azure patterns
  • โšก One-Line Setup - AddMetadataClient(configuration)
  • ๐Ÿค– Auto Context - No manual TenantId/AppId passing
  • ๐Ÿ›ก๏ธ Secure - Fixed SSL certificate validation
  • ๐Ÿ“Š Lightweight - HTTP-only, no message bus dependencies
  • ๐Ÿงช Testable - All dependencies mockable via interfaces
  • โš™๏ธ Configurable - Supports both appsettings and manual config

๐Ÿ“ฆ Dependencies

  • .NET 8.0+ - Modern .NET runtime
  • Microsoft.AspNetCore.Http - HTTP context access
  • Microsoft.Extensions.DependencyInjection - DI container
  • Microsoft.Extensions.Http - HTTP client factory
  • System.ComponentModel.Annotations - Configuration validation

๐Ÿค Contributing

This SDK is maintained by the TAF Development Team. For issues or feature requests, please contact the development team.

๐Ÿ“„ License

MIT License - see LICENSE file for details.


๐Ÿค– Generated with Claude Code

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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
4.1.0 97 9/19/2025
3.0.1 136 9/5/2025
3.0.0 115 9/5/2025
2.0.2 140 9/3/2025
2.0.1 135 9/3/2025
1.0.0 138 9/3/2025