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"
|
2025-09-25 16:23:35 +02:00
|
|
|
"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"
|
|
|
|
|
|
2025-09-29 09:41:44 +02:00
|
|
|
"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
|
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
|
|
|
|
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", "")
|
|
|
|
|
|
2025-09-29 09:41:44 +02:00
|
|
|
var edgeClient *edgeconnect.Client
|
2025-09-25 14:21:31 +02:00
|
|
|
|
|
|
|
|
if token != "" {
|
|
|
|
|
// Use static token authentication
|
|
|
|
|
fmt.Println("🔐 Using Bearer token authentication")
|
2025-09-29 09:41:44 +02:00
|
|
|
edgeClient = edgeconnect.NewClient(baseURL,
|
|
|
|
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
|
|
|
|
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
|
|
|
|
|
edgeconnect.WithLogger(log.Default()),
|
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")
|
2025-09-29 09:41:44 +02:00
|
|
|
edgeClient = edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
|
|
|
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
|
|
|
|
edgeconnect.WithLogger(log.Default()),
|
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
|
2025-09-29 09:41:44 +02:00
|
|
|
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",
|
2025-09-29 09:41:44 +02:00
|
|
|
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",
|
|
|
|
|
},
|
2025-09-25 16:23:35 +02:00
|
|
|
Deployment: "docker",
|
|
|
|
|
ImageType: "ImageTypeDocker",
|
|
|
|
|
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
2025-09-29 09:41:44 +02:00
|
|
|
DefaultFlavor: edgeconnect.Flavor{Name: "EU.small"},
|
2025-09-25 16:23:35 +02:00
|
|
|
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
|
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!")
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 09:41:44 +02:00
|
|
|
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...")
|
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...")
|
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...")
|
2025-09-29 09:41:44 +02:00
|
|
|
filter := edgeconnect.AppKey{Organization: appKey.Organization}
|
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...")
|
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...")
|
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 {
|
2025-09-29 09:41:44 +02:00
|
|
|
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
|
|
|
}
|