This commit is contained in:
aafetisov committed 2026-11-20 17:14:41 +03:00
1 parent ee7a8ebb55
commit 3b0a73c424
17 files changed
+218 -20

No files matched your search

+2 -2
View File
@@ -8,8 +8,8 @@ type Audit struct {
}
// Builder for audit endpoint
func New(client interfaces.Caller) *Audit {
func New(client interfaces.Caller) *Audit{
return &Audit{
client: client,
}
}
}
+36 -2
View File
@@ -1,8 +1,10 @@
package audit
import "encoding/json"
// Main info about audit
type RecordAudit struct {
// Arguments
// Arguments as JSON text
Arguments string `json:"args"`
// Call
@@ -14,7 +16,7 @@ type RecordAudit struct {
// Correlation ID
CorrelationID string `json:"correlation_id"`
// Kwargs
// Keyword arguments as JSON text
Kwargs string `json:"kwargs"`
// RemoteAddr
@@ -43,6 +45,38 @@ type RecordAudit struct {
// Public Session ID
PublicSessionID string `json:"public_session_id"`
// TTL
TTL string `json:"_ttl"`
}
// UnmarshalJSON accepts both JSON-encoded strings and structured arguments.
func (r *RecordAudit) UnmarshalJSON(data []byte) error {
type recordAudit RecordAudit
response := struct {
*recordAudit
Arguments auditJSONText `json:"args"`
Kwargs auditJSONText `json:"kwargs"`
}{
recordAudit: (*recordAudit)(r),
Arguments: auditJSONText{value: &r.Arguments, opening: '['},
Kwargs: auditJSONText{value: &r.Kwargs, opening: '{'},
}
return json.Unmarshal(data, &response)
}
type auditJSONText struct {
value *string
opening byte
}
func (f *auditJSONText) UnmarshalJSON(data []byte) error {
if len(data) > 0 && data[0] == f.opening {
*f.value = string(data)
return nil
}
return json.Unmarshal(data, f.value)
}
// Main info about audit
+18
View File
@@ -399,6 +399,24 @@ type IOTune struct {
// WriteIOPSSecMax
WriteIOPSSecMax uint64 `json:"write_iops_sec_max"`
// ReadBytesSecMaxLength
ReadBytesSecMaxLength uint64 `json:"read_bytes_sec_max_length"`
// ReadIOPSSecMaxLength
ReadIOPSSecMaxLength uint64 `json:"read_iops_sec_max_length"`
// TotalBytesSecMaxLength
TotalBytesSecMaxLength uint64 `json:"total_bytes_sec_max_length"`
// TotalIOPSSecMaxLength
TotalIOPSSecMaxLength uint64 `json:"total_iops_sec_max_length"`
// WriteBytesSecMaxLength
WriteBytesSecMaxLength uint64 `json:"write_bytes_sec_max_length"`
// WriteIOPSSecMaxLength
WriteIOPSSecMaxLength uint64 `json:"write_iops_sec_max_length"`
}
// Detailed information about disk
@@ -0,0 +1,39 @@
package disks
import (
"context"
"net/http"
"strconv"
"strings"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
)
type ReplicationCancelSyncRequest struct {
// Disk ID
// Required: true
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
}
// ReplicationCancelSync cancels ongoing disk replication synchronization
func (d Disks) ReplicationCancelSync(ctx context.Context, req ReplicationCancelSyncRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/disks/replication_cancel_sync"
res, err := d.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(strings.TrimSpace(string(res)))
if err != nil {
return false, err
}
return result, nil
}
+6
View File
@@ -129,6 +129,9 @@ type RecordZone struct {
// Timeout
TaskDiskTimeout string `json:"task_disk_timeout"`
// TTL
TTL string `json:"ttl"`
}
// A zone item from a list
@@ -219,4 +222,7 @@ type ItemZone struct {
// Timeout
TaskDiskTimeout string `json:"task_disk_timeout"`
// TTL
TTL string `json:"ttl"`
}