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
<PackageReference Include="TAF.MetaData.SDK" Version="4.1.0" />
<PackageVersion Include="TAF.MetaData.SDK" Version="4.1.0" />
<PackageReference Include="TAF.MetaData.SDK" />
paket add TAF.MetaData.SDK --version 4.1.0
#r "nuget: TAF.MetaData.SDK, 4.1.0"
#:package TAF.MetaData.SDK@4.1.0
#addin nuget:?package=TAF.MetaData.SDK&version=4.1.0
#tool nuget:?package=TAF.MetaData.SDK&version=4.1.0
TAF Metadata Client SDK
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 retrieveversion
- Optional version filter (default: null)cancellationToken
- Cancellation token
Returns: AppObjectResponse
if found, null
if not found
Throws:
ArgumentException
- When appObjectName is null/emptyInvalidOperationException
- When required headers are missingMetadataServiceException
- 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 URLTimeoutSeconds
- 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 | Versions 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. |
-
net8.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.