github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/iec/v1/vpcs/results.go (about) 1 package vpcs 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/openstack/iec/v1/common" 6 "github.com/huaweicloud/golangsdk/pagination" 7 ) 8 9 type commonResult struct { 10 golangsdk.Result 11 } 12 13 type CreateResult struct { 14 commonResult 15 } 16 17 func (r CreateResult) Extract() (*common.VPC, error) { 18 var entity common.VPC 19 err := r.ExtractIntoStructPtr(&entity, "vpc") 20 return &entity, err 21 } 22 23 type DeleteResult struct { 24 golangsdk.ErrResult 25 } 26 27 type GetResult struct { 28 commonResult 29 } 30 31 func (r GetResult) Extract() (*common.VPC, error) { 32 var entity common.VPC 33 err := r.ExtractIntoStructPtr(&entity, "vpc") 34 return &entity, err 35 } 36 37 type VpcPage struct { 38 pagination.LinkedPageBase 39 } 40 41 func ExtractVpcs(r pagination.Page) ([]common.VPC, error) { 42 var s struct { 43 Vpcs []common.VPC `json:"vpcs"` 44 } 45 err := r.(VpcPage).ExtractInto(&s) 46 return s.Vpcs, err 47 } 48 49 // IsEmpty checks whether a NetworkPage struct is empty. 50 func (r VpcPage) IsEmpty() (bool, error) { 51 s, err := ExtractVpcs(r) 52 return len(s) == 0, err 53 } 54 55 type UpdateResult struct { 56 commonResult 57 } 58 59 func (r UpdateResult) Extract() (*common.VPC, error) { 60 var entity common.VPC 61 err := r.ExtractIntoStructPtr(&entity, "vpc") 62 return &entity, err 63 } 64 65 type UpdateStatusResult struct { 66 commonResult 67 } 68 69 // Vpcs vpc列表对象 70 type Vpcs struct { 71 Vpcs []common.VPC `json:"vpcs"` 72 Count int `json:"count"` 73 } 74 75 type ListResult struct { 76 commonResult 77 } 78 79 func (r ListResult) Extract() (*Vpcs, error) { 80 var entity Vpcs 81 err := r.ExtractIntoStructPtr(&entity, "") 82 return &entity, err 83 }