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