github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/er/v3/routetables/results.go (about) 1 package routetables 2 3 import ( 4 "github.com/chnsz/golangsdk/openstack/common/tags" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 // createResp is the structure that represents the API response of the 'Create' method, which contains route table 9 // details and the request information. 10 type createResp struct { 11 // The response detail of the route table. 12 RouteTable RouteTable `json:"route_table"` 13 // The request ID. 14 RequestId string `json:"request_id"` 15 } 16 17 // RouteTable is the structure that represents the details of the route table for ER service. 18 type RouteTable struct { 19 // The ID of the route table. 20 ID string `json:"id"` 21 // The name of the route table. 22 // The value can contain 1 to 64 characters, only english and chinese letters, digits, underscore (_), hyphens (-) 23 // and dots (.) are allowed. 24 Name string `json:"name"` 25 // The description of the route table. 26 // The value contain a maximum of 255 characters, and the angle brackets (< and >) are not allowed. 27 Description string `json:"description"` 28 // The configuration of the BGP route selection. 29 BgpOptions BgpOptions `json:"bgp_options"` 30 // The key/value pairs to associate with the route table. 31 Tags []tags.ResourceTag `json:"tags"` 32 // Whether this route table is the default association route table. 33 IsDefaultAssociation bool `json:"is_default_association"` 34 // Whether this route table is the default propagation route table. 35 IsDefaultPropagation bool `json:"is_default_propagation"` 36 // The current status of the route table. 37 Status string `json:"state"` 38 // The creation time of the route table. 39 CreatedAt string `json:"created_at"` 40 // The last update time of the route table. 41 UpdatedAt string `json:"updated_at"` 42 } 43 44 // getResp is the structure that represents the API response of the 'Get' method, which contains route table details and 45 // the request information. 46 type getResp struct { 47 // The response detail of the route table. 48 RouteTable RouteTable `json:"route_table"` 49 // The request ID. 50 RequestId string `json:"request_id"` 51 } 52 53 // listResp is the structure that represents the API response of the 'List' method, which contains route table list, 54 // page details and the request information. 55 type listResp struct { 56 // The list of the route tables. 57 RouteTables []RouteTable `json:"route_tables"` 58 // The request ID. 59 RequestId string `json:"request_id"` 60 // The page information. 61 PageInfo pageInfo `json:"page_info"` 62 } 63 64 // pageInfo is the structure that represents the page information. 65 type pageInfo struct { 66 // The next marker information. 67 NextMarker string `json:"next_marker"` 68 // The number of the route table in current page. 69 CurrentCount int `json:"current_count"` 70 } 71 72 // RouteTablePage represents the response pages of the List method. 73 type RouteTablePage struct { 74 pagination.MarkerPageBase 75 } 76 77 // IsEmpty returns true if a ListResult no route table. 78 func (r RouteTablePage) IsEmpty() (bool, error) { 79 resp, err := extractRouteTables(r) 80 return len(resp) == 0, err 81 } 82 83 // LastMarker returns the last marker index in a ListResult. 84 func (r RouteTablePage) LastMarker() (string, error) { 85 resp, err := extractPageInfo(r) 86 if err != nil { 87 return "", err 88 } 89 if resp.NextMarker != "" { 90 return "", nil 91 } 92 return resp.NextMarker, nil 93 } 94 95 // extractPageInfo is a method which to extract the response of the page information. 96 func extractPageInfo(r pagination.Page) (*pageInfo, error) { 97 var s listResp 98 err := r.(RouteTablePage).Result.ExtractInto(&s) 99 return &s.PageInfo, err 100 } 101 102 // extractRouteTables is a method which to extract the response to a route table list. 103 func extractRouteTables(r pagination.Page) ([]RouteTable, error) { 104 var s listResp 105 err := r.(RouteTablePage).Result.ExtractInto(&s) 106 return s.RouteTables, err 107 } 108 109 // updateResp is the structure that represents the API response of the 'Update' method, which contains route table 110 // details and the request information. 111 type updateResp struct { 112 // The response detail of the route table. 113 RouteTable RouteTable `json:"route_table"` 114 // The request ID. 115 RequestId string `json:"request_id"` 116 }