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

46 lines
1.1 KiB
Go
Raw Normal View History

2022-10-03 16:56:47 +03:00
package vins
import (
"context"
"encoding/json"
"net/http"
)
2023-10-25 17:37:18 +03:00
// SearchRequest struct for search VINSes
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 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-10-03 16:56:47 +03:00
}
2023-10-25 17:37:18 +03:00
// Search searches VINSes
2023-06-30 11:21:47 +03:00
func (v VINS) Search(ctx context.Context, req SearchRequest) (SearchListVINS, error) {
2022-10-03 16:56:47 +03:00
url := "/cloudapi/vins/search"
2022-12-22 17:56:47 +03:00
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
2022-10-03 16:56:47 +03:00
if err != nil {
return nil, err
}
2023-06-30 11:21:47 +03:00
list := SearchListVINS{}
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
}