46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
|
|
package zone
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// ListCPUAlignmentProfileRequest struct to list CPU alignment profiles
|
||
|
|
type ListCPUAlignmentProfileRequest struct {
|
||
|
|
// ID of zone
|
||
|
|
// Required: false
|
||
|
|
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// ListCPUAlignmentProfile gets list of CPU alignment profiles
|
||
|
|
func (e Zone) ListCPUAlignmentProfile(ctx context.Context, req ListCPUAlignmentProfileRequest) (*ListCPUAlignmentProfiles, error) {
|
||
|
|
res, err := e.ListCPUAlignmentProfileRaw(ctx, req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
list := ListCPUAlignmentProfiles{}
|
||
|
|
|
||
|
|
err = json.Unmarshal(res, &list)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &list, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// ListCPUAlignmentProfileRaw gets list of CPU alignment profiles as an array of bytes
|
||
|
|
func (e Zone) ListCPUAlignmentProfileRaw(ctx context.Context, req ListCPUAlignmentProfileRequest) ([]byte, error) {
|
||
|
|
if err := validators.ValidateRequest(req); err != nil {
|
||
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/cloudbroker/zone/list_cpu_alignment_profile"
|
||
|
|
|
||
|
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||
|
|
return res, err
|
||
|
|
}
|