-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for maintenance windows (#28)
* feat: add support for maintenance windows * chore(deps): update module github.com/go-resty/resty/v2 to v2.15.2 # Conflicts: # go.sum * chore: go mod tidy * chore(deps): update module github.com/go-resty/resty/v2 to v2.15.2 # Conflicts: # go.sum * feat(cluster): add maintenanceScheduleIdentity --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
- Loading branch information
1 parent
875ab6a
commit 17cc873
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,4 +115,6 @@ vendor | |
.idea | ||
|
||
# Golang | ||
.netrc | ||
.netrc | ||
|
||
go-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package acloudapi | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
func (c *clientImpl) GetMaintenanceSchedules(ctx context.Context, org string) ([]MaintenanceSchedule, error) { | ||
var result []MaintenanceSchedule | ||
response, err := c.R(). | ||
SetContext(ctx). | ||
SetResult(&result). | ||
Get(fmt.Sprintf("/api/v1/organisations/%s/maintenance-schedule", org)) | ||
if err := c.CheckResponse(response, err); err != nil { | ||
return nil, err | ||
} | ||
return result, nil | ||
} | ||
|
||
func (c *clientImpl) GetMaintenanceSchedule(ctx context.Context, org, maintenanceScheduleID string) (*MaintenanceSchedule, error) { | ||
maintenanceSchedule := MaintenanceSchedule{} | ||
response, err := c.R(). | ||
SetContext(ctx). | ||
SetResult(&maintenanceSchedule). | ||
Get(fmt.Sprintf("/api/v1/organisations/%s/maintenance-schedule/%s", org, maintenanceScheduleID)) | ||
if err := c.CheckResponse(response, err); err != nil { | ||
return nil, err | ||
} | ||
return &maintenanceSchedule, nil | ||
} | ||
|
||
type CreateMaintenanceSchedule struct { | ||
Name string `json:"name"` | ||
Windows []MaintenanceWindow `json:"windows"` | ||
} | ||
|
||
func (c *clientImpl) CreateMaintenanceSchedule(ctx context.Context, org string, createMaintenanceSchedule CreateMaintenanceSchedule) (*MaintenanceSchedule, error) { | ||
maintenanceSchedule := MaintenanceSchedule{} | ||
response, err := c.R(). | ||
SetContext(ctx). | ||
SetResult(&maintenanceSchedule). | ||
SetBody(&createMaintenanceSchedule). | ||
Post(fmt.Sprintf("/api/v1/organisations/%s/maintenance-schedule", org)) | ||
|
||
if err := c.CheckResponse(response, err); err != nil { | ||
return nil, err | ||
} | ||
return &maintenanceSchedule, nil | ||
} | ||
|
||
func (c *clientImpl) DeleteMaintenanceSchedule(ctx context.Context, org, maintenanceScheduleID string) error { | ||
response, err := c.R(). | ||
SetContext(ctx). | ||
Delete(fmt.Sprintf("/api/v1/organisations/%s/maintenance-schedule/%s", org, maintenanceScheduleID)) | ||
if err := c.CheckResponse(response, err); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
type UpdateMaintenanceSchedule struct { | ||
Name string `json:"name"` | ||
Windows []MaintenanceWindow `json:"windows"` | ||
} | ||
|
||
func (c *clientImpl) UpdateMaintenanceSchedule(ctx context.Context, org, maintenanceScheduleID string, updateMaintenanceSchedule UpdateMaintenanceSchedule) (*MaintenanceSchedule, error) { | ||
maintenanceSchedule := MaintenanceSchedule{} | ||
response, err := c.R(). | ||
SetContext(ctx). | ||
SetResult(&maintenanceSchedule). | ||
SetBody(&updateMaintenanceSchedule). | ||
Patch(fmt.Sprintf("/api/v1/organisations/%s/maintenance-schedule/%s", org, maintenanceScheduleID)) | ||
if err := c.CheckResponse(response, err); err != nil { | ||
return nil, err | ||
} | ||
return &maintenanceSchedule, nil | ||
} |