github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/waf/v1/certificates/results.go (about) 1 package certificates 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type Certificate struct { 9 // Certificate ID 10 Id string `json:"id"` 11 // Certificate Name 12 Name string `json:"name"` 13 // the time when the certificate expires in unix timestamp 14 ExpireTime int `json:"expireTime"` 15 // the time when the certificate is uploaded in unix timestamp 16 TimeStamp int `json:"timestamp"` 17 } 18 19 type commonResult struct { 20 golangsdk.Result 21 } 22 23 // Extract is a function that accepts a result and extracts a certificate. 24 func (r commonResult) Extract() (*Certificate, error) { 25 var response Certificate 26 err := r.ExtractInto(&response) 27 return &response, err 28 } 29 30 // CreateResult represents the result of a create operation. Call its Extract 31 // method to interpret it as a Certificate. 32 type CreateResult struct { 33 commonResult 34 } 35 36 // UpdateResult represents the result of a update operation. Call its Extract 37 // method to interpret it as a Certificate. 38 type UpdateResult struct { 39 commonResult 40 } 41 42 // GetResult represents the result of a get operation. Call its Extract 43 // method to interpret it as a Certificate. 44 type GetResult struct { 45 commonResult 46 } 47 48 // CertificateDetail reprersents the result of list certificates. 49 type CertificateDetail struct { 50 // Certificate ID 51 Id string `json:"id"` 52 // Certificate Name 53 Name string `json:"name"` 54 // Certificate Id 55 CertificateId string `json:"certificateid"` 56 // Certificate name 57 CertificateName string `json:"certificatename"` 58 // the key of the certificate 59 Timestamp int64 `json:"timestamp"` 60 // the privite key of the certificate 61 BindHosts []BindHost `json:"bind_host,omitempty"` 62 // the time when the certificate expires in unix timestamp 63 ExpireTime int `json:"expire_time"` 64 // the expire status of the certificate 65 // 0-not expired, 1-expired, 2-expired soon 66 ExpStatus int `json:"exp_status"` 67 } 68 69 type BindHost struct { 70 Id string `json:"id"` 71 Hostname string `json:"hostname"` 72 WafType string `json:"waf_type"` 73 Mode string `json:"mode"` 74 } 75 76 type CertificatePage struct { 77 pagination.SinglePageBase 78 } 79 80 func ExtractCertificates(r pagination.Page) ([]CertificateDetail, error) { 81 var s struct { 82 Certificates []CertificateDetail `json:"items"` 83 } 84 err := (r.(CertificatePage)).ExtractInto(&s) 85 return s.Certificates, err 86 } 87 88 // DeleteResult represents the result of a delete operation. Call its ExtractErr 89 // method to determine if the request succeeded or failed. 90 type DeleteResult struct { 91 golangsdk.ErrResult 92 }