github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vpc/v1/publicips/results.go (about) 1 package publicips 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type PublicIP struct { 9 // Specifies the ID of the elastic IP address, which uniquely 10 // identifies the elastic IP address. 11 ID string `json:"id"` 12 13 // Specifies the status of the elastic IP address. 14 Status string `json:"status"` 15 16 // ext data for order info 17 Profile Profile `json:"profile"` 18 19 // Specifies the type of the elastic IP address. 20 Type string `json:"type"` 21 22 // Specifies the obtained elastic IP address. 23 PublicIpAddress string `json:"public_ip_address"` 24 25 // Specifies the obtained elastic IPv6 address. 26 PublicIpV6Address string `json:"public_ipv6_address"` 27 28 //Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default 29 IPVersion int `json:"ip_version"` 30 31 // Specifies the private IP address bound to the elastic IP 32 // address. 33 PrivateIpAddress string `json:"private_ip_address,omitempty"` 34 35 // Specifies the port ID. 36 PortId string `json:"port_id,omitempty"` 37 38 // Specifies the tenant ID of the operator. 39 TenantId string `json:"tenant_id"` 40 41 // Specifies the time for applying for the elastic IP address. 42 CreateTime string `json:"create_time"` 43 44 // Specifies the bandwidth ID of the elastic IP address. 45 BandwidthId string `json:"bandwidth_id"` 46 47 // Specifies the bandwidth size. 48 BandwidthSize int `json:"bandwidth_size"` 49 50 // Specifies whether the bandwidth is shared or exclusive. 51 BandwidthShareType string `json:"bandwidth_share_type"` 52 // 53 // Specifies the bandwidth name. 54 BandwidthName string `json:"bandwidth_name"` 55 56 // Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0". 57 //When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP. 58 EnterpriseProjectId string `json:"enterprise_project_id,omitempty"` 59 } 60 61 type Profile struct { 62 UserID string `json:"user_id"` 63 ProductID string `json:"product_id"` 64 RegionID string `json:"region_id"` 65 OrderID string `json:"order_id"` 66 } 67 68 type PublicIPCreateResp struct { 69 // Specifies the ID of the elastic IP address, which uniquely 70 // identifies the elastic IP address. 71 ID string `json:"id"` 72 73 // Specifies the status of the elastic IP address. 74 Status string `json:"status"` 75 76 // Specifies the type of the elastic IP address. 77 Type string `json:"type"` 78 79 // Specifies the obtained elastic IP address. 80 PublicIpAddress string `json:"public_ip_address"` 81 82 // Specifies the obtained elastic IPv6 address. 83 PublicIpV6Address string `json:"public_ipv6_address"` 84 85 //Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default 86 IPVersion int `json:"ip_version"` 87 88 // Specifies the tenant ID of the operator. 89 TenantId string `json:"tenant_id"` 90 91 // Specifies the time for applying for the elastic IP address. 92 CreateTime string `json:"create_time"` 93 94 // Specifies the bandwidth size. 95 BandwidthSize int `json:"bandwidth_size"` 96 97 // Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0". 98 //When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP. 99 EnterpriseProjectId string `json:"enterprise_project_id,omitempty"` 100 } 101 102 type PublicIPUpdateResp struct { 103 // Specifies the ID of the elastic IP address, which uniquely 104 // identifies the elastic IP address. 105 ID string `json:"id"` 106 107 // Specifies the status of the elastic IP address. 108 Status string `json:"status"` 109 110 // Specifies the type of the elastic IP address. 111 Type string `json:"type"` 112 113 // Specifies the obtained elastic IP address. 114 PublicIpAddress string `json:"public_ip_address"` 115 116 // Specifies the private IP address bound to the elastic IP address. 117 PrivateIpAddress string `json:"private_ip_address"` 118 119 // Specifies the obtained elastic IPv6 address. 120 PublicIpV6Address string `json:"public_ipv6_address"` 121 122 //Value range: 4, 6, respectively, to create ipv4 and ipv6, when not created ipv4 by default 123 IPVersion int `json:"ip_version"` 124 125 // Specifies the port ID. 126 PortId string `json:"port_id,omitempty"` 127 128 // Specifies the tenant ID of the operator. 129 TenantId string `json:"tenant_id"` 130 131 // Specifies the time for applying for the elastic IP address. 132 CreateTime string `json:"create_time"` 133 134 // Specifies the bandwidth size. 135 BandwidthSize int `json:"bandwidth_size"` 136 137 // Specifies the bandwidth ID of the elastic IP address. 138 BandwidthId string `json:"bandwidth_id"` 139 140 // Specifies whether the bandwidth is shared or exclusive. 141 BandwidthShareType string `json:"bandwidth_share_type"` 142 143 // Specifies the bandwidth name. 144 BandwidthName string `json:"bandwidth_name"` 145 146 // Enterprise project ID. The maximum length is 36 bytes, with the U-ID format of the hyphen "-", or the string "0". 147 //When creating an elastic public IP address, bind the enterprise project ID to the elastic public network IP. 148 EnterpriseProjectId string `json:"enterprise_project_id"` 149 } 150 type commonResult struct { 151 golangsdk.Result 152 } 153 154 type CreateResult struct { 155 commonResult 156 } 157 158 func (r CreateResult) Extract() (*PublicIPCreateResp, error) { 159 var entity PublicIPCreateResp 160 err := r.ExtractIntoStructPtr(&entity, "publicip") 161 return &entity, err 162 } 163 164 type DeleteResult struct { 165 golangsdk.ErrResult 166 } 167 168 type GetResult struct { 169 commonResult 170 } 171 172 func (r GetResult) Extract() (*PublicIP, error) { 173 var entity PublicIP 174 err := r.ExtractIntoStructPtr(&entity, "publicip") 175 return &entity, err 176 } 177 178 type PublicIPPage struct { 179 pagination.LinkedPageBase 180 } 181 182 func (r PublicIPPage) NextPageURL() (string, error) { 183 publicIps, err := ExtractPublicIPs(r) 184 if err != nil { 185 return "", err 186 } 187 return r.WrapNextPageURL(publicIps[len(publicIps)-1].ID) 188 } 189 190 func ExtractPublicIPs(r pagination.Page) ([]PublicIP, error) { 191 var s struct { 192 PublicIPs []PublicIP `json:"publicips"` 193 } 194 err := r.(PublicIPPage).ExtractInto(&s) 195 return s.PublicIPs, err 196 } 197 198 // IsEmpty checks whether a NetworkPage struct is empty. 199 func (r PublicIPPage) IsEmpty() (bool, error) { 200 s, err := ExtractPublicIPs(r) 201 return len(s) == 0, err 202 } 203 204 type UpdateResult struct { 205 commonResult 206 } 207 208 func (r UpdateResult) Extract() (*PublicIPUpdateResp, error) { 209 var entity PublicIPUpdateResp 210 err := r.ExtractIntoStructPtr(&entity, "publicip") 211 return &entity, err 212 }