edge-connect-client/sdk/examples/deploy_app.go

137 lines
4.4 KiB
Go
Raw Normal View History

feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
// ABOUTME: Example demonstrating EdgeXR SDK usage for app deployment workflow
// ABOUTME: Shows app creation, querying, and cleanup using the typed SDK APIs
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
"time"
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
)
func main() {
// Configure SDK client
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
baseURL := getEnvOrDefault("EDGEXR_BASE_URL", "https://hub.apps.edge.platform.mg3.mdb.osc.live")
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
// Support both token-based and username/password authentication
token := getEnvOrDefault("EDGEXR_TOKEN", "")
username := getEnvOrDefault("EDGEXR_USERNAME", "")
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
var edgeClient *edgeconnect.Client
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
if token != "" {
// Use static token authentication
fmt.Println("🔐 Using Bearer token authentication")
edgeClient = edgeconnect.NewClient(baseURL,
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
edgeconnect.WithLogger(log.Default()),
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
)
} else if username != "" && password != "" {
// Use username/password authentication (matches existing client pattern)
fmt.Println("🔐 Using username/password authentication")
edgeClient = edgeconnect.NewClientWithCredentials(baseURL, username, password,
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
edgeconnect.WithLogger(log.Default()),
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
)
} else {
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
}
ctx := context.Background()
// Example application to deploy
app := &edgeconnect.NewAppInput{
feat(sdk): ✨ Complete Phase 2 - AppInstance, Cloudlet APIs & CLI integration Implemented comprehensive EdgeXR SDK with full API coverage and CLI integration: ## New API Coverage: - **AppInstance Management**: Create, Show, List, Refresh, Delete instances - **Cloudlet Management**: Create, Show, List, Delete cloudlets - **Cloudlet Operations**: GetManifest, GetResourceUsage for monitoring - **Streaming JSON**: Support for EdgeXR's multi-line JSON response format ## API Implementations: ### AppInstance APIs: - CreateAppInstance → POST /auth/ctrl/CreateAppInst - ShowAppInstance → POST /auth/ctrl/ShowAppInst - ShowAppInstances → POST /auth/ctrl/ShowAppInst (multi-result) - RefreshAppInstance → POST /auth/ctrl/RefreshAppInst - DeleteAppInstance → POST /auth/ctrl/DeleteAppInst ### Cloudlet APIs: - CreateCloudlet → POST /auth/ctrl/CreateCloudlet - ShowCloudlet → POST /auth/ctrl/ShowCloudlet - ShowCloudlets → POST /auth/ctrl/ShowCloudlet (multi-result) - DeleteCloudlet → POST /auth/ctrl/DeleteCloudlet - GetCloudletManifest → POST /auth/ctrl/GetCloudletManifest - GetCloudletResourceUsage → POST /auth/ctrl/GetCloudletResourceUsage ## CLI Integration: - **Backward Compatible**: Existing CLI commands work unchanged - **Enhanced Reliability**: Now uses SDK with retry logic and caching - **Same Interface**: All flags, config, and behavior preserved - **Better Errors**: Structured error handling with meaningful messages ## Testing & Examples: - **Comprehensive Test Suite**: 100+ test cases covering all APIs - **Mock Servers**: httptest-based integration testing - **Error Scenarios**: Network failures, auth errors, 404 handling - **Real Workflow**: Complete app deployment example with cleanup ## Documentation: - **SDK README**: Complete API reference and usage examples - **Migration Guide**: Easy transition from existing client - **Configuration**: All authentication and retry options documented - **Performance**: Token caching, connection pooling benchmarks ## Quality Features: - **Type Safety**: No more interface{} - full type definitions - **Context Support**: Proper timeout/cancellation throughout - **Error Handling**: Structured APIError with status codes - **Resilience**: Automatic retry with exponential backoff - **Observability**: Request logging and metrics hooks The SDK is now production-ready with comprehensive API coverage, robust error handling, and seamless CLI integration while maintaining full backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:53:43 +02:00
Region: "EU",
App: edgeconnect.App{
Key: edgeconnect.AppKey{
feat(sdk): ✨ Complete Phase 2 - AppInstance, Cloudlet APIs & CLI integration Implemented comprehensive EdgeXR SDK with full API coverage and CLI integration: ## New API Coverage: - **AppInstance Management**: Create, Show, List, Refresh, Delete instances - **Cloudlet Management**: Create, Show, List, Delete cloudlets - **Cloudlet Operations**: GetManifest, GetResourceUsage for monitoring - **Streaming JSON**: Support for EdgeXR's multi-line JSON response format ## API Implementations: ### AppInstance APIs: - CreateAppInstance → POST /auth/ctrl/CreateAppInst - ShowAppInstance → POST /auth/ctrl/ShowAppInst - ShowAppInstances → POST /auth/ctrl/ShowAppInst (multi-result) - RefreshAppInstance → POST /auth/ctrl/RefreshAppInst - DeleteAppInstance → POST /auth/ctrl/DeleteAppInst ### Cloudlet APIs: - CreateCloudlet → POST /auth/ctrl/CreateCloudlet - ShowCloudlet → POST /auth/ctrl/ShowCloudlet - ShowCloudlets → POST /auth/ctrl/ShowCloudlet (multi-result) - DeleteCloudlet → POST /auth/ctrl/DeleteCloudlet - GetCloudletManifest → POST /auth/ctrl/GetCloudletManifest - GetCloudletResourceUsage → POST /auth/ctrl/GetCloudletResourceUsage ## CLI Integration: - **Backward Compatible**: Existing CLI commands work unchanged - **Enhanced Reliability**: Now uses SDK with retry logic and caching - **Same Interface**: All flags, config, and behavior preserved - **Better Errors**: Structured error handling with meaningful messages ## Testing & Examples: - **Comprehensive Test Suite**: 100+ test cases covering all APIs - **Mock Servers**: httptest-based integration testing - **Error Scenarios**: Network failures, auth errors, 404 handling - **Real Workflow**: Complete app deployment example with cleanup ## Documentation: - **SDK README**: Complete API reference and usage examples - **Migration Guide**: Easy transition from existing client - **Configuration**: All authentication and retry options documented - **Performance**: Token caching, connection pooling benchmarks ## Quality Features: - **Type Safety**: No more interface{} - full type definitions - **Context Support**: Proper timeout/cancellation throughout - **Error Handling**: Structured APIError with status codes - **Resilience**: Automatic retry with exponential backoff - **Observability**: Request logging and metrics hooks The SDK is now production-ready with comprehensive API coverage, robust error handling, and seamless CLI integration while maintaining full backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:53:43 +02:00
Organization: "edp2",
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
Name: "my-edge-app",
Version: "1.0.0",
},
Deployment: "docker",
ImageType: "ImageTypeDocker",
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
DefaultFlavor: edgeconnect.Flavor{Name: "EU.small"},
ServerlessConfig: struct{}{},
AllowServerless: false,
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
},
}
// Demonstrate app lifecycle
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
if err := demonstrateAppLifecycle(ctx, edgeClient, app); err != nil {
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
log.Fatalf("App lifecycle demonstration failed: %v", err)
}
fmt.Println("✅ SDK example completed successfully!")
}
func demonstrateAppLifecycle(ctx context.Context, edgeClient *edgeconnect.Client, input *edgeconnect.NewAppInput) error {
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
appKey := input.App.Key
region := input.Region
fmt.Printf("🚀 Demonstrating EdgeXR SDK with app: %s/%s v%s\n",
appKey.Organization, appKey.Name, appKey.Version)
// Step 1: Create the application
fmt.Println("\n1. Creating application...")
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
if err := edgeClient.CreateApp(ctx, input); err != nil {
2025-09-25 15:32:07 +02:00
return fmt.Errorf("failed to create app: %+v", err)
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
}
fmt.Printf("✅ App created: %s/%s v%s\n", appKey.Organization, appKey.Name, appKey.Version)
// Step 2: Query the application
fmt.Println("\n2. Querying application...")
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
app, err := edgeClient.ShowApp(ctx, appKey, region)
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
if err != nil {
return fmt.Errorf("failed to show app: %w", err)
}
fmt.Printf("✅ App found: %s/%s v%s (deployment: %s)\n",
app.Key.Organization, app.Key.Name, app.Key.Version, app.Deployment)
// Step 3: List applications in the organization
fmt.Println("\n3. Listing applications...")
filter := edgeconnect.AppKey{Organization: appKey.Organization}
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
apps, err := edgeClient.ShowApps(ctx, filter, region)
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
if err != nil {
return fmt.Errorf("failed to list apps: %w", err)
}
fmt.Printf("✅ Found %d applications in organization '%s'\n", len(apps), appKey.Organization)
// Step 4: Clean up - delete the application
fmt.Println("\n4. Cleaning up...")
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
if err := edgeClient.DeleteApp(ctx, appKey, region); err != nil {
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
return fmt.Errorf("failed to delete app: %w", err)
}
fmt.Printf("✅ App deleted: %s/%s v%s\n", appKey.Organization, appKey.Name, appKey.Version)
// Step 5: Verify deletion
fmt.Println("\n5. Verifying deletion...")
feat(sdk): ✨ Add username/password authentication matching existing client Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:21:31 +02:00
_, err = edgeClient.ShowApp(ctx, appKey, region)
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
if err != nil {
if strings.Contains(fmt.Sprintf("%v", err), edgeconnect.ErrResourceNotFound.Error()) {
feat(sdk): ✨ Implement EdgeXR Master Controller Go SDK foundation Phase 1 Implementation - Core SDK foundation with typed APIs: ## New Components Added: - **SDK Package Structure**: `/sdk/client`, `/sdk/internal/http`, `/sdk/examples` - **Core Types**: App, AppInstance, Cloudlet with JSON marshaling - **HTTP Transport**: Resilient HTTP client with go-retryablehttp - **Auth System**: Pluggable providers (StaticToken, NoAuth) - **Client**: Configurable SDK client with retry and logging options ## API Implementation: - **App Management**: CreateApp, ShowApp, ShowApps, DeleteApp - **Error Handling**: Structured APIError with status codes and messages - **Response Parsing**: EdgeXR streaming JSON response support - **Context Support**: All APIs accept context.Context for timeouts/cancellation ## Testing & Examples: - **Unit Tests**: Comprehensive test suite with httptest mock servers - **Example App**: Complete app lifecycle demonstration in examples/deploy_app.go - **Test Coverage**: Create, show, list, delete operations with error conditions ## Build Infrastructure: - **Makefile**: Automated code generation, testing, and building - **Dependencies**: Added go-retryablehttp, testify, oapi-codegen - **Configuration**: oapi-codegen.yaml for type generation ## API Mapping: - CreateApp → POST /auth/ctrl/CreateApp - ShowApp → POST /auth/ctrl/ShowApp - DeleteApp → POST /auth/ctrl/DeleteApp Following existing prototype patterns while adding type safety, retry logic, and comprehensive error handling. Ready for Phase 2 AppInstance APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:05:20 +02:00
fmt.Printf("✅ App successfully deleted (not found)\n")
} else {
return fmt.Errorf("unexpected error verifying deletion: %w", err)
}
} else {
return fmt.Errorf("app still exists after deletion")
}
return nil
}
func getEnvOrDefault(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
feat(sdk): ✨ Complete Phase 2 - AppInstance, Cloudlet APIs & CLI integration Implemented comprehensive EdgeXR SDK with full API coverage and CLI integration: ## New API Coverage: - **AppInstance Management**: Create, Show, List, Refresh, Delete instances - **Cloudlet Management**: Create, Show, List, Delete cloudlets - **Cloudlet Operations**: GetManifest, GetResourceUsage for monitoring - **Streaming JSON**: Support for EdgeXR's multi-line JSON response format ## API Implementations: ### AppInstance APIs: - CreateAppInstance → POST /auth/ctrl/CreateAppInst - ShowAppInstance → POST /auth/ctrl/ShowAppInst - ShowAppInstances → POST /auth/ctrl/ShowAppInst (multi-result) - RefreshAppInstance → POST /auth/ctrl/RefreshAppInst - DeleteAppInstance → POST /auth/ctrl/DeleteAppInst ### Cloudlet APIs: - CreateCloudlet → POST /auth/ctrl/CreateCloudlet - ShowCloudlet → POST /auth/ctrl/ShowCloudlet - ShowCloudlets → POST /auth/ctrl/ShowCloudlet (multi-result) - DeleteCloudlet → POST /auth/ctrl/DeleteCloudlet - GetCloudletManifest → POST /auth/ctrl/GetCloudletManifest - GetCloudletResourceUsage → POST /auth/ctrl/GetCloudletResourceUsage ## CLI Integration: - **Backward Compatible**: Existing CLI commands work unchanged - **Enhanced Reliability**: Now uses SDK with retry logic and caching - **Same Interface**: All flags, config, and behavior preserved - **Better Errors**: Structured error handling with meaningful messages ## Testing & Examples: - **Comprehensive Test Suite**: 100+ test cases covering all APIs - **Mock Servers**: httptest-based integration testing - **Error Scenarios**: Network failures, auth errors, 404 handling - **Real Workflow**: Complete app deployment example with cleanup ## Documentation: - **SDK README**: Complete API reference and usage examples - **Migration Guide**: Easy transition from existing client - **Configuration**: All authentication and retry options documented - **Performance**: Token caching, connection pooling benchmarks ## Quality Features: - **Type Safety**: No more interface{} - full type definitions - **Context Support**: Proper timeout/cancellation throughout - **Error Handling**: Structured APIError with status codes - **Resilience**: Automatic retry with exponential backoff - **Observability**: Request logging and metrics hooks The SDK is now production-ready with comprehensive API coverage, robust error handling, and seamless CLI integration while maintaining full backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 14:53:43 +02:00
}