From 55e9f867590f525392dfa806f7034b007c19c19f Mon Sep 17 00:00:00 2001 From: Waldemar Date: Mon, 29 Sep 2025 09:41:44 +0200 Subject: [PATCH] Renamed package and removed unused make calls --- Makefile | 10 +--- cmd/app.go | 24 ++++---- cmd/instance.go | 26 ++++---- oapi-codegen.yaml | 8 --- sdk/{client => edgeconnect}/appinstance.go | 2 +- .../appinstance_test.go | 2 +- sdk/{client => edgeconnect}/apps.go | 2 +- sdk/{client => edgeconnect}/apps_test.go | 2 +- sdk/{client => edgeconnect}/auth.go | 4 +- sdk/{client => edgeconnect}/auth_test.go | 4 +- sdk/{client => edgeconnect}/client.go | 12 ++-- sdk/{client => edgeconnect}/cloudlet.go | 2 +- sdk/{client => edgeconnect}/cloudlet_test.go | 2 +- sdk/{client => edgeconnect}/types.go | 2 +- sdk/examples/comprehensive/main.go | 60 +++++++++---------- sdk/examples/deploy_app.go | 32 +++++----- 16 files changed, 91 insertions(+), 103 deletions(-) delete mode 100644 oapi-codegen.yaml rename sdk/{client => edgeconnect}/appinstance.go (99%) rename sdk/{client => edgeconnect}/appinstance_test.go (99%) rename sdk/{client => edgeconnect}/apps.go (99%) rename sdk/{client => edgeconnect}/apps_test.go (99%) rename sdk/{client => edgeconnect}/auth.go (99%) rename sdk/{client => edgeconnect}/auth_test.go (99%) rename sdk/{client => edgeconnect}/client.go (94%) rename sdk/{client => edgeconnect}/cloudlet.go (99%) rename sdk/{client => edgeconnect}/cloudlet_test.go (99%) rename sdk/{client => edgeconnect}/types.go (99%) diff --git a/Makefile b/Makefile index 594f6c8..496876e 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,12 @@ # ABOUTME: Build automation and code generation for EdgeXR SDK # ABOUTME: Provides targets for generating types, testing, and building the CLI -.PHONY: generate test build clean install-tools +.PHONY: test build clean install-tools # Install required tools install-tools: go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest -# Generate Go types from OpenAPI spec -generate: - oapi-codegen -config oapi-codegen.yaml api/swagger.json - # Run tests test: go test -v ./... @@ -35,7 +31,7 @@ lint: golangci-lint run # Run all checks (generate, test, lint) -check: generate test lint +check: test lint # Default target -all: check build \ No newline at end of file +all: check build diff --git a/cmd/app.go b/cmd/app.go index 4e24eef..8cac4e5 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -7,7 +7,7 @@ import ( "os" "time" - "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client" + "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -19,20 +19,20 @@ var ( region string ) -func newSDKClient() *client.Client { +func newSDKClient() *edgeconnect.Client { baseURL := viper.GetString("base_url") username := viper.GetString("username") password := viper.GetString("password") if username != "" && password != "" { - return client.NewClientWithCredentials(baseURL, username, password, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + return edgeconnect.NewClientWithCredentials(baseURL, username, password, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), ) } // Fallback to no auth for now - in production should require auth - return client.NewClient(baseURL, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + return edgeconnect.NewClient(baseURL, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), ) } @@ -47,10 +47,10 @@ var createAppCmd = &cobra.Command{ Short: "Create a new Edge Connect application", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - input := &client.NewAppInput{ + input := &edgeconnect.NewAppInput{ Region: region, - App: client.App{ - Key: client.AppKey{ + App: edgeconnect.App{ + Key: edgeconnect.AppKey{ Organization: organization, Name: appName, Version: appVersion, @@ -72,7 +72,7 @@ var showAppCmd = &cobra.Command{ Short: "Show details of an Edge Connect application", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - appKey := client.AppKey{ + appKey := edgeconnect.AppKey{ Organization: organization, Name: appName, Version: appVersion, @@ -92,7 +92,7 @@ var listAppsCmd = &cobra.Command{ Short: "List Edge Connect applications", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - appKey := client.AppKey{ + appKey := edgeconnect.AppKey{ Organization: organization, Name: appName, Version: appVersion, @@ -115,7 +115,7 @@ var deleteAppCmd = &cobra.Command{ Short: "Delete an Edge Connect application", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - appKey := client.AppKey{ + appKey := edgeconnect.AppKey{ Organization: organization, Name: appName, Version: appVersion, diff --git a/cmd/instance.go b/cmd/instance.go index 745535c..de22062 100644 --- a/cmd/instance.go +++ b/cmd/instance.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client" + "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect" "github.com/spf13/cobra" ) @@ -27,23 +27,23 @@ var createInstanceCmd = &cobra.Command{ Short: "Create a new Edge Connect application instance", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - input := &client.NewAppInstanceInput{ + input := &edgeconnect.NewAppInstanceInput{ Region: region, - AppInst: client.AppInstance{ - Key: client.AppInstanceKey{ + AppInst: edgeconnect.AppInstance{ + Key: edgeconnect.AppInstanceKey{ Organization: organization, Name: instanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: cloudletOrg, Name: cloudletName, }, }, - AppKey: client.AppKey{ + AppKey: edgeconnect.AppKey{ Organization: organization, Name: appName, Version: appVersion, }, - Flavor: client.Flavor{ + Flavor: edgeconnect.Flavor{ Name: flavorName, }, }, @@ -63,10 +63,10 @@ var showInstanceCmd = &cobra.Command{ Short: "Show details of an Edge Connect application instance", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - instanceKey := client.AppInstanceKey{ + instanceKey := edgeconnect.AppInstanceKey{ Organization: organization, Name: instanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: cloudletOrg, Name: cloudletName, }, @@ -86,10 +86,10 @@ var listInstancesCmd = &cobra.Command{ Short: "List Edge Connect application instances", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - instanceKey := client.AppInstanceKey{ + instanceKey := edgeconnect.AppInstanceKey{ Organization: organization, Name: instanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: cloudletOrg, Name: cloudletName, }, @@ -112,10 +112,10 @@ var deleteInstanceCmd = &cobra.Command{ Short: "Delete an Edge Connect application instance", Run: func(cmd *cobra.Command, args []string) { c := newSDKClient() - instanceKey := client.AppInstanceKey{ + instanceKey := edgeconnect.AppInstanceKey{ Organization: organization, Name: instanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: cloudletOrg, Name: cloudletName, }, diff --git a/oapi-codegen.yaml b/oapi-codegen.yaml deleted file mode 100644 index 3e05cf0..0000000 --- a/oapi-codegen.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: client -output: sdk/client/types_generated.go -generate: - models: true - client: false - embedded-spec: false -output-options: - skip-prune: true \ No newline at end of file diff --git a/sdk/client/appinstance.go b/sdk/edgeconnect/appinstance.go similarity index 99% rename from sdk/client/appinstance.go rename to sdk/edgeconnect/appinstance.go index 01afafc..44c8b0b 100644 --- a/sdk/client/appinstance.go +++ b/sdk/edgeconnect/appinstance.go @@ -1,7 +1,7 @@ // ABOUTME: Application instance lifecycle management APIs for EdgeXR Master Controller // ABOUTME: Provides typed methods for creating, querying, and deleting application instances -package client +package edgeconnect import ( "context" diff --git a/sdk/client/appinstance_test.go b/sdk/edgeconnect/appinstance_test.go similarity index 99% rename from sdk/client/appinstance_test.go rename to sdk/edgeconnect/appinstance_test.go index a7fb9d8..c97f62a 100644 --- a/sdk/client/appinstance_test.go +++ b/sdk/edgeconnect/appinstance_test.go @@ -1,7 +1,7 @@ // ABOUTME: Unit tests for AppInstance management APIs using httptest mock server // ABOUTME: Tests create, show, list, refresh, and delete operations with error conditions -package client +package edgeconnect import ( "context" diff --git a/sdk/client/apps.go b/sdk/edgeconnect/apps.go similarity index 99% rename from sdk/client/apps.go rename to sdk/edgeconnect/apps.go index 8efcc8e..af07a3f 100644 --- a/sdk/client/apps.go +++ b/sdk/edgeconnect/apps.go @@ -1,7 +1,7 @@ // ABOUTME: Application lifecycle management APIs for EdgeXR Master Controller // ABOUTME: Provides typed methods for creating, querying, and deleting applications -package client +package edgeconnect import ( "context" diff --git a/sdk/client/apps_test.go b/sdk/edgeconnect/apps_test.go similarity index 99% rename from sdk/client/apps_test.go rename to sdk/edgeconnect/apps_test.go index 872456f..e424bbf 100644 --- a/sdk/client/apps_test.go +++ b/sdk/edgeconnect/apps_test.go @@ -1,7 +1,7 @@ // ABOUTME: Unit tests for App management APIs using httptest mock server // ABOUTME: Tests create, show, list, and delete operations with error conditions -package client +package edgeconnect import ( "context" diff --git a/sdk/client/auth.go b/sdk/edgeconnect/auth.go similarity index 99% rename from sdk/client/auth.go rename to sdk/edgeconnect/auth.go index d50d03c..eab24b9 100644 --- a/sdk/client/auth.go +++ b/sdk/edgeconnect/auth.go @@ -1,7 +1,7 @@ // ABOUTME: Authentication providers for EdgeXR Master Controller API // ABOUTME: Supports Bearer token authentication with pluggable provider interface -package client +package edgeconnect import ( "bytes" @@ -181,4 +181,4 @@ func NewNoAuthProvider() *NoAuthProvider { // Attach does nothing (no authentication) func (n *NoAuthProvider) Attach(ctx context.Context, req *http.Request) error { return nil -} \ No newline at end of file +} diff --git a/sdk/client/auth_test.go b/sdk/edgeconnect/auth_test.go similarity index 99% rename from sdk/client/auth_test.go rename to sdk/edgeconnect/auth_test.go index c7e3b04..8ea3176 100644 --- a/sdk/client/auth_test.go +++ b/sdk/edgeconnect/auth_test.go @@ -1,7 +1,7 @@ // ABOUTME: Unit tests for authentication providers including username/password token flow // ABOUTME: Tests token caching, login flow, and error conditions with mock servers -package client +package edgeconnect import ( "context" @@ -223,4 +223,4 @@ func TestNewClientWithCredentials(t *testing.T) { assert.Equal(t, "testuser", authProvider.Username) assert.Equal(t, "testpass", authProvider.Password) assert.Equal(t, "https://example.com", authProvider.BaseURL) -} \ No newline at end of file +} diff --git a/sdk/client/client.go b/sdk/edgeconnect/client.go similarity index 94% rename from sdk/client/client.go rename to sdk/edgeconnect/client.go index bcc1aa2..2a79cff 100644 --- a/sdk/client/client.go +++ b/sdk/edgeconnect/client.go @@ -1,7 +1,7 @@ // ABOUTME: Core EdgeXR Master Controller SDK client with HTTP transport and auth // ABOUTME: Provides typed APIs for app, instance, and cloudlet management operations -package client +package edgeconnect import ( "net/http" @@ -20,10 +20,10 @@ type Client struct { // RetryOptions configures retry behavior for API calls type RetryOptions struct { - MaxRetries int - InitialDelay time.Duration - MaxDelay time.Duration - Multiplier float64 + MaxRetries int + InitialDelay time.Duration + MaxDelay time.Duration + Multiplier float64 RetryableHTTPStatusCodes []int } @@ -119,4 +119,4 @@ func (c *Client) logf(format string, v ...interface{}) { if c.Logger != nil { c.Logger.Printf(format, v...) } -} \ No newline at end of file +} diff --git a/sdk/client/cloudlet.go b/sdk/edgeconnect/cloudlet.go similarity index 99% rename from sdk/client/cloudlet.go rename to sdk/edgeconnect/cloudlet.go index 0b0b31b..e3f4b7d 100644 --- a/sdk/client/cloudlet.go +++ b/sdk/edgeconnect/cloudlet.go @@ -1,7 +1,7 @@ // ABOUTME: Cloudlet management APIs for EdgeXR Master Controller // ABOUTME: Provides typed methods for creating, querying, and managing edge cloudlets -package client +package edgeconnect import ( "context" diff --git a/sdk/client/cloudlet_test.go b/sdk/edgeconnect/cloudlet_test.go similarity index 99% rename from sdk/client/cloudlet_test.go rename to sdk/edgeconnect/cloudlet_test.go index 53dc4c2..7d129bb 100644 --- a/sdk/client/cloudlet_test.go +++ b/sdk/edgeconnect/cloudlet_test.go @@ -1,7 +1,7 @@ // ABOUTME: Unit tests for Cloudlet management APIs using httptest mock server // ABOUTME: Tests create, show, list, delete, manifest, and resource usage operations -package client +package edgeconnect import ( "context" diff --git a/sdk/client/types.go b/sdk/edgeconnect/types.go similarity index 99% rename from sdk/client/types.go rename to sdk/edgeconnect/types.go index d2f884d..67ccb87 100644 --- a/sdk/client/types.go +++ b/sdk/edgeconnect/types.go @@ -1,7 +1,7 @@ // ABOUTME: Core type definitions for EdgeXR Master Controller SDK // ABOUTME: These types are based on the swagger API specification and existing client patterns -package client +package edgeconnect import ( "encoding/json" diff --git a/sdk/examples/comprehensive/main.go b/sdk/examples/comprehensive/main.go index 85985de..aafd588 100644 --- a/sdk/examples/comprehensive/main.go +++ b/sdk/examples/comprehensive/main.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client" + "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect" ) func main() { @@ -24,20 +24,20 @@ func main() { username := getEnvOrDefault("EDGEXR_USERNAME", "") password := getEnvOrDefault("EDGEXR_PASSWORD", "") - var edgeClient *client.Client + var client *edgeconnect.Client if token != "" { fmt.Println("🔐 Using Bearer token authentication") - edgeClient = client.NewClient(baseURL, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), - client.WithAuthProvider(client.NewStaticTokenProvider(token)), - client.WithLogger(log.Default()), + client = edgeconnect.NewClient(baseURL, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)), + edgeconnect.WithLogger(log.Default()), ) } else if username != "" && password != "" { fmt.Println("🔐 Using username/password authentication") - edgeClient = client.NewClientWithCredentials(baseURL, username, password, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), - client.WithLogger(log.Default()), + client = edgeconnect.NewClientWithCredentials(baseURL, username, password, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + edgeconnect.WithLogger(log.Default()), ) } else { log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD") @@ -61,7 +61,7 @@ func main() { fmt.Printf("Organization: %s, Region: %s\n\n", config.Organization, config.Region) // Run the complete workflow - if err := runComprehensiveWorkflow(ctx, edgeClient, config); err != nil { + if err := runComprehensiveWorkflow(ctx, client, config); err != nil { log.Fatalf("Workflow failed: %v", err) } @@ -85,15 +85,15 @@ type WorkflowConfig struct { FlavorName string } -func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config WorkflowConfig) error { +func runComprehensiveWorkflow(ctx context.Context, c *edgeconnect.Client, config WorkflowConfig) error { fmt.Println("═══ Phase 1: Application Management ═══") // 1. Create Application fmt.Println("\n1️⃣ Creating application...") - app := &client.NewAppInput{ + app := &edgeconnect.NewAppInput{ Region: config.Region, - App: client.App{ - Key: client.AppKey{ + App: edgeconnect.App{ + Key: edgeconnect.AppKey{ Organization: config.Organization, Name: config.AppName, Version: config.AppVersion, @@ -101,10 +101,10 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work Deployment: "kubernetes", ImageType: "ImageTypeDocker", ImagePath: "https://registry-1.docker.io/library/nginx:latest", - DefaultFlavor: client.Flavor{Name: config.FlavorName}, + DefaultFlavor: edgeconnect.Flavor{Name: config.FlavorName}, ServerlessConfig: struct{}{}, AllowServerless: true, - RequiredOutboundConnections: []client.SecurityRule{ + RequiredOutboundConnections: []edgeconnect.SecurityRule{ { Protocol: "tcp", PortRangeMin: 80, @@ -128,7 +128,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 2. Show Application Details fmt.Println("\n2️⃣ Querying application details...") - appKey := client.AppKey{ + appKey := edgeconnect.AppKey{ Organization: config.Organization, Name: config.AppName, Version: config.AppVersion, @@ -146,7 +146,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 3. List Applications in Organization fmt.Println("\n3️⃣ Listing applications in organization...") - filter := client.AppKey{Organization: config.Organization} + filter := edgeconnect.AppKey{Organization: config.Organization} apps, err := c.ShowApps(ctx, filter, config.Region) if err != nil { return fmt.Errorf("failed to list apps: %w", err) @@ -160,19 +160,19 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 4. Create Application Instance fmt.Println("\n4️⃣ Creating application instance...") - instance := &client.NewAppInstanceInput{ + instance := &edgeconnect.NewAppInstanceInput{ Region: config.Region, - AppInst: client.AppInstance{ - Key: client.AppInstanceKey{ + AppInst: edgeconnect.AppInstance{ + Key: edgeconnect.AppInstanceKey{ Organization: config.Organization, Name: config.InstanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: config.CloudletOrg, Name: config.CloudletName, }, }, AppKey: appKey, - Flavor: client.Flavor{Name: config.FlavorName}, + Flavor: edgeconnect.Flavor{Name: config.FlavorName}, }, } @@ -184,10 +184,10 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 5. Wait for Application Instance to be Ready fmt.Println("\n5️⃣ Waiting for application instance to be ready...") - instanceKey := client.AppInstanceKey{ + instanceKey := edgeconnect.AppInstanceKey{ Organization: config.Organization, Name: config.InstanceName, - CloudletKey: client.CloudletKey{ + CloudletKey: edgeconnect.CloudletKey{ Organization: config.CloudletOrg, Name: config.CloudletName, }, @@ -207,7 +207,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 6. List Application Instances fmt.Println("\n6️⃣ Listing application instances...") - instances, err := c.ShowAppInstances(ctx, client.AppInstanceKey{Organization: config.Organization}, config.Region) + instances, err := c.ShowAppInstances(ctx, edgeconnect.AppInstanceKey{Organization: config.Organization}, config.Region) if err != nil { return fmt.Errorf("failed to list app instances: %w", err) } @@ -228,7 +228,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 8. Show Cloudlet Details fmt.Println("\n8️⃣ Querying cloudlet information...") - cloudletKey := client.CloudletKey{ + cloudletKey := edgeconnect.CloudletKey{ Organization: config.CloudletOrg, Name: config.CloudletName, } @@ -287,7 +287,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work // 13. Verify Cleanup fmt.Println("\n1️⃣3️⃣ Verifying cleanup...") _, err = c.ShowApp(ctx, appKey, config.Region) - if err != nil && fmt.Sprintf("%v", err) == client.ErrResourceNotFound.Error() { + if err != nil && fmt.Sprintf("%v", err) == edgeconnect.ErrResourceNotFound.Error() { fmt.Printf("✅ Cleanup verified - app no longer exists\n") } else if err != nil { fmt.Printf("✅ Cleanup appears successful (verification returned: %v)\n", err) @@ -306,7 +306,7 @@ func getEnvOrDefault(key, defaultValue string) string { } // waitForInstanceReady polls the instance status until it's no longer "Creating" or timeout -func waitForInstanceReady(ctx context.Context, c *client.Client, instanceKey client.AppInstanceKey, region string, timeout time.Duration) (client.AppInstance, error) { +func waitForInstanceReady(ctx context.Context, c *edgeconnect.Client, instanceKey edgeconnect.AppInstanceKey, region string, timeout time.Duration) (edgeconnect.AppInstance, error) { timeoutCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() @@ -318,7 +318,7 @@ func waitForInstanceReady(ctx context.Context, c *client.Client, instanceKey cli for { select { case <-timeoutCtx.Done(): - return client.AppInstance{}, fmt.Errorf("timeout waiting for instance to be ready after %v", timeout) + return edgeconnect.AppInstance{}, fmt.Errorf("timeout waiting for instance to be ready after %v", timeout) case <-ticker.C: instance, err := c.ShowAppInstance(timeoutCtx, instanceKey, region) diff --git a/sdk/examples/deploy_app.go b/sdk/examples/deploy_app.go index f68063e..b413886 100644 --- a/sdk/examples/deploy_app.go +++ b/sdk/examples/deploy_app.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client" + "edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect" ) func main() { @@ -24,22 +24,22 @@ func main() { username := getEnvOrDefault("EDGEXR_USERNAME", "") password := getEnvOrDefault("EDGEXR_PASSWORD", "") - var edgeClient *client.Client + var edgeClient *edgeconnect.Client if token != "" { // Use static token authentication fmt.Println("🔐 Using Bearer token authentication") - edgeClient = client.NewClient(baseURL, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), - client.WithAuthProvider(client.NewStaticTokenProvider(token)), - client.WithLogger(log.Default()), + edgeClient = edgeconnect.NewClient(baseURL, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)), + edgeconnect.WithLogger(log.Default()), ) } else if username != "" && password != "" { // Use username/password authentication (matches existing client pattern) fmt.Println("🔐 Using username/password authentication") - edgeClient = client.NewClientWithCredentials(baseURL, username, password, - client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), - client.WithLogger(log.Default()), + edgeClient = edgeconnect.NewClientWithCredentials(baseURL, username, password, + edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), + edgeconnect.WithLogger(log.Default()), ) } else { log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD") @@ -48,10 +48,10 @@ func main() { ctx := context.Background() // Example application to deploy - app := &client.NewAppInput{ + app := &edgeconnect.NewAppInput{ Region: "EU", - App: client.App{ - Key: client.AppKey{ + App: edgeconnect.App{ + Key: edgeconnect.AppKey{ Organization: "edp2", Name: "my-edge-app", Version: "1.0.0", @@ -59,7 +59,7 @@ func main() { Deployment: "docker", ImageType: "ImageTypeDocker", ImagePath: "https://registry-1.docker.io/library/nginx:latest", - DefaultFlavor: client.Flavor{Name: "EU.small"}, + DefaultFlavor: edgeconnect.Flavor{Name: "EU.small"}, ServerlessConfig: struct{}{}, AllowServerless: false, }, @@ -73,7 +73,7 @@ func main() { fmt.Println("✅ SDK example completed successfully!") } -func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, input *client.NewAppInput) error { +func demonstrateAppLifecycle(ctx context.Context, edgeClient *edgeconnect.Client, input *edgeconnect.NewAppInput) error { appKey := input.App.Key region := input.Region @@ -98,7 +98,7 @@ func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, inp // Step 3: List applications in the organization fmt.Println("\n3. Listing applications...") - filter := client.AppKey{Organization: appKey.Organization} + filter := edgeconnect.AppKey{Organization: appKey.Organization} apps, err := edgeClient.ShowApps(ctx, filter, region) if err != nil { return fmt.Errorf("failed to list apps: %w", err) @@ -116,7 +116,7 @@ func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, inp fmt.Println("\n5. Verifying deletion...") _, err = edgeClient.ShowApp(ctx, appKey, region) if err != nil { - if strings.Contains(fmt.Sprintf("%v", err), client.ErrResourceNotFound.Error()) { + if strings.Contains(fmt.Sprintf("%v", err), edgeconnect.ErrResourceNotFound.Error()) { fmt.Printf("✅ App successfully deleted (not found)\n") } else { return fmt.Errorf("unexpected error verifying deletion: %w", err)