From b62d16b2273a246a6ecea869982a654d476b23b7 Mon Sep 17 00:00:00 2001 From: Magnus Landerblom Date: Wed, 17 Dec 2025 08:26:36 +0100 Subject: [PATCH 1/2] Set header User-Agent=cloudamqp-cli --- client/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client/client.go b/client/client.go index 56450cb..fbcaa01 100644 --- a/client/client.go +++ b/client/client.go @@ -77,6 +77,7 @@ func (c *Client) makeRequest(method, endpoint string, body any) ([]byte, error) if contentType != "" { req.Header.Set("Content-Type", contentType) } + req.Header.Set("User-Agent", "cloudamqp-cli") resp, err := c.httpClient.Do(req) if err != nil { From 2a6aea221c16198794544c5ed5b9ccf223a25cbe Mon Sep 17 00:00:00 2001 From: Magnus Landerblom Date: Wed, 17 Dec 2025 10:45:58 +0100 Subject: [PATCH 2/2] Include version in user agent string --- client/client.go | 12 ++++++++---- client/client_test.go | 20 ++++++++++---------- client/common_operations_vcr_test.go | 8 ++++---- client/instances_bunny_vcr_test.go | 6 +++--- client/instances_test.go | 18 +++++++++--------- client/instances_vcr_test.go | 2 +- client/regions_test.go | 8 ++++---- client/vpc_vcr_test.go | 4 ++-- client/vpcs_test.go | 14 +++++++------- cmd/audit.go | 2 +- cmd/completion_helpers.go | 14 +++++++------- cmd/instance_account.go | 4 ++-- cmd/instance_actions.go | 10 +++++----- cmd/instance_config.go | 6 +++--- cmd/instance_create.go | 2 +- cmd/instance_delete.go | 2 +- cmd/instance_get.go | 2 +- cmd/instance_list.go | 2 +- cmd/instance_nodes.go | 4 ++-- cmd/instance_plugins.go | 6 +++--- cmd/instance_resize.go | 2 +- cmd/instance_update.go | 2 +- cmd/plans.go | 2 +- cmd/regions.go | 2 +- cmd/rotate_key.go | 2 +- cmd/team_invite.go | 2 +- cmd/team_list.go | 2 +- cmd/team_remove.go | 2 +- cmd/team_update.go | 2 +- cmd/vpc_create.go | 2 +- cmd/vpc_delete.go | 2 +- cmd/vpc_get.go | 2 +- cmd/vpc_list.go | 2 +- cmd/vpc_update.go | 2 +- 34 files changed, 89 insertions(+), 85 deletions(-) diff --git a/client/client.go b/client/client.go index fbcaa01..5bbe23d 100644 --- a/client/client.go +++ b/client/client.go @@ -17,9 +17,10 @@ type Client struct { apiKey string baseURL string httpClient *http.Client + version string } -func New(apiKey string) *Client { +func New(apiKey, version string) *Client { baseURL := "https://customer.cloudamqp.com/api" if envURL := os.Getenv("CLOUDAMQP_URL"); envURL != "" { baseURL = envURL @@ -28,24 +29,27 @@ func New(apiKey string) *Client { apiKey: apiKey, baseURL: baseURL, httpClient: &http.Client{}, + version: version, } } -func NewWithBaseURL(apiKey, baseURL string) *Client { +func NewWithBaseURL(apiKey, baseURL, version string) *Client { return &Client{ apiKey: apiKey, baseURL: baseURL, httpClient: &http.Client{}, + version: version, } } // NewWithHTTPClient creates a new client with a custom HTTP client. // This is useful for testing with tools like go-vcr. -func NewWithHTTPClient(apiKey, baseURL string, httpClient *http.Client) *Client { +func NewWithHTTPClient(apiKey, baseURL, version string, httpClient *http.Client) *Client { return &Client{ apiKey: apiKey, baseURL: baseURL, httpClient: httpClient, + version: version, } } @@ -77,7 +81,7 @@ func (c *Client) makeRequest(method, endpoint string, body any) ([]byte, error) if contentType != "" { req.Header.Set("Content-Type", contentType) } - req.Header.Set("User-Agent", "cloudamqp-cli") + req.Header.Set("User-Agent", fmt.Sprintf("cloudamqp-cli/%s", c.version)) resp, err := c.httpClient.Do(req) if err != nil { diff --git a/client/client_test.go b/client/client_test.go index c82b7fe..b752e53 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -12,7 +12,7 @@ import ( func TestNew(t *testing.T) { apiKey := "test-api-key" - client := New(apiKey) + client := New(apiKey, "test") assert.NotNil(t, client) assert.Equal(t, apiKey, client.apiKey) @@ -29,7 +29,7 @@ func TestNew_WithEnvironmentVariable(t *testing.T) { os.Setenv("CLOUDAMQP_URL", customURL) apiKey := "test-api-key" - client := New(apiKey) + client := New(apiKey, "test") assert.NotNil(t, client) assert.Equal(t, apiKey, client.apiKey) @@ -38,7 +38,7 @@ func TestNew_WithEnvironmentVariable(t *testing.T) { // Test with empty environment variable (should use default) os.Setenv("CLOUDAMQP_URL", "") - client = New(apiKey) + client = New(apiKey, "test") assert.NotNil(t, client) assert.Equal(t, "https://customer.cloudamqp.com/api", client.baseURL) @@ -64,7 +64,7 @@ func TestMakeRequest_GET_Success(t *testing.T) { defer server.Close() // Create client with test server URL - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") // Test request resp, err := client.makeRequest("GET", "/test", nil) @@ -92,7 +92,7 @@ func TestMakeRequest_POST_FormData(t *testing.T) { defer server.Close() // Create client with test server URL - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") // Test request with form data formData := url.Values{} @@ -123,7 +123,7 @@ func TestMakeRequest_POST_JSON(t *testing.T) { defer server.Close() // Create client with test server URL - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") // Test request with JSON data jsonData := map[string]string{"test": "value"} @@ -143,7 +143,7 @@ func TestMakeRequest_APIError_JSON(t *testing.T) { defer server.Close() // Create client with test server URL - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") // Test request _, err := client.makeRequest("GET", "/test", nil) @@ -161,7 +161,7 @@ func TestMakeRequest_APIError_Plain(t *testing.T) { defer server.Close() // Create client with test server URL - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") // Test request _, err := client.makeRequest("GET", "/test", nil) @@ -172,7 +172,7 @@ func TestMakeRequest_APIError_Plain(t *testing.T) { func TestMakeRequest_NetworkError(t *testing.T) { // Create client with invalid URL - client := NewWithBaseURL("test-api-key", "http://invalid-url-that-does-not-exist") + client := NewWithBaseURL("test-api-key", "http://invalid-url-that-does-not-exist", "test") // Test request _, err := client.makeRequest("GET", "/test", nil) @@ -182,7 +182,7 @@ func TestMakeRequest_NetworkError(t *testing.T) { } func TestMakeRequest_InvalidJSON(t *testing.T) { - client := New("test-api-key") + client := New("test-api-key", "test") // Test with invalid JSON data invalidData := make(chan int) // channels can't be marshaled to JSON diff --git a/client/common_operations_vcr_test.go b/client/common_operations_vcr_test.go index e02e2ae..90e4968 100644 --- a/client/common_operations_vcr_test.go +++ b/client/common_operations_vcr_test.go @@ -33,7 +33,7 @@ func TestListInstancesVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) instances, err := client.ListInstances() @@ -64,7 +64,7 @@ func TestGetInstanceVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Use an existing instance ID (should match cassette) instanceID := 359563 @@ -98,7 +98,7 @@ func TestListRegionsVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) regions, err := client.ListRegions("") @@ -135,7 +135,7 @@ func TestListPlansVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) plans, err := client.ListPlans("") diff --git a/client/instances_bunny_vcr_test.go b/client/instances_bunny_vcr_test.go index ecc2fcb..a20af06 100644 --- a/client/instances_bunny_vcr_test.go +++ b/client/instances_bunny_vcr_test.go @@ -37,7 +37,7 @@ func TestCreateInstanceBunny1(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Create instance with bunny-1 plan req := &InstanceCreateRequest{ @@ -84,7 +84,7 @@ func TestUpdateInstanceBunny1ToHare1(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Use a real instance ID from a bunny-1 instance // This should be an instance that is already created and fully configured @@ -138,7 +138,7 @@ func TestDeleteInstanceBunny1(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Use an instance ID that exists (from a previous test or manual creation) instanceID := 359559 diff --git a/client/instances_test.go b/client/instances_test.go index 5f78bc5..adea9cd 100644 --- a/client/instances_test.go +++ b/client/instances_test.go @@ -31,7 +31,7 @@ func TestListInstances(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") instances, err := client.ListInstances() @@ -62,7 +62,7 @@ func TestGetInstance(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") instance, err := client.GetInstance(1234) @@ -97,7 +97,7 @@ func TestCreateInstance(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &InstanceCreateRequest{ Name: "test-instance", @@ -128,7 +128,7 @@ func TestCreateInstance_WithTags(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &InstanceCreateRequest{ Name: "test-instance", @@ -154,7 +154,7 @@ func TestCreateInstance_WithVPC(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") vpcID := 5678 req := &InstanceCreateRequest{ @@ -183,7 +183,7 @@ func TestUpdateInstance(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &InstanceUpdateRequest{ Name: "updated-name", @@ -203,7 +203,7 @@ func TestDeleteInstance(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") err := client.DeleteInstance(1234) assert.NoError(t, err) @@ -223,7 +223,7 @@ func TestResizeInstanceDisk(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &DiskResizeRequest{ ExtraDiskSize: 100, @@ -246,7 +246,7 @@ func TestResizeInstanceDisk_NoDowntime(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &DiskResizeRequest{ ExtraDiskSize: 50, diff --git a/client/instances_vcr_test.go b/client/instances_vcr_test.go index 73e25f2..0552594 100644 --- a/client/instances_vcr_test.go +++ b/client/instances_vcr_test.go @@ -83,7 +83,7 @@ func TestCreateInstanceVCR(t *testing.T) { httpClient := &http.Client{Transport: r} // Create client with VCR HTTP client - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Create instance request req := &InstanceCreateRequest{ diff --git a/client/regions_test.go b/client/regions_test.go index 40e3676..dec8acf 100644 --- a/client/regions_test.go +++ b/client/regions_test.go @@ -34,7 +34,7 @@ func TestListRegions(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") regions, err := client.ListRegions("") @@ -63,7 +63,7 @@ func TestListRegions_WithProvider(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") regions, err := client.ListRegions("amazon-web-services") @@ -97,7 +97,7 @@ func TestListPlans(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") plans, err := client.ListPlans("") @@ -125,7 +125,7 @@ func TestListPlans_WithBackend(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") plans, err := client.ListPlans("rabbitmq") diff --git a/client/vpc_vcr_test.go b/client/vpc_vcr_test.go index 5f63dc0..f9fdf87 100644 --- a/client/vpc_vcr_test.go +++ b/client/vpc_vcr_test.go @@ -32,7 +32,7 @@ func TestListVPCsVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) vpcs, err := client.ListVPCs() @@ -62,7 +62,7 @@ func TestVPCLifecycleVCR(t *testing.T) { } httpClient := &http.Client{Transport: r} - client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", httpClient) + client := NewWithHTTPClient(apiKey, "https://customer.cloudamqp.com/api", "test", httpClient) // Step 1: Create VPC t.Log("Step 1: Creating VPC") diff --git a/client/vpcs_test.go b/client/vpcs_test.go index e0967ef..0c1fcf0 100644 --- a/client/vpcs_test.go +++ b/client/vpcs_test.go @@ -32,7 +32,7 @@ func TestListVPCs(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") vpcs, err := client.ListVPCs() @@ -65,7 +65,7 @@ func TestGetVPC(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") vpc, err := client.GetVPC(5678) @@ -100,7 +100,7 @@ func TestCreateVPC(t *testing.T) { defer server.Close() // Test - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &VPCCreateRequest{ Name: "test-vpc", @@ -131,7 +131,7 @@ func TestCreateVPC_WithTags(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &VPCCreateRequest{ Name: "test-vpc", @@ -162,7 +162,7 @@ func TestUpdateVPC(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") req := &VPCUpdateRequest{ Name: "updated-vpc-name", @@ -182,7 +182,7 @@ func TestDeleteVPC(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") err := client.DeleteVPC(5678) assert.NoError(t, err) @@ -195,7 +195,7 @@ func TestVPCError_NotFound(t *testing.T) { })) defer server.Close() - client := NewWithBaseURL("test-api-key", server.URL) + client := NewWithBaseURL("test-api-key", server.URL, "test") _, err := client.GetVPC(9999) diff --git a/cmd/audit.go b/cmd/audit.go index c3aa437..01b0094 100644 --- a/cmd/audit.go +++ b/cmd/audit.go @@ -22,7 +22,7 @@ var auditCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) csv, err := c.GetAuditLogCSV(auditTimestamp) if err != nil { diff --git a/cmd/completion_helpers.go b/cmd/completion_helpers.go index ef67d1b..3c613f8 100644 --- a/cmd/completion_helpers.go +++ b/cmd/completion_helpers.go @@ -32,7 +32,7 @@ func completeInstances(cmd *cobra.Command, args []string, toComplete string) ([] return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var instances []client.Instance @@ -67,7 +67,7 @@ func completePlans(cmd *cobra.Command, args []string, toComplete string) ([]stri return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var plans []client.Plan @@ -102,7 +102,7 @@ func completeRegions(cmd *cobra.Command, args []string, toComplete string) ([]st return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var regions []client.Region @@ -138,7 +138,7 @@ func completeVPCs(cmd *cobra.Command, args []string, toComplete string) ([]strin return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var vpcs []client.VPC @@ -190,7 +190,7 @@ func completeVPCIDFlag(cmd *cobra.Command, args []string, toComplete string) ([] return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var vpcs []client.VPC @@ -225,7 +225,7 @@ func completeCopyFromIDFlag(cmd *cobra.Command, args []string, toComplete string return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var instances []client.Instance @@ -260,7 +260,7 @@ func completeVPCArgs(cmd *cobra.Command, args []string, toComplete string) ([]st return nil, cobra.ShellCompDirectiveNoFileComp } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Try to get from cache var vpcs []client.VPC diff --git a/cmd/instance_account.go b/cmd/instance_account.go index 1536fd6..6496db1 100644 --- a/cmd/instance_account.go +++ b/cmd/instance_account.go @@ -35,7 +35,7 @@ var rotatePasswordCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.RotatePassword(idFlag) if err != nil { @@ -65,7 +65,7 @@ var rotateInstanceAPIKeyCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.RotateInstanceAPIKey(idFlag) if err != nil { diff --git a/cmd/instance_actions.go b/cmd/instance_actions.go index 65dc363..0b7c0aa 100644 --- a/cmd/instance_actions.go +++ b/cmd/instance_actions.go @@ -183,7 +183,7 @@ var upgradeVersionsCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) versions, err := c.GetUpgradeVersions(idFlag) if err != nil { @@ -214,7 +214,7 @@ func performNodeAction(cmd *cobra.Command, action string) error { return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) nodesStr, _ := cmd.Flags().GetString("nodes") var nodes []string @@ -258,7 +258,7 @@ func performClusterAction(cmd *cobra.Command, action string) error { return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) switch action { case "restart-cluster": @@ -292,7 +292,7 @@ func performUpgradeAction(cmd *cobra.Command, action, version string) error { return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) switch action { case "upgrade-erlang": @@ -326,7 +326,7 @@ func performToggleAction(cmd *cobra.Command, action string) error { return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) enable, _ := cmd.Flags().GetBool("enable") diff --git a/cmd/instance_config.go b/cmd/instance_config.go index 31cac48..6cb4836 100644 --- a/cmd/instance_config.go +++ b/cmd/instance_config.go @@ -37,7 +37,7 @@ var instanceConfigListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) config, err := c.GetRabbitMQConfig(idFlag) if err != nil { @@ -87,7 +87,7 @@ var instanceConfigGetCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) config, err := c.GetRabbitMQConfig(idFlag) if err != nil { @@ -127,7 +127,7 @@ var instanceConfigSetCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) // Convert string value to appropriate type var value interface{} diff --git a/cmd/instance_create.go b/cmd/instance_create.go index b5fa53c..b71a711 100644 --- a/cmd/instance_create.go +++ b/cmd/instance_create.go @@ -52,7 +52,7 @@ Optional flags: return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.InstanceCreateRequest{ Name: instanceName, diff --git a/cmd/instance_delete.go b/cmd/instance_delete.go index fd67bbd..9137113 100644 --- a/cmd/instance_delete.go +++ b/cmd/instance_delete.go @@ -56,7 +56,7 @@ WARNING: This action cannot be undone. All data will be lost.`, } } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.DeleteInstance(instanceID) if err != nil { diff --git a/cmd/instance_get.go b/cmd/instance_get.go index e0b5ce1..ed13dac 100644 --- a/cmd/instance_get.go +++ b/cmd/instance_get.go @@ -31,7 +31,7 @@ var instanceGetCmd = &cobra.Command{ return fmt.Errorf("invalid instance ID: %v", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) instance, err := c.GetInstance(instanceID) if err != nil { diff --git a/cmd/instance_list.go b/cmd/instance_list.go index 76fa7ec..998ad96 100644 --- a/cmd/instance_list.go +++ b/cmd/instance_list.go @@ -22,7 +22,7 @@ var instanceListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) instances, err := c.ListInstances() if err != nil { diff --git a/cmd/instance_nodes.go b/cmd/instance_nodes.go index 6777f91..06fbc2d 100644 --- a/cmd/instance_nodes.go +++ b/cmd/instance_nodes.go @@ -37,7 +37,7 @@ var instanceNodesListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) nodes, err := c.ListNodes(idFlag) if err != nil { @@ -93,7 +93,7 @@ var instanceNodesVersionsCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) versions, err := c.GetAvailableVersions(idFlag) if err != nil { diff --git a/cmd/instance_plugins.go b/cmd/instance_plugins.go index 47b2347..b0360f4 100644 --- a/cmd/instance_plugins.go +++ b/cmd/instance_plugins.go @@ -37,7 +37,7 @@ var instancePluginsListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) plugins, err := c.ListPlugins(idFlag) if err != nil { @@ -84,7 +84,7 @@ var instancePluginsEnableCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.EnablePlugin(idFlag, pluginName) if err != nil { @@ -116,7 +116,7 @@ var instancePluginsDisableCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.DisablePlugin(idFlag, pluginName) if err != nil { diff --git a/cmd/instance_resize.go b/cmd/instance_resize.go index 437d995..f57b311 100644 --- a/cmd/instance_resize.go +++ b/cmd/instance_resize.go @@ -57,7 +57,7 @@ Available disk sizes: 0, 25, 50, 100, 250, 500, 1000, 2000 GB`, return fmt.Errorf("invalid disk size. Valid sizes are: 0, 25, 50, 100, 250, 500, 1000, 2000 GB") } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.DiskResizeRequest{ ExtraDiskSize: diskSize, diff --git a/cmd/instance_update.go b/cmd/instance_update.go index c9fcf7b..13e4463 100644 --- a/cmd/instance_update.go +++ b/cmd/instance_update.go @@ -44,7 +44,7 @@ You can update the following fields: return fmt.Errorf("invalid instance ID: %v", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.InstanceUpdateRequest{ Name: updateInstanceName, diff --git a/cmd/plans.go b/cmd/plans.go index 744a879..4d760b2 100644 --- a/cmd/plans.go +++ b/cmd/plans.go @@ -24,7 +24,7 @@ var plansCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) plans, err := c.ListPlans(backendFilter) if err != nil { diff --git a/cmd/regions.go b/cmd/regions.go index ca78e69..95341e1 100644 --- a/cmd/regions.go +++ b/cmd/regions.go @@ -23,7 +23,7 @@ var regionsCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) regions, err := c.ListRegions(providerFilter) if err != nil { diff --git a/cmd/rotate_key.go b/cmd/rotate_key.go index b6167fc..8ed7190 100644 --- a/cmd/rotate_key.go +++ b/cmd/rotate_key.go @@ -20,7 +20,7 @@ var rotateKeyCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) resp, err := c.RotateAPIKey() if err != nil { diff --git a/cmd/team_invite.go b/cmd/team_invite.go index 35fadf6..0ea2a37 100644 --- a/cmd/team_invite.go +++ b/cmd/team_invite.go @@ -30,7 +30,7 @@ Default role: member`, return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.TeamInviteRequest{ Email: inviteEmail, diff --git a/cmd/team_list.go b/cmd/team_list.go index f3f58b8..56a112e 100644 --- a/cmd/team_list.go +++ b/cmd/team_list.go @@ -22,7 +22,7 @@ var teamListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) members, err := c.ListTeamMembers() if err != nil { diff --git a/cmd/team_remove.go b/cmd/team_remove.go index 29ae69a..e638730 100644 --- a/cmd/team_remove.go +++ b/cmd/team_remove.go @@ -22,7 +22,7 @@ var teamRemoveCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) resp, err := c.RemoveTeamMember(removeEmail) if err != nil { diff --git a/cmd/team_update.go b/cmd/team_update.go index 2acd1dd..77da907 100644 --- a/cmd/team_update.go +++ b/cmd/team_update.go @@ -29,7 +29,7 @@ Available roles: admin, devops, member, monitor, billing manager`, return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.TeamUpdateRequest{ Role: updateRole, diff --git a/cmd/vpc_create.go b/cmd/vpc_create.go index 84b7537..958ed3c 100644 --- a/cmd/vpc_create.go +++ b/cmd/vpc_create.go @@ -36,7 +36,7 @@ Optional flags: return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.VPCCreateRequest{ Name: vpcName, diff --git a/cmd/vpc_delete.go b/cmd/vpc_delete.go index 9eaca61..03719a0 100644 --- a/cmd/vpc_delete.go +++ b/cmd/vpc_delete.go @@ -56,7 +56,7 @@ WARNING: This action cannot be undone. All instances in the VPC must be deleted } } - c := client.New(apiKey) + c := client.New(apiKey, Version) err = c.DeleteVPC(vpcID) if err != nil { diff --git a/cmd/vpc_get.go b/cmd/vpc_get.go index 8f9687e..e0f8f29 100644 --- a/cmd/vpc_get.go +++ b/cmd/vpc_get.go @@ -31,7 +31,7 @@ var vpcGetCmd = &cobra.Command{ return fmt.Errorf("invalid VPC ID: %v", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) vpc, err := c.GetVPC(vpcID) if err != nil { diff --git a/cmd/vpc_list.go b/cmd/vpc_list.go index ea02724..fa5b2c9 100644 --- a/cmd/vpc_list.go +++ b/cmd/vpc_list.go @@ -22,7 +22,7 @@ var vpcListCmd = &cobra.Command{ return fmt.Errorf("failed to get API key: %w", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) vpcs, err := c.ListVPCs() if err != nil { diff --git a/cmd/vpc_update.go b/cmd/vpc_update.go index 694e1f5..7db9d18 100644 --- a/cmd/vpc_update.go +++ b/cmd/vpc_update.go @@ -41,7 +41,7 @@ You can update the following fields: return fmt.Errorf("invalid VPC ID: %v", err) } - c := client.New(apiKey) + c := client.New(apiKey, Version) req := &client.VPCUpdateRequest{ Name: updateVPCName,