Files
dynamix-golang-sdk/pkg/cloudbroker/apiaccess/desc_update.go
T

44 lines
1.1 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package apiaccess
import (
"context"
2026-09-28 15:34:18 +04:00
"encoding/json"
2025-09-23 14:34:24 +03:00
"net/http"
2025-12-08 16:30:08 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
2025-09-23 14:34:24 +03:00
)
// DescUpdateRequest struct for updating apiaccess group description.
type DescUpdateRequest struct {
// APIAccess group ID.
// Required: true
2025-09-26 19:17:30 +03:00
APIAccessID uint64 `url:"apiaccess_id" json:"apiaccess_id" validate:"required"`
2025-09-23 14:34:24 +03:00
// New description to set for the apiaccess group.
// Required: true
Description string `url:"desc" json:"desc" validate:"required"`
}
// DescUpdate sets a new text description of the apiaccess group.
2026-09-28 15:34:18 +04:00
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (*ItemAPIAccess, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2026-09-28 15:34:18 +04:00
return nil, validators.ValidationErrors(validators.GetErrors(err))
2025-09-23 14:34:24 +03:00
}
url := "/cloudbroker/apiaccess/descUpdate"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
2026-09-28 15:34:18 +04:00
return nil, err
2025-09-23 14:34:24 +03:00
}
2026-09-28 15:34:18 +04:00
info := ItemAPIAccess{}
err = json.Unmarshal(res, &info)
2025-09-23 14:34:24 +03:00
if err != nil {
2026-09-28 15:34:18 +04:00
return nil, err
2025-09-23 14:34:24 +03:00
}
2026-09-28 15:34:18 +04:00
return &info, nil
2025-09-23 14:34:24 +03:00
}