From b9716ee94813094e0ebba4434de94c97a87a435e Mon Sep 17 00:00:00 2001 From: Ben Pearce Date: Thu, 21 Nov 2024 17:19:09 +1000 Subject: [PATCH] working operations for deployment freezes --- pkg/client/octopusdeploy.go | 1 - .../deploymentfreezes_service.go | 21 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/client/octopusdeploy.go b/pkg/client/octopusdeploy.go index b38f4557..ddb4e23a 100644 --- a/pkg/client/octopusdeploy.go +++ b/pkg/client/octopusdeploy.go @@ -432,7 +432,6 @@ func NewClientWithCredentials(httpClient *http.Client, apiURL *url.URL, apiCrede Configuration: configuration.NewConfigurationService(base, configurationPath, versionControlClearCachePath), DashboardConfigurations: dashboard.NewDashboardConfigurationService(base, dashboardConfigurationPath), Dashboards: dashboard.NewDashboardService(base, dashboardPath, dashboardDynamicPath), - DeploymentFreezes: deploymentfreezes.NewDeploymentFreezeService(), DeploymentProcesses: deployments.NewDeploymentProcessService(base, deploymentProcessesPath), Deployments: deployments.NewDeploymentService(base, deploymentsPath), DynamicExtensions: extensions.NewDynamicExtensionService(base, dynamicExtensionsPath, dynamicExtensionsFeaturesMetadataPath, dynamicExtensionsFeaturesValuesPath, dynamicExtensionsScriptsPath), diff --git a/pkg/deploymentfreezes/deploymentfreezes_service.go b/pkg/deploymentfreezes/deploymentfreezes_service.go index d70c24c1..ff826b5c 100644 --- a/pkg/deploymentfreezes/deploymentfreezes_service.go +++ b/pkg/deploymentfreezes/deploymentfreezes_service.go @@ -26,6 +26,23 @@ func Get(client newclient.Client, deploymentFreezesQuery *DeploymentFreezeQuery) return res, nil } +func GetById(client newclient.Client, id string) (*DeploymentFreeze, error) { + path, err := client.URITemplateCache().Expand(template, map[string]any{ + "id": id, + }) + if err != nil { + return nil, err + } + + res, err := newclient.Get[DeploymentFreeze](client.HttpSession(), path) + if err != nil { + return &DeploymentFreeze{}, err + } + + return res, nil + +} + func GetAll(client newclient.Client) ([]*DeploymentFreeze, error) { path, err := client.URITemplateCache().Expand(template, &DeploymentFreezeQuery{Skip: 0, Take: math.MaxInt32}) if err != nil { @@ -64,7 +81,7 @@ func Update(client newclient.Client, deploymentFreeze *DeploymentFreeze) (*Deplo return nil, internal.CreateRequiredParameterIsEmptyOrNilError("deploymentFreeze") } - path, err := client.URITemplateCache().Expand(template, deploymentFreeze) + path, err := client.URITemplateCache().Expand(template, map[string]any{"id": deploymentFreeze.ID}) if err != nil { return nil, err } @@ -81,7 +98,7 @@ func Delete(client newclient.Client, deploymentFreeze *DeploymentFreeze) error { return internal.CreateRequiredParameterIsEmptyOrNilError("deploymentFreeze") } - path, err := client.URITemplateCache().Expand(template, deploymentFreeze) + path, err := client.URITemplateCache().Expand(template, map[string]any{"id": deploymentFreeze.ID}) if err != nil { return err }