Files
decort-golang-sdk/pkg/cloudapi/disks/search.go

49 lines
1.1 KiB
Go
Raw Normal View History

2022-10-03 16:56:47 +03:00
package disks
import (
"context"
"encoding/json"
"net/http"
)
2023-10-25 17:37:18 +03:00
// SearchRequest struct for search
2022-10-03 16:56:47 +03:00
type SearchRequest struct {
2022-12-22 17:56:47 +03:00
// ID of the account to search for the Disk
// Required: false
2023-03-01 19:05:53 +03:00
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
2022-12-22 17:56:47 +03:00
// Name of the Disk to search for
// Required: false
2023-03-01 19:05:53 +03:00
Name string `url:"name,omitempty" json:"name,omitempty"`
2022-12-22 17:56:47 +03:00
// If false, then disks having one of the statuses are not listed
// Required: false
2023-03-01 19:05:53 +03:00
ShowAll bool `url:"show_all,omitempty" json:"show_all,omitempty"`
2024-04-16 14:26:06 +03:00
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
2022-10-03 16:56:47 +03:00
}
2023-10-25 17:37:18 +03:00
// Search searches disks
2023-06-30 11:21:47 +03:00
func (d Disks) Search(ctx context.Context, req SearchRequest) (ListSearchDisks, error) {
2022-10-03 16:56:47 +03:00
url := "/cloudapi/disks/search"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
2023-06-30 11:21:47 +03:00
list := ListSearchDisks{}
2022-10-03 16:56:47 +03:00
2022-12-22 17:56:47 +03:00
err = json.Unmarshal(res, &list)
2022-10-03 16:56:47 +03:00
if err != nil {
return nil, err
}
2022-12-22 17:56:47 +03:00
return list, nil
2022-10-03 16:56:47 +03:00
}