Files
decort-golang-sdk/pkg/cloudbroker/apiaccess/desc_update.go

45 lines
1.1 KiB
Go
Raw Normal View History

2023-06-23 15:13:22 +03:00
package apiaccess
import (
"context"
2026-09-18 16:49:20 +03:00
"encoding/json"
2023-06-23 15:13:22 +03:00
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
2023-10-25 17:37:18 +03:00
// DescUpdateRequest struct for updating apiaccess group description.
2023-06-23 15:13:22 +03:00
type DescUpdateRequest struct {
// APIAccess group ID.
// Required: true
2025-04-09 11:21:07 +03:00
APIAccessID uint64 `url:"apiaccess_id" json:"apiaccess_id" validate:"required"`
2023-06-23 15:13:22 +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-18 16:49:20 +03:00
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (*ItemAPIAccess, error) {
2023-06-23 15:13:22 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2026-09-18 16:49:20 +03:00
return nil, validators.ValidationErrors(validators.GetErrors(err))
2023-06-23 15:13:22 +03:00
}
url := "/cloudbroker/apiaccess/descUpdate"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
2026-09-18 16:49:20 +03:00
return nil, err
2023-06-23 15:13:22 +03:00
}
2026-09-18 16:49:20 +03:00
info := ItemAPIAccess{}
err = json.Unmarshal(res, &info)
2023-06-23 15:13:22 +03:00
if err != nil {
2026-09-18 16:49:20 +03:00
return nil, err
2023-06-23 15:13:22 +03:00
}
2026-09-18 16:49:20 +03:00
return &info, nil
2023-06-23 15:13:22 +03:00
}