Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pkg/environments/v2/environments/environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package environments

import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions"
)

type Environment struct {
ID string `json:"Id"`
Name string `json:"Name"`
SpaceID string `json:"SpaceId"`
Slug string `json:"Slug"`
Description string `json:"Description,omitempty"`
Type string `json:"Type"`
SortOrder int `json:"SortOrder"`
UseGuidedFailure bool `json:"UseGuidedFailure"`
EnvironmentTags []string `json:"EnvironmentTags,omitempty"`

// Fields for Static environments
AllowDynamicInfrastructure *bool `json:"AllowDynamicInfrastructure,omitempty"`
ExtensionSettings []extensions.ExtensionSettings `json:"ExtensionSettings,omitempty"`

// Fields for Ephemeral environments
ParentEnvironmentId string `json:"ParentEnvironmentId,omitempty"`
}
9 changes: 9 additions & 0 deletions pkg/environments/v2/environments/environment_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package environments

type EnvironmentQuery struct {
Ids []string `uri:"ids,omitempty" url:"ids,omitempty"`
PartialName string `uri:"partialName,omitempty" url:"partialName,omitempty"`
Skip int `uri:"skip" url:"skip"`
Take int `uri:"take" url:"take"`
Type []string `uri:"type,omitempty" url:"type,omitempty"`
}
14 changes: 14 additions & 0 deletions pkg/environments/v2/environments/environment_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package environments

import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
)

// Get returns a collection of environments based on the criteria defined by
// its input query parameter. If an error occurs, an empty collection is
// returned along with the associated error.
func Get(client newclient.Client, spaceID string, environmentsQuery EnvironmentQuery) (*resources.Resources[*Environment], error) {
return newclient.GetByQuery[Environment](client, v2.Template, spaceID, environmentsQuery)
}
13 changes: 13 additions & 0 deletions pkg/environments/v2/ephemeralenvironments/ephemeral_environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ephemeralenvironments

type EphemeralEnvironment struct {
ID string `json:"Id"`
Name string `json:"Name"`
SpaceID string `json:"SpaceId"`
Slug string `json:"Slug"`
Description string `json:"Description"`
Type string `json:"Type"`
SortOrder int `json:"SortOrder"`
UseGuidedFailure bool `json:"UseGuidedFailure"`
ParentEnvironmentId string `json:"ParentEnvironmentId"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ephemeralenvironments

import (
"math"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/environments"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
)

func GetAllEphemeralEnvironments(client newclient.Client, spaceID string) (*resources.Resources[*environments.Environment], error) {
query := &environments.EnvironmentQuery{
Skip: 0,
Take: math.MaxInt32,
Type: []string{"Ephemeral"},
}

return newclient.GetByQuery[environments.Environment](client, v2.Template, spaceID, query)
}
3 changes: 3 additions & 0 deletions pkg/environments/v2/route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package v2

const Template = "/api/{spaceId}/environments/v2{/id}{?name,skip,ids,take,partialName,type}"
Loading