github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/lbaas_v2/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 } 19 20 // CertificatePage is the page returned by a pager when traversing over a 21 // collection of certificates. 22 type CertificatePage struct { 23 pagination.SinglePageBase 24 } 25 26 // ExtractCertificates accepts a Page struct, specifically a CertificatePage struct, 27 // and extracts the elements into a slice of Certificate structs. In other words, 28 // a generic collection is mapped into a relevant slice. 29 func ExtractCertificates(r pagination.Page) ([]Certificate, error) { 30 var s struct { 31 Certificates []Certificate `json:"certificates"` 32 } 33 err := (r.(CertificatePage)).ExtractInto(&s) 34 return s.Certificates, err 35 } 36 37 type commonResult struct { 38 golangsdk.Result 39 } 40 41 func (r commonResult) Extract() (*Certificate, error) { 42 s := &Certificate{} 43 return s, r.ExtractInto(s) 44 } 45 46 type CreateResult struct { 47 commonResult 48 } 49 50 // GetResult represents the result of a get operation. 51 type GetResult struct { 52 commonResult 53 } 54 55 type UpdateResult struct { 56 commonResult 57 } 58 59 // DeleteResult represents the result of a delete operation. 60 type DeleteResult struct { 61 golangsdk.ErrResult 62 }