-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for new tenant variables endpoints with environment scoping #301
Changes from 12 commits
6113794
cd949c9
7133799
9597fe5
1dcbdbc
66d6f0a
8162c4a
34c3ab9
b5f4773
cadae9f
7a2aa9b
74cbb07
ef3d742
25e7da8
02b37b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package configuration | ||
|
||
type FeatureToggleConfigurationQuery struct { | ||
Name string `uri:"Name,omitempty" url:"Name,omitempty"` | ||
} | ||
|
||
type FeatureToggleConfigurationResponse struct { | ||
FeatureToggles []ConfiguredFeatureToggle `json:"FeatureToggles"` | ||
} | ||
|
||
type ConfiguredFeatureToggle struct { | ||
Name string `json:"Name"` | ||
IsEnabled bool `json:"IsEnabled"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package configuration | ||
|
||
import ( | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" | ||
) | ||
|
||
type FeatureToggleConfigurationService struct{} | ||
|
||
const template = "/api/configuration/feature-toggles{?Name}" | ||
|
||
func Get(client newclient.Client, query *FeatureToggleConfigurationQuery) (*FeatureToggleConfigurationResponse, error) { | ||
return newclient.GetByQueryWithoutSpace[FeatureToggleConfigurationResponse](client, template, query) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,3 +314,26 @@ func DeleteByID(client newclient.Client, spaceID string, ID string) error { | |
func GetAll(client newclient.Client, spaceID string) ([]*Tenant, error) { | ||
return newclient.GetAll[Tenant](client, template, spaceID) | ||
} | ||
|
||
const tenantProjectVariableTemplate = "/api/{spaceId}/tenants/{id}/projectvariables" | ||
const tenantCommonVariableTemplate = "/api/{spaceId}/tenants/{id}/commonvariables" | ||
|
||
// GetProjectVariables returns all tenant project variables. If an error occurs, it returns nil. | ||
func GetProjectVariables(client newclient.Client, spaceID string, tenantID string) (*variables.TenantProjectVariablesResource, error) { | ||
return newclient.GetByID[variables.TenantProjectVariablesResource](client, tenantProjectVariableTemplate, spaceID, tenantID) | ||
} | ||
|
||
// GetCommonVariables returns all tenant common variables. If an error occurs, it returns nil. | ||
func GetCommonVariables(client newclient.Client, spaceID string, tenantID string) (*variables.TenantCommonVariablesResource, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✔️ |
||
return newclient.GetByID[variables.TenantCommonVariablesResource](client, tenantCommonVariableTemplate, spaceID, tenantID) | ||
} | ||
|
||
// UpdateProjectVariables modifies tenant project variables based on the ones provided as input. | ||
func UpdateProjectVariables(client newclient.Client, spaceID string, tenantID string, projectVariables *variables.ModifyTenantProjectVariablesCommand) (*variables.TenantProjectVariablesResource, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✔️ |
||
return newclient.Update[variables.TenantProjectVariablesResource](client, tenantProjectVariableTemplate, spaceID, tenantID, projectVariables) | ||
} | ||
|
||
// UpdateCommonVariables modifies tenant common variables based on the ones provided as input. | ||
func UpdateCommonVariables(client newclient.Client, spaceID string, tenantID string, commonVariables *variables.ModifyTenantCommonVariablesCommand) (*variables.TenantCommonVariablesResource, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✔️ |
||
return newclient.Update[variables.TenantCommonVariablesResource](client, tenantCommonVariableTemplate, spaceID, tenantID, commonVariables) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package variables | ||
|
||
import ( | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" | ||
) | ||
|
||
type TenantCommonVariablesResource struct { | ||
TenantID string `json:"TenantId,omitempty"` | ||
CommonVariables []TenantCommonVariable `json:"CommonVariables,omitempty"` | ||
|
||
resources.Resource | ||
} | ||
|
||
type TenantCommonVariable struct { | ||
Id string `json:"Id,omitempty"` | ||
LibraryVariableSetId string `json:"LibraryVariableSetId"` | ||
LibraryVariableSetName string `json:"LibraryVariableSetName,omitempty"` | ||
TemplateID string `json:"TemplateId"` | ||
Template actiontemplates.ActionTemplateParameter `json:"Template"` | ||
Value core.PropertyValue `json:"Value"` | ||
Scope TenantVariableScope `json:"Scope"` | ||
|
||
resources.Resource | ||
} | ||
|
||
type ModifyTenantCommonVariablesCommand struct { | ||
Variables []TenantCommonVariableCommand `json:"Variables"` | ||
} | ||
|
||
type TenantCommonVariableCommand struct { | ||
Id string `json:"Id,omitempty"` | ||
LibraryVariableSetId string `json:"LibraryVariableSetId"` | ||
TemplateID string `json:"TemplateId"` | ||
Value core.PropertyValue `json:"Value"` | ||
Scope TenantVariableScope `json:"Scope"` | ||
|
||
resources.Resource | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package variables | ||
|
||
import ( | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" | ||
) | ||
|
||
type TenantProjectVariablesResource struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think our naming needs a bit of work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Names updated based on the team discussion |
||
TenantID string `json:"TenantId,omitempty"` | ||
ProjectVariables []TenantProjectVariable `json:"ProjectVariables,omitempty"` | ||
|
||
resources.Resource | ||
} | ||
|
||
type TenantProjectVariable struct { | ||
Id string `json:"Id,omitempty"` | ||
ProjectID string `json:"ProjectId"` | ||
ProjectName string `json:"ProjectName,omitempty"` | ||
TemplateID string `json:"TemplateId"` | ||
Template actiontemplates.ActionTemplateParameter `json:"Template"` | ||
Value core.PropertyValue `json:"Value"` | ||
Scope TenantVariableScope `json:"Scope"` | ||
Links map[string]string `json:"Links,omitempty"` | ||
|
||
resources.Resource | ||
} | ||
|
||
type ModifyTenantProjectVariablesCommand struct { | ||
Variables []TenantProjectVariableCommand `json:"Variables"` | ||
} | ||
|
||
type TenantProjectVariableCommand struct { | ||
Id string `json:"Id,omitempty"` | ||
ProjectID string `json:"ProjectId"` | ||
TemplateID string `json:"TemplateId"` | ||
Value core.PropertyValue `json:"Value"` | ||
Scope TenantVariableScope `json:"Scope"` | ||
|
||
resources.Resource | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package variables | ||
|
||
import "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" | ||
|
||
type TenantVariableScope struct { | ||
EnvironmentIds []string `json:"EnvironmentIds"` | ||
|
||
resources.Resource | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️