From 28f79d1a1a540cb47ab51dddc232abcb92a5a8db Mon Sep 17 00:00:00 2001 From: Dominik Giger Date: Wed, 10 Apr 2024 14:18:23 +0200 Subject: [PATCH] Add ShowMaxZones parameter to deployment-template API. (#462) With this parameter set, the `max_zones` field in the ICs is filled. --- .changelog/1.17.0/462.yml | 4 ++++ pkg/api/deploymentapi/deptemplateapi/get.go | 4 +++- pkg/api/deploymentapi/deptemplateapi/get_test.go | 8 ++++++-- pkg/api/deploymentapi/deptemplateapi/list.go | 4 +++- pkg/api/deploymentapi/deptemplateapi/list_test.go | 7 ++++++- 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 .changelog/1.17.0/462.yml diff --git a/.changelog/1.17.0/462.yml b/.changelog/1.17.0/462.yml new file mode 100644 index 00000000..31ab52e8 --- /dev/null +++ b/.changelog/1.17.0/462.yml @@ -0,0 +1,4 @@ +category: enhancement +title: Add `show_max_zones` parameter for deployment-templates API. +description: | + This parameter adds the `max_zones` field to each instance-configuration. (Left empty by default). diff --git a/pkg/api/deploymentapi/deptemplateapi/get.go b/pkg/api/deploymentapi/deptemplateapi/get.go index cb2494e1..bc1c08ae 100644 --- a/pkg/api/deploymentapi/deptemplateapi/get.go +++ b/pkg/api/deploymentapi/deptemplateapi/get.go @@ -37,6 +37,7 @@ type GetParams struct { StackVersion string HideInstanceConfigurations bool + ShowMaxZones bool } // Validate ensures the parameters are usable by Get. @@ -89,7 +90,8 @@ func getParams(params GetParams) *deployment_templates.GetDeploymentTemplateV2Pa var apiParams = deployment_templates.NewGetDeploymentTemplateV2Params(). WithShowInstanceConfigurations(ec.Bool(!params.HideInstanceConfigurations)). WithRegion(params.Region). - WithTemplateID(params.TemplateID) + WithTemplateID(params.TemplateID). + WithShowMaxZones(ec.Bool(params.ShowMaxZones)) if params.StackVersion != "" { apiParams.SetStackVersion(¶ms.StackVersion) diff --git a/pkg/api/deploymentapi/deptemplateapi/get_test.go b/pkg/api/deploymentapi/deptemplateapi/get_test.go index fc547667..284ea045 100644 --- a/pkg/api/deploymentapi/deptemplateapi/get_test.go +++ b/pkg/api/deploymentapi/deptemplateapi/get_test.go @@ -73,8 +73,9 @@ func TestGet(t *testing.T) { { name: "succeeds", args: args{params: GetParams{ - Region: "us-east-1", - TemplateID: "default", + Region: "us-east-1", + TemplateID: "default", + ShowMaxZones: true, API: api.NewMock(mock.New200ResponseAssertion( &mock.RequestAssertion{ Header: api.DefaultReadMockHeaders, @@ -84,6 +85,7 @@ func TestGet(t *testing.T) { Query: url.Values{ "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, + "show_max_zones": []string{"true"}, }, }, mock.NewByteBody(getRawResp), @@ -107,6 +109,7 @@ func TestGet(t *testing.T) { "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, "stack_version": []string{"6.8.0"}, + "show_max_zones": []string{"false"}, }, }, mock.NewByteBody(getRawResp), @@ -128,6 +131,7 @@ func TestGet(t *testing.T) { Query: url.Values{ "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, + "show_max_zones": []string{"false"}, }, }, mock.SampleInternalError().Response.Body, diff --git a/pkg/api/deploymentapi/deptemplateapi/list.go b/pkg/api/deploymentapi/deptemplateapi/list.go index 155dfbc0..90d5c6c8 100644 --- a/pkg/api/deploymentapi/deptemplateapi/list.go +++ b/pkg/api/deploymentapi/deptemplateapi/list.go @@ -39,6 +39,7 @@ type ListParams struct { ShowHidden bool HideInstanceConfigurations bool + ShowMaxZones bool } // Validate ensures the parameters are usable by List. @@ -90,7 +91,8 @@ func listParams(params ListParams) *deployment_templates.GetDeploymentTemplatesV var apiParams = deployment_templates.NewGetDeploymentTemplatesV2Params(). WithShowInstanceConfigurations(ec.Bool(!params.HideInstanceConfigurations)). WithShowHidden(¶ms.ShowHidden). - WithRegion(params.Region) + WithRegion(params.Region). + WithShowMaxZones(ec.Bool(params.ShowMaxZones)) if params.MetadataFilter != "" { apiParams.SetMetadata(¶ms.MetadataFilter) diff --git a/pkg/api/deploymentapi/deptemplateapi/list_test.go b/pkg/api/deploymentapi/deptemplateapi/list_test.go index 611b3673..96fae149 100644 --- a/pkg/api/deploymentapi/deptemplateapi/list_test.go +++ b/pkg/api/deploymentapi/deptemplateapi/list_test.go @@ -72,7 +72,8 @@ func TestList(t *testing.T) { { name: "succeeds", args: args{params: ListParams{ - Region: "us-east-1", + Region: "us-east-1", + ShowMaxZones: true, API: api.NewMock(mock.New200ResponseAssertion( &mock.RequestAssertion{ Header: api.DefaultReadMockHeaders, @@ -83,6 +84,7 @@ func TestList(t *testing.T) { "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, "show_hidden": []string{"false"}, + "show_max_zones": []string{"true"}, }, }, mock.NewByteBody(listRawResp), @@ -106,6 +108,7 @@ func TestList(t *testing.T) { "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, "show_hidden": []string{"false"}, + "show_max_zones": []string{"false"}, }, }, mock.NewByteBody(listRawResp), @@ -131,6 +134,7 @@ func TestList(t *testing.T) { "show_instance_configurations": []string{"true"}, "show_hidden": []string{"false"}, "stack_version": []string{"6.2.1"}, + "show_max_zones": []string{"false"}, }, }, mock.NewByteBody(listRawResp), @@ -152,6 +156,7 @@ func TestList(t *testing.T) { "region": []string{"us-east-1"}, "show_instance_configurations": []string{"true"}, "show_hidden": []string{"false"}, + "show_max_zones": []string{"false"}, }, }, mock.SampleInternalError().Response.Body,