Files
decort-golang-sdk/pkg/cloudbroker/vins/search.go

46 lines
1.0 KiB
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package vins
import (
"context"
"encoding/json"
"net/http"
)
2023-10-25 17:37:18 +03:00
// SearchRequest struct to search VINSes
2022-12-22 17:56:47 +03:00
type SearchRequest struct {
// ID of the account to search for the ViNSes
// 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
// ID of the resource group to limit search to the specified RG level only
// Required: false
2023-03-01 19:05:53 +03:00
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
2022-12-22 17:56:47 +03:00
// Name of the ViNS 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 VINSes having one of the statuses are not listed for
// Required: false
2023-03-01 19:05:53 +03:00
ShowAll bool `url:"show_all,omitempty" json:"show_all,omitempty"`
2022-12-22 17:56:47 +03:00
}
2023-10-25 17:37:18 +03:00
// Search searches VINSes
2023-07-13 15:28:07 +03:00
func (v VINS) Search(ctx context.Context, req SearchRequest) (SearchVINS, error) {
2022-12-22 17:56:47 +03:00
url := "/cloudbroker/vins/search"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
2023-07-13 15:28:07 +03:00
list := SearchVINS{}
2022-12-22 17:56:47 +03:00
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
}