github.com/qiniu/go-sdk/v7@v7.27.0/storagev2/apis/get_bucket_quota/api.go (about)

     1  // THIS FILE IS GENERATED BY api-generator, DO NOT EDIT DIRECTLY!
     2  
     3  // 获取用户存储空间配额限制
     4  package get_bucket_quota
     5  
     6  import (
     7  	"encoding/json"
     8  
     9  	credentials "github.com/qiniu/go-sdk/v7/storagev2/credentials"
    10  )
    11  
    12  // 调用 API 所用的请求
    13  type Request struct {
    14  	Bucket      string                          // 指定存储空间
    15  	Credentials credentials.CredentialsProvider // 鉴权参数,用于生成鉴权凭证,如果为空,则使用 HTTPClientOptions 中的 CredentialsProvider
    16  }
    17  
    18  // 获取 API 所用的响应
    19  type Response struct {
    20  	Size  int64 // 空间存储量配额
    21  	Count int64 // 空间文件数配额
    22  }
    23  
    24  // Bucket 配额信息
    25  type (
    26  	BucketQuota  = Response
    27  	jsonResponse struct {
    28  		Size  int64 `json:"size,omitempty"`  // 空间存储量配额
    29  		Count int64 `json:"count,omitempty"` // 空间文件数配额
    30  	}
    31  )
    32  
    33  func (j *Response) MarshalJSON() ([]byte, error) {
    34  	if err := j.validate(); err != nil {
    35  		return nil, err
    36  	}
    37  	return json.Marshal(&jsonResponse{Size: j.Size, Count: j.Count})
    38  }
    39  
    40  func (j *Response) UnmarshalJSON(data []byte) error {
    41  	var nj jsonResponse
    42  	if err := json.Unmarshal(data, &nj); err != nil {
    43  		return err
    44  	}
    45  	j.Size = nj.Size
    46  	j.Count = nj.Count
    47  	return nil
    48  }
    49  
    50  func (j *Response) validate() error {
    51  	return nil
    52  }