github.com/qiniu/go-sdk/v7@v7.27.0/storagev2/apis/query_bucket_v4/api.go (about) 1 // THIS FILE IS GENERATED BY api-generator, DO NOT EDIT DIRECTLY! 2 3 // 查询存储空间服务域名 4 package query_bucket_v4 5 6 import ( 7 "encoding/json" 8 9 errors "github.com/qiniu/go-sdk/v7/storagev2/errors" 10 ) 11 12 // 调用 API 所用的请求 13 type Request struct { 14 Bucket string // 存储空间名称 15 AccessKey string // Access Key 16 } 17 18 // 获取 API 所用的响应 19 type Response struct { 20 Hosts BucketQueryHosts // 存储空间服务域名 21 } 22 23 // 加速上传域名列表 24 type AcceleratedUpDomains = []string 25 26 // 主上传域名列表 27 type PreferedUpDomains = []string 28 29 // 备选上传域名列表 30 type AlternativeUpDomains = []string 31 32 // 上传域名 33 type UpDomains struct { 34 AcceleratedUpDomains AcceleratedUpDomains // 加速上传域名列表 35 PreferedUpDomains PreferedUpDomains // 主上传域名列表 36 AlternativeUpDomains AlternativeUpDomains // 备选上传域名列表 37 } 38 type jsonUpDomains struct { 39 AcceleratedUpDomains AcceleratedUpDomains `json:"acc_domains"` // 加速上传域名列表 40 PreferedUpDomains PreferedUpDomains `json:"domains"` // 主上传域名列表 41 AlternativeUpDomains AlternativeUpDomains `json:"old"` // 备选上传域名列表 42 } 43 44 func (j *UpDomains) MarshalJSON() ([]byte, error) { 45 if err := j.validate(); err != nil { 46 return nil, err 47 } 48 return json.Marshal(&jsonUpDomains{AcceleratedUpDomains: j.AcceleratedUpDomains, PreferedUpDomains: j.PreferedUpDomains, AlternativeUpDomains: j.AlternativeUpDomains}) 49 } 50 51 func (j *UpDomains) UnmarshalJSON(data []byte) error { 52 var nj jsonUpDomains 53 if err := json.Unmarshal(data, &nj); err != nil { 54 return err 55 } 56 j.AcceleratedUpDomains = nj.AcceleratedUpDomains 57 j.PreferedUpDomains = nj.PreferedUpDomains 58 j.AlternativeUpDomains = nj.AlternativeUpDomains 59 return nil 60 } 61 62 func (j *UpDomains) validate() error { 63 if len(j.AcceleratedUpDomains) == 0 { 64 return errors.MissingRequiredFieldError{Name: "AcceleratedUpDomains"} 65 } 66 if len(j.PreferedUpDomains) == 0 { 67 return errors.MissingRequiredFieldError{Name: "PreferedUpDomains"} 68 } 69 if len(j.AlternativeUpDomains) == 0 { 70 return errors.MissingRequiredFieldError{Name: "AlternativeUpDomains"} 71 } 72 return nil 73 } 74 75 // 主下载域名列表 76 type PreferedIoDomains = []string 77 78 // 下载域名 79 type IoDomains struct { 80 PreferedIoDomains PreferedIoDomains // 主下载域名列表 81 } 82 type jsonIoDomains struct { 83 PreferedIoDomains PreferedIoDomains `json:"domains"` // 主下载域名列表 84 } 85 86 func (j *IoDomains) MarshalJSON() ([]byte, error) { 87 if err := j.validate(); err != nil { 88 return nil, err 89 } 90 return json.Marshal(&jsonIoDomains{PreferedIoDomains: j.PreferedIoDomains}) 91 } 92 93 func (j *IoDomains) UnmarshalJSON(data []byte) error { 94 var nj jsonIoDomains 95 if err := json.Unmarshal(data, &nj); err != nil { 96 return err 97 } 98 j.PreferedIoDomains = nj.PreferedIoDomains 99 return nil 100 } 101 102 func (j *IoDomains) validate() error { 103 if len(j.PreferedIoDomains) == 0 { 104 return errors.MissingRequiredFieldError{Name: "PreferedIoDomains"} 105 } 106 return nil 107 } 108 109 // 主源站下载域名列表 110 type PreferedIoSrcDomains = []string 111 112 // 源站下载域名 113 type IoSrcDomains struct { 114 PreferedIoSrcDomains PreferedIoSrcDomains // 主源站下载域名列表 115 } 116 type jsonIoSrcDomains struct { 117 PreferedIoSrcDomains PreferedIoSrcDomains `json:"domains"` // 主源站下载域名列表 118 } 119 120 func (j *IoSrcDomains) MarshalJSON() ([]byte, error) { 121 if err := j.validate(); err != nil { 122 return nil, err 123 } 124 return json.Marshal(&jsonIoSrcDomains{PreferedIoSrcDomains: j.PreferedIoSrcDomains}) 125 } 126 127 func (j *IoSrcDomains) UnmarshalJSON(data []byte) error { 128 var nj jsonIoSrcDomains 129 if err := json.Unmarshal(data, &nj); err != nil { 130 return err 131 } 132 j.PreferedIoSrcDomains = nj.PreferedIoSrcDomains 133 return nil 134 } 135 136 func (j *IoSrcDomains) validate() error { 137 if len(j.PreferedIoSrcDomains) == 0 { 138 return errors.MissingRequiredFieldError{Name: "PreferedIoSrcDomains"} 139 } 140 return nil 141 } 142 143 // 主对象管理域名列表 144 type PreferedRsDomains = []string 145 146 // 对象管理域名 147 type RsDomains struct { 148 PreferedRsDomains PreferedRsDomains // 主对象管理域名列表 149 } 150 type jsonRsDomains struct { 151 PreferedRsDomains PreferedRsDomains `json:"domains"` // 主对象管理域名列表 152 } 153 154 func (j *RsDomains) MarshalJSON() ([]byte, error) { 155 if err := j.validate(); err != nil { 156 return nil, err 157 } 158 return json.Marshal(&jsonRsDomains{PreferedRsDomains: j.PreferedRsDomains}) 159 } 160 161 func (j *RsDomains) UnmarshalJSON(data []byte) error { 162 var nj jsonRsDomains 163 if err := json.Unmarshal(data, &nj); err != nil { 164 return err 165 } 166 j.PreferedRsDomains = nj.PreferedRsDomains 167 return nil 168 } 169 170 func (j *RsDomains) validate() error { 171 if len(j.PreferedRsDomains) == 0 { 172 return errors.MissingRequiredFieldError{Name: "PreferedRsDomains"} 173 } 174 return nil 175 } 176 177 // 主对象列举域名列表 178 type PreferedRsfDomains = []string 179 180 // 对象列举域名 181 type RsfDomains struct { 182 PreferedRsfDomains PreferedRsfDomains // 主对象列举域名列表 183 } 184 type jsonRsfDomains struct { 185 PreferedRsfDomains PreferedRsfDomains `json:"domains"` // 主对象列举域名列表 186 } 187 188 func (j *RsfDomains) MarshalJSON() ([]byte, error) { 189 if err := j.validate(); err != nil { 190 return nil, err 191 } 192 return json.Marshal(&jsonRsfDomains{PreferedRsfDomains: j.PreferedRsfDomains}) 193 } 194 195 func (j *RsfDomains) UnmarshalJSON(data []byte) error { 196 var nj jsonRsfDomains 197 if err := json.Unmarshal(data, &nj); err != nil { 198 return err 199 } 200 j.PreferedRsfDomains = nj.PreferedRsfDomains 201 return nil 202 } 203 204 func (j *RsfDomains) validate() error { 205 if len(j.PreferedRsfDomains) == 0 { 206 return errors.MissingRequiredFieldError{Name: "PreferedRsfDomains"} 207 } 208 return nil 209 } 210 211 // 主 API 域名列表 212 type PreferedApiDomains = []string 213 214 // API 域名 215 type ApiDomains struct { 216 PreferedApiDomains PreferedApiDomains // 主 API 域名列表 217 } 218 type jsonApiDomains struct { 219 PreferedApiDomains PreferedApiDomains `json:"domains"` // 主 API 域名列表 220 } 221 222 func (j *ApiDomains) MarshalJSON() ([]byte, error) { 223 if err := j.validate(); err != nil { 224 return nil, err 225 } 226 return json.Marshal(&jsonApiDomains{PreferedApiDomains: j.PreferedApiDomains}) 227 } 228 229 func (j *ApiDomains) UnmarshalJSON(data []byte) error { 230 var nj jsonApiDomains 231 if err := json.Unmarshal(data, &nj); err != nil { 232 return err 233 } 234 j.PreferedApiDomains = nj.PreferedApiDomains 235 return nil 236 } 237 238 func (j *ApiDomains) validate() error { 239 if len(j.PreferedApiDomains) == 0 { 240 return errors.MissingRequiredFieldError{Name: "PreferedApiDomains"} 241 } 242 return nil 243 } 244 245 // 主 S3 域名列表 246 type PreferedS3Domains = []string 247 248 // S3 域名 249 type S3Domains struct { 250 RegionAlias string // S3 Region 251 PreferedApiDomains PreferedS3Domains // 主 S3 域名列表 252 } 253 type jsonS3Domains struct { 254 RegionAlias string `json:"region_alias"` // S3 Region 255 PreferedApiDomains PreferedS3Domains `json:"domains"` // 主 S3 域名列表 256 } 257 258 func (j *S3Domains) MarshalJSON() ([]byte, error) { 259 if err := j.validate(); err != nil { 260 return nil, err 261 } 262 return json.Marshal(&jsonS3Domains{RegionAlias: j.RegionAlias, PreferedApiDomains: j.PreferedApiDomains}) 263 } 264 265 func (j *S3Domains) UnmarshalJSON(data []byte) error { 266 var nj jsonS3Domains 267 if err := json.Unmarshal(data, &nj); err != nil { 268 return err 269 } 270 j.RegionAlias = nj.RegionAlias 271 j.PreferedApiDomains = nj.PreferedApiDomains 272 return nil 273 } 274 275 func (j *S3Domains) validate() error { 276 if j.RegionAlias == "" { 277 return errors.MissingRequiredFieldError{Name: "RegionAlias"} 278 } 279 if len(j.PreferedApiDomains) == 0 { 280 return errors.MissingRequiredFieldError{Name: "PreferedApiDomains"} 281 } 282 return nil 283 } 284 285 // 存储空间服务域名 286 type BucketQueryHost struct { 287 RegionId string // 区域 ID 288 TimeToLive int64 // 查询结果的 TTL 289 UpDomains UpDomains // 上传域名 290 IoDomains IoDomains // 下载域名 291 IoSrcDomains IoSrcDomains // 源站下载域名 292 RsDomains RsDomains // 对象管理域名 293 RsfDomains RsfDomains // 对象列举域名 294 ApiDomains ApiDomains // API 域名 295 S3Domains S3Domains // S3 域名 296 } 297 type jsonBucketQueryHost struct { 298 RegionId string `json:"region"` // 区域 ID 299 TimeToLive int64 `json:"ttl"` // 查询结果的 TTL 300 UpDomains UpDomains `json:"up"` // 上传域名 301 IoDomains IoDomains `json:"io"` // 下载域名 302 IoSrcDomains IoSrcDomains `json:"io_src,omitempty"` // 源站下载域名 303 RsDomains RsDomains `json:"rs"` // 对象管理域名 304 RsfDomains RsfDomains `json:"rsf"` // 对象列举域名 305 ApiDomains ApiDomains `json:"api"` // API 域名 306 S3Domains S3Domains `json:"s3"` // S3 域名 307 } 308 309 func (j *BucketQueryHost) MarshalJSON() ([]byte, error) { 310 if err := j.validate(); err != nil { 311 return nil, err 312 } 313 return json.Marshal(&jsonBucketQueryHost{RegionId: j.RegionId, TimeToLive: j.TimeToLive, UpDomains: j.UpDomains, IoDomains: j.IoDomains, IoSrcDomains: j.IoSrcDomains, RsDomains: j.RsDomains, RsfDomains: j.RsfDomains, ApiDomains: j.ApiDomains, S3Domains: j.S3Domains}) 314 } 315 316 func (j *BucketQueryHost) UnmarshalJSON(data []byte) error { 317 var nj jsonBucketQueryHost 318 if err := json.Unmarshal(data, &nj); err != nil { 319 return err 320 } 321 j.RegionId = nj.RegionId 322 j.TimeToLive = nj.TimeToLive 323 j.UpDomains = nj.UpDomains 324 j.IoDomains = nj.IoDomains 325 j.IoSrcDomains = nj.IoSrcDomains 326 j.RsDomains = nj.RsDomains 327 j.RsfDomains = nj.RsfDomains 328 j.ApiDomains = nj.ApiDomains 329 j.S3Domains = nj.S3Domains 330 return nil 331 } 332 333 func (j *BucketQueryHost) validate() error { 334 if j.RegionId == "" { 335 return errors.MissingRequiredFieldError{Name: "RegionId"} 336 } 337 if j.TimeToLive == 0 { 338 return errors.MissingRequiredFieldError{Name: "TimeToLive"} 339 } 340 if err := j.UpDomains.validate(); err != nil { 341 return err 342 } 343 if err := j.IoDomains.validate(); err != nil { 344 return err 345 } 346 if err := j.RsDomains.validate(); err != nil { 347 return err 348 } 349 if err := j.RsfDomains.validate(); err != nil { 350 return err 351 } 352 if err := j.ApiDomains.validate(); err != nil { 353 return err 354 } 355 if err := j.S3Domains.validate(); err != nil { 356 return err 357 } 358 return nil 359 } 360 361 // 存储空间服务域名 362 type BucketQueryHosts = []BucketQueryHost 363 364 // 存储空间服务域名查询结果 365 type ( 366 BucketQueryResult = Response 367 jsonResponse struct { 368 Hosts BucketQueryHosts `json:"hosts"` // 存储空间服务域名 369 } 370 ) 371 372 func (j *Response) MarshalJSON() ([]byte, error) { 373 if err := j.validate(); err != nil { 374 return nil, err 375 } 376 return json.Marshal(&jsonResponse{Hosts: j.Hosts}) 377 } 378 379 func (j *Response) UnmarshalJSON(data []byte) error { 380 var nj jsonResponse 381 if err := json.Unmarshal(data, &nj); err != nil { 382 return err 383 } 384 j.Hosts = nj.Hosts 385 return nil 386 } 387 388 func (j *Response) validate() error { 389 if len(j.Hosts) == 0 { 390 return errors.MissingRequiredFieldError{Name: "Hosts"} 391 } 392 for _, value := range j.Hosts { 393 if err := value.validate(); err != nil { 394 return err 395 } 396 } 397 return nil 398 }