Files
decort-golang-sdk/pkg/cloudbroker/stpolicy/delete_pool.go

52 lines
1.2 KiB
Go
Raw Normal View History

2025-09-11 15:56:44 +03:00
package stpolicy
2025-08-29 12:51:25 +03:00
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2025-09-11 15:56:44 +03:00
type DeletePoolRequest struct {
2025-08-29 12:51:25 +03:00
// ID of storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Storage endpoint provider ID to delete
// Required: true
2025-09-11 15:56:44 +03:00
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
2025-08-29 12:51:25 +03:00
// Pool to delete
// Required: true
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
}
2025-09-11 15:56:44 +03:00
func (sp StPolicy) DeletePool(ctx context.Context, req DeletePoolRequest) (*InfoStoragePolicyWithID, error) {
2025-08-29 12:51:25 +03:00
res, err := sp.DeletePoolRaw(ctx, req)
if err != nil {
return nil, err
}
info := InfoStoragePolicyWithID{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
2025-09-11 15:56:44 +03:00
func (sp StPolicy) DeletePoolRaw(ctx context.Context, req DeletePoolRequest) ([]byte, error) {
2025-08-29 12:51:25 +03:00
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/delete_pool"
res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}