diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10f9548f1c..5ede9e3005 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: - uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 with: - args: --timeout 3m --verbose + args: --timeout 5m --verbose version: latest only-new-issues: true diff --git a/internal/backups/list/list_test.go b/internal/backups/list/list_test.go index 70285ec6b1..d07aae744e 100644 --- a/internal/backups/list/list_test.go +++ b/internal/backups/list/list_test.go @@ -58,10 +58,12 @@ func TestListBackup(t *testing.T) { JSON(api.V1BackupsResponse{ Region: "ap-southeast-1", Backups: []struct { + Id int `json:"id"` InsertedAt string `json:"inserted_at"` IsPhysicalBackup bool `json:"is_physical_backup"` Status api.V1BackupsResponseBackupsStatus `json:"status"` }{{ + Id: 1, InsertedAt: "2026-02-08 16:44:07", IsPhysicalBackup: true, Status: api.V1BackupsResponseBackupsStatusCOMPLETED, diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index ed33fb4585..79e8c6510a 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -431,6 +431,11 @@ type ClientInterface interface { // V1ListAllBackups request V1ListAllBackups(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1RestorePhysicalBackupWithBody request with any body + V1RestorePhysicalBackupWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1RestorePhysicalBackup(ctx context.Context, ref string, body V1RestorePhysicalBackupJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1RestorePitrBackupWithBody request with any body V1RestorePitrBackupWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2152,6 +2157,30 @@ func (c *Client) V1ListAllBackups(ctx context.Context, ref string, reqEditors .. return c.Client.Do(req) } +func (c *Client) V1RestorePhysicalBackupWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RestorePhysicalBackupRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1RestorePhysicalBackup(ctx context.Context, ref string, body V1RestorePhysicalBackupJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RestorePhysicalBackupRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1RestorePitrBackupWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1RestorePitrBackupRequestWithBody(c.Server, ref, contentType, body) if err != nil { @@ -7713,6 +7742,53 @@ func NewV1ListAllBackupsRequest(server string, ref string) (*http.Request, error return req, nil } +// NewV1RestorePhysicalBackupRequest calls the generic V1RestorePhysicalBackup builder with application/json body +func NewV1RestorePhysicalBackupRequest(server string, ref string, body V1RestorePhysicalBackupJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1RestorePhysicalBackupRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewV1RestorePhysicalBackupRequestWithBody generates requests for V1RestorePhysicalBackup with any type of body +func NewV1RestorePhysicalBackupRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/database/backups/restore", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1RestorePitrBackupRequest calls the generic V1RestorePitrBackup builder with application/json body func NewV1RestorePitrBackupRequest(server string, ref string, body V1RestorePitrBackupJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -11279,6 +11355,11 @@ type ClientWithResponsesInterface interface { // V1ListAllBackupsWithResponse request V1ListAllBackupsWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1ListAllBackupsResponse, error) + // V1RestorePhysicalBackupWithBodyWithResponse request with any body + V1RestorePhysicalBackupWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestorePhysicalBackupResponse, error) + + V1RestorePhysicalBackupWithResponse(ctx context.Context, ref string, body V1RestorePhysicalBackupJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RestorePhysicalBackupResponse, error) + // V1RestorePitrBackupWithBodyWithResponse request with any body V1RestorePitrBackupWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestorePitrBackupResponse, error) @@ -13608,6 +13689,27 @@ func (r V1ListAllBackupsResponse) StatusCode() int { return 0 } +type V1RestorePhysicalBackupResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1RestorePhysicalBackupResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1RestorePhysicalBackupResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1RestorePitrBackupResponse struct { Body []byte HTTPResponse *http.Response @@ -16112,6 +16214,23 @@ func (c *ClientWithResponses) V1ListAllBackupsWithResponse(ctx context.Context, return ParseV1ListAllBackupsResponse(rsp) } +// V1RestorePhysicalBackupWithBodyWithResponse request with arbitrary body returning *V1RestorePhysicalBackupResponse +func (c *ClientWithResponses) V1RestorePhysicalBackupWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestorePhysicalBackupResponse, error) { + rsp, err := c.V1RestorePhysicalBackupWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RestorePhysicalBackupResponse(rsp) +} + +func (c *ClientWithResponses) V1RestorePhysicalBackupWithResponse(ctx context.Context, ref string, body V1RestorePhysicalBackupJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RestorePhysicalBackupResponse, error) { + rsp, err := c.V1RestorePhysicalBackup(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RestorePhysicalBackupResponse(rsp) +} + // V1RestorePitrBackupWithBodyWithResponse request with arbitrary body returning *V1RestorePitrBackupResponse func (c *ClientWithResponses) V1RestorePitrBackupWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestorePitrBackupResponse, error) { rsp, err := c.V1RestorePitrBackupWithBody(ctx, ref, contentType, body, reqEditors...) @@ -19240,6 +19359,22 @@ func ParseV1ListAllBackupsResponse(rsp *http.Response) (*V1ListAllBackupsRespons return response, nil } +// ParseV1RestorePhysicalBackupResponse parses an HTTP response from a V1RestorePhysicalBackupWithResponse call +func ParseV1RestorePhysicalBackupResponse(rsp *http.Response) (*V1RestorePhysicalBackupResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1RestorePhysicalBackupResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseV1RestorePitrBackupResponse parses an HTTP response from a V1RestorePitrBackupWithResponse call func ParseV1RestorePitrBackupResponse(rsp *http.Response) (*V1RestorePitrBackupResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 89211a3a2e..91b2727ae9 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -4398,6 +4398,7 @@ type UpgradeDatabaseBodyReleaseChannel string // V1BackupsResponse defines model for V1BackupsResponse. type V1BackupsResponse struct { Backups []struct { + Id int `json:"id"` InsertedAt string `json:"inserted_at"` IsPhysicalBackup bool `json:"is_physical_backup"` Status V1BackupsResponseBackupsStatus `json:"status"` @@ -4822,6 +4823,11 @@ type V1ReadOnlyQueryBody struct { Query string `json:"query"` } +// V1RestoreBackupBody defines model for V1RestoreBackupBody. +type V1RestoreBackupBody struct { + Id int `json:"id"` +} + // V1RestorePitrBody defines model for V1RestorePitrBody. type V1RestorePitrBody struct { RecoveryTimeTargetUnix int64 `json:"recovery_time_target_unix"` @@ -5336,6 +5342,9 @@ type V1UpdateStorageConfigJSONRequestBody = UpdateStorageConfigBody // V1UpdateHostnameConfigJSONRequestBody defines body for V1UpdateHostnameConfig for application/json ContentType. type V1UpdateHostnameConfigJSONRequestBody = UpdateCustomHostnameBody +// V1RestorePhysicalBackupJSONRequestBody defines body for V1RestorePhysicalBackup for application/json ContentType. +type V1RestorePhysicalBackupJSONRequestBody = V1RestoreBackupBody + // V1RestorePitrBackupJSONRequestBody defines body for V1RestorePitrBackup for application/json ContentType. type V1RestorePitrBackupJSONRequestBody = V1RestorePitrBody