From d643c35e5abe38e9a3f2de9294e5615f0ce0c4c6 Mon Sep 17 00:00:00 2001 From: jbristowe Date: Sat, 27 Mar 2021 11:09:28 +1000 Subject: [PATCH] feat: serverStatus and serverStatusService.Get() Implemented serverStatus type and added Get API to serverStatusSevice. Includes simple test. Refs #47 --- integration/server_status_service_test.go | 16 ++++++++++++++++ octopusdeploy/constants_services.go | 2 +- octopusdeploy/server_status.go | 13 +++++++++++++ octopusdeploy/server_status_service.go | 19 ++++++++++++++++++- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 integration/server_status_service_test.go create mode 100644 octopusdeploy/server_status.go diff --git a/integration/server_status_service_test.go b/integration/server_status_service_test.go new file mode 100644 index 00000000..094e1226 --- /dev/null +++ b/integration/server_status_service_test.go @@ -0,0 +1,16 @@ +package integration + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestServerStatusServiceGet(t *testing.T) { + client := getOctopusClient() + require.NotNil(t, client) + + serverStatus, err := client.ServerStatus.Get() + require.NoError(t, err) + require.NotNil(t, serverStatus) +} diff --git a/octopusdeploy/constants_services.go b/octopusdeploy/constants_services.go index 38b44e85..cc5126ef 100644 --- a/octopusdeploy/constants_services.go +++ b/octopusdeploy/constants_services.go @@ -61,7 +61,7 @@ const ( ServiceSchedulerService string = "SchedulerService" ServiceScopedUserRoleService string = "ScopedUserRoleService" ServiceServerConfigurationService string = "ServerConfigurationService" - ServiceServerStatuService string = "ServerStatuService" + ServiceServerStatusService string = "ServerStatusService" ServiceSpaceService string = "SpaceService" ServiceSMTPConfigurationService string = "SMTPConfigurationService" ServiceSubscriptionService string = "SubscriptionService" diff --git a/octopusdeploy/server_status.go b/octopusdeploy/server_status.go new file mode 100644 index 00000000..87df40ca --- /dev/null +++ b/octopusdeploy/server_status.go @@ -0,0 +1,13 @@ +package octopusdeploy + +type ServerStatus struct { + IsDatabaseEncrypted bool `json:"IsDatabaseEncrypted,omitempty"` + IsMajorMinorUpgrade bool `json:"IsMajorMinorUpgrade,omitempty"` + IsInMaintenanceMode bool `json:"IsInMaintenanceMode,omitempty"` + IsUpgradeAvailable bool `json:"IsUpgradeAvailable,omitempty"` + MaintenanceExpires string `json:"MaintenanceExpires,omitempty"` + MaximumAvailableVersion string `json:"MaximumAvailableVersion,omitempty"` + MaximumAvailableVersionCoveredByLicense string `json:"MaximumAvailableVersionCoveredByLicense,omitempty"` + + resource +} diff --git a/octopusdeploy/server_status_service.go b/octopusdeploy/server_status_service.go index c402f3fa..b3ebe934 100644 --- a/octopusdeploy/server_status_service.go +++ b/octopusdeploy/server_status_service.go @@ -15,6 +15,23 @@ func newServerStatusService(sling *sling.Sling, uriTemplate string, extensionSta extensionStatsPath: extensionStatsPath, healthStatusPath: healthStatusPath, timezonesPath: timezonesPath, - service: newService(ServiceServerStatuService, sling, uriTemplate), + service: newService(ServiceServerStatusService, sling, uriTemplate), } } + +// Get returns the status of the server. +func (s serverStatusService) Get() (*ServerStatus, error) { + path, err := getPath(s) + if err != nil { + return nil, err + } + + response, err := apiGet(s.getClient(), new(ServerStatus), path) + if err != nil { + return nil, err + } + + return response.(*ServerStatus), nil +} + +var _ IService = &serverStatusService{}