github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/elb/v3/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 ID string `json:"id"` 10 Name string `json:"name"` 11 Description string `json:"description"` 12 Type string `json:"type"` 13 Domain string `json:"domain"` 14 PrivateKey string `json:"private_key"` 15 Certificate string `json:"certificate"` 16 CreateTime string `json:"create_time"` 17 UpdateTime string `json:"update_time"` 18 ExpireTime string `json:"expire_time"` 19 } 20 21 // CertificatePage is the page returned by a pager when traversing over a 22 // collection of certificates. 23 type CertificatePage struct { 24 pagination.SinglePageBase 25 } 26 27 // ExtractCertificates accepts a Page struct, specifically a CertificatePage struct, 28 // and extracts the elements into a slice of Certificate structs. In other words, 29 // a generic collection is mapped into a relevant slice. 30 func ExtractCertificates(r pagination.Page) ([]Certificate, error) { 31 var s struct { 32 Certificates []Certificate `json:"certificates"` 33 } 34 err := (r.(CertificatePage)).ExtractInto(&s) 35 return s.Certificates, err 36 } 37 38 type commonResult struct { 39 golangsdk.Result 40 } 41 42 func (r commonResult) Extract() (*Certificate, error) { 43 var s struct { 44 Certificate *Certificate `json:"certificate"` 45 } 46 err := r.ExtractInto(&s) 47 return s.Certificate, err 48 } 49 50 type CreateResult struct { 51 commonResult 52 } 53 54 // GetResult represents the result of a get operation. 55 type GetResult struct { 56 commonResult 57 } 58 59 type UpdateResult struct { 60 commonResult 61 } 62 63 // DeleteResult represents the result of a delete operation. 64 type DeleteResult struct { 65 golangsdk.ErrResult 66 }