@@ -6,6 +6,7 @@ package modify_group
66import (
77 "encoding/json"
88 credentials "github.com/qiniu/go-sdk/v7/storagev2/credentials"
9+ errors "github.com/qiniu/go-sdk/v7/storagev2/errors"
910)
1011
1112// 调用 API 所用的请求
@@ -43,4 +44,98 @@ func (j *Request) validate() error {
4344}
4445
4546// 获取 API 所用的响应
46- type Response struct {}
47+ type Response struct {
48+ Data ModifyGroupData // 用户分组信息
49+ }
50+
51+ // 用户分组信息
52+ type Data struct {
53+ Id string // 记录 ID
54+ RootUid int64 // 根用户 uid
55+ Alias string // 用户分组别名
56+ Description string // 用户分组描述
57+ Enabled bool // 用户分组是否启用
58+ CreatedAt string // 用户分组创建时间
59+ UpdatedAt string // 用户分组上次更新时间
60+ }
61+
62+ // 返回的用户分组信息
63+ type ModifyGroupData = Data
64+ type jsonData struct {
65+ Id string `json:"id"` // 记录 ID
66+ RootUid int64 `json:"root_uid"` // 根用户 uid
67+ Alias string `json:"alias"` // 用户分组别名
68+ Description string `json:"description"` // 用户分组描述
69+ Enabled bool `json:"enabled"` // 用户分组是否启用
70+ CreatedAt string `json:"created_at"` // 用户分组创建时间
71+ UpdatedAt string `json:"updated_at"` // 用户分组上次更新时间
72+ }
73+
74+ func (j * Data ) MarshalJSON () ([]byte , error ) {
75+ if err := j .validate (); err != nil {
76+ return nil , err
77+ }
78+ return json .Marshal (& jsonData {Id : j .Id , RootUid : j .RootUid , Alias : j .Alias , Description : j .Description , Enabled : j .Enabled , CreatedAt : j .CreatedAt , UpdatedAt : j .UpdatedAt })
79+ }
80+ func (j * Data ) UnmarshalJSON (data []byte ) error {
81+ var nj jsonData
82+ if err := json .Unmarshal (data , & nj ); err != nil {
83+ return err
84+ }
85+ j .Id = nj .Id
86+ j .RootUid = nj .RootUid
87+ j .Alias = nj .Alias
88+ j .Description = nj .Description
89+ j .Enabled = nj .Enabled
90+ j .CreatedAt = nj .CreatedAt
91+ j .UpdatedAt = nj .UpdatedAt
92+ return nil
93+ }
94+ func (j * Data ) validate () error {
95+ if j .Id == "" {
96+ return errors.MissingRequiredFieldError {Name : "Id" }
97+ }
98+ if j .RootUid == 0 {
99+ return errors.MissingRequiredFieldError {Name : "RootUid" }
100+ }
101+ if j .Alias == "" {
102+ return errors.MissingRequiredFieldError {Name : "Alias" }
103+ }
104+ if j .Description == "" {
105+ return errors.MissingRequiredFieldError {Name : "Description" }
106+ }
107+ if j .CreatedAt == "" {
108+ return errors.MissingRequiredFieldError {Name : "CreatedAt" }
109+ }
110+ if j .UpdatedAt == "" {
111+ return errors.MissingRequiredFieldError {Name : "UpdatedAt" }
112+ }
113+ return nil
114+ }
115+
116+ // 返回的用户分组响应
117+ type ModifyGroupResp = Response
118+ type jsonResponse struct {
119+ Data ModifyGroupData `json:"data"` // 用户分组信息
120+ }
121+
122+ func (j * Response ) MarshalJSON () ([]byte , error ) {
123+ if err := j .validate (); err != nil {
124+ return nil , err
125+ }
126+ return json .Marshal (& jsonResponse {Data : j .Data })
127+ }
128+ func (j * Response ) UnmarshalJSON (data []byte ) error {
129+ var nj jsonResponse
130+ if err := json .Unmarshal (data , & nj ); err != nil {
131+ return err
132+ }
133+ j .Data = nj .Data
134+ return nil
135+ }
136+ func (j * Response ) validate () error {
137+ if err := j .Data .validate (); err != nil {
138+ return err
139+ }
140+ return nil
141+ }
0 commit comments