github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/elb/v3/rules/results.go (about) 1 package rules 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 type ForwardingRule struct { 9 ID string `json:"id"` 10 Type RuleType `json:"type"` 11 CompareType CompareType `json:"compare_type"` 12 Value string `json:"value"` 13 ProjectID string `json:"project_id"` 14 Conditions []Condition `json:"conditions"` 15 } 16 17 type commonResult struct { 18 golangsdk.Result 19 } 20 21 func (r commonResult) Extract() (*ForwardingRule, error) { 22 var rule ForwardingRule 23 err := r.ExtractIntoStructPtr(&rule, "rule") 24 if err != nil { 25 return nil, err 26 } 27 return &rule, nil 28 } 29 30 type CreateResult struct { 31 commonResult 32 } 33 34 type GetResult struct { 35 commonResult 36 } 37 38 type UpdateResult struct { 39 commonResult 40 } 41 42 type DeleteResult struct { 43 golangsdk.ErrResult 44 } 45 46 type RulePage struct { 47 pagination.PageWithInfo 48 } 49 50 func (p RulePage) IsEmpty() (bool, error) { 51 rules, err := ExtractRules(p) 52 return len(rules) == 0, err 53 } 54 55 func ExtractRules(p pagination.Page) ([]ForwardingRule, error) { 56 var policies []ForwardingRule 57 err := p.(RulePage).ExtractIntoSlicePtr(&policies, "rules") 58 if err != nil { 59 return nil, err 60 } 61 return policies, nil 62 }