Skip to content

Commit

Permalink
fix: fix get all deployment freeze call (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 authored Nov 27, 2024
1 parent 2d95b7e commit b692e57
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 4 additions & 1 deletion pkg/deploymentfreezes/deploymentfreeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
"time"
)

type DeploymentFreezes resources.Resources[DeploymentFreeze]
type DeploymentFreezes struct {
DeploymentFreezes []DeploymentFreeze `json:"DeploymentFreezes"`
Count int `json:"Count"`
}

type DeploymentFreeze struct {
Name string `json:"Name" validate:"required"`
Expand Down
12 changes: 6 additions & 6 deletions pkg/deploymentfreezes/deploymentfreeze_query.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package deploymentfreezes

type DeploymentFreezeQuery struct {
IncludeComplete bool `uri:"includeComplete,omitempty"`
ProjectIds []string `uri:"projectIds,omitempty"`
EnvironmentIds []string `uri:"environmentIds,omitempty"`
IDs []string `uri:"ids,omitempty"`
Skip int `uri:"skip,omitempty"`
Take int `uri:"take,omitempty"`
IncludeComplete bool `uri:"includeComplete,omitempty" url:"includeComplete,omitempty"`
ProjectIds []string `uri:"projectIds,omitempty" url:"projectIds,omitempty"`
EnvironmentIds []string `uri:"environmentIds,omitempty" url:"environmentIds,omitempty"`
IDs []string `uri:"ids,omitempty" url:"ids,omitempty"`
Skip int `uri:"skip" url:"skip"`
Take int `uri:"take,omitempty" url:"take,omitempty"`
}
10 changes: 4 additions & 6 deletions pkg/deploymentfreezes/deploymentfreezes_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,18 @@ func GetById(client newclient.Client, id string) (*DeploymentFreeze, error) {

}

func GetAll(client newclient.Client) ([]*DeploymentFreeze, error) {
func GetAll(client newclient.Client) (*DeploymentFreezes, error) {
path, err := client.URITemplateCache().Expand(template, &DeploymentFreezeQuery{Skip: 0, Take: math.MaxInt32})
if err != nil {
return nil, err
}

res, err := newclient.Get[DeploymentFreezes](client.HttpSession(), path)

freezes := make([]*DeploymentFreeze, 0)
for _, freeze := range res.Items {
freezes = append(freezes, &freeze)
if err != nil {
return &DeploymentFreezes{}, err
}

return freezes, nil
return res, nil
}

func Add(client newclient.Client, deploymentFreeze *DeploymentFreeze) (*DeploymentFreeze, error) {
Expand Down

0 comments on commit b692e57

Please sign in to comment.