github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/vpc/v1/bandwidths/results.go (about) 1 package bandwidths 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 type commonResult struct { 9 golangsdk.Result 10 } 11 12 type BandWidth struct { 13 // Specifies the bandwidth name. The value is a string of 1 to 64 14 // characters that can contain letters, digits, underscores (_), and hyphens (-). 15 Name string `json:"name"` 16 17 // Specifies the bandwidth size. The value ranges from 1 Mbit/s to 18 // 300 Mbit/s. 19 Size int `json:"size"` 20 21 // Specifies the bandwidth ID, which uniquely identifies the 22 // bandwidth. 23 ID string `json:"id"` 24 25 // Specifies whether the bandwidth is shared or exclusive. The 26 // value can be PER or WHOLE. 27 ShareType string `json:"share_type"` 28 29 // Specifies the elastic IP address of the bandwidth. The 30 // bandwidth, whose type is set to WHOLE, supports up to 20 elastic IP addresses. The 31 // bandwidth, whose type is set to PER, supports only one elastic IP address. 32 PublicipInfo []PublicIpinfo `json:"publicip_info"` 33 34 // Specifies the tenant ID of the user. 35 TenantId string `json:"tenant_id"` 36 37 // Specifies the bandwidth type. 38 BandwidthType string `json:"bandwidth_type"` 39 40 // Specifies the charging mode (by traffic or by bandwidth). 41 ChargeMode string `json:"charge_mode"` 42 43 // Specifies the billing information. 44 BillingInfo string `json:"billing_info"` 45 46 // Enterprise project id 47 EnterpriseProjectID string `json:"enterprise_project_id"` 48 49 // Specifies the status of bandwidth 50 Status string `json:"status"` 51 } 52 53 type PublicIpinfo struct { 54 // Specifies the tenant ID of the user. 55 PublicipId string `json:"publicip_id"` 56 57 // Specifies the elastic IP address. 58 PublicipAddress string `json:"publicip_address"` 59 60 // Specifies the elastic IP v6 address. 61 Publicipv6Address string `json:"publicipv6_address"` 62 63 // Specifies the elastic IP version. 64 IPVersion int `json:"ip_version"` 65 66 // Specifies the elastic IP address type. The value can be 67 // 5_telcom, 5_union, or 5_bgp. 68 PublicipType string `json:"publicip_type"` 69 } 70 71 type GetResult struct { 72 commonResult 73 } 74 75 func (r GetResult) Extract() (*BandWidth, error) { 76 var entity BandWidth 77 err := r.ExtractIntoStructPtr(&entity, "bandwidth") 78 return &entity, err 79 } 80 81 type ListResult struct { 82 commonResult 83 } 84 85 func (r ListResult) Extract() (*[]BandWidth, error) { 86 var list []BandWidth 87 err := r.ExtractIntoSlicePtr(&list, "bandwidths") 88 return &list, err 89 } 90 91 type UpdateResult struct { 92 commonResult 93 } 94 95 func (r UpdateResult) Extract() (*BandWidth, error) { 96 var entity BandWidth 97 err := r.ExtractIntoStructPtr(&entity, "bandwidth") 98 return &entity, err 99 } 100 func (r BandWidthPage) IsEmpty() (bool, error) { 101 list, err := ExtractBandWidths(r) 102 return len(list) == 0, err 103 } 104 105 type BandWidthPage struct { 106 pagination.LinkedPageBase 107 } 108 109 func ExtractBandWidths(r pagination.Page) ([]BandWidth, error) { 110 var s struct { 111 BandWidths []BandWidth `json:"bandwidths"` 112 } 113 err := r.(BandWidthPage).ExtractInto(&s) 114 return s.BandWidths, err 115 } 116 func (r BandWidthPage) NextPageURL() (string, error) { 117 s, err := ExtractBandWidths(r) 118 if err != nil { 119 return "", err 120 } 121 return r.WrapNextPageURL(s[len(s)-1].ID) 122 }