github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vpcep/v1/services/results.go (about) 1 package services 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/openstack/common/tags" 6 ) 7 8 // Service contains the response of the VPC endpoint service 9 type Service struct { 10 // the ID of the VPC endpoint service 11 ID string `json:"id"` 12 // the status of the VPC endpoint service 13 Status string `json:"status"` 14 // the ID for identifying the backend resource of the VPC endpoint service 15 PortID string `json:"port_id"` 16 // the ID of the VPC to which the backend resource of the VPC endpoint service belongs 17 VpcID string `json:"vpc_id"` 18 // the name of the VPC endpoint service 19 ServiceName string `json:"service_name"` 20 // the type of the VPC endpoint service 21 ServiceType string `json:"service_type"` 22 // the resource type 23 ServerType string `json:"server_type"` 24 // whether connection approval is required 25 Approval bool `json:"approval_enabled"` 26 // the ID of the virtual NIC to which the virtual IP address is bound 27 VipPortID string `json:"vip_port_id"` 28 // the project ID 29 ProjectID string `json:"project_id"` 30 // the network segment type. The value can be public or internal 31 CidrType string `json:"cidr_type"` 32 // Lists the port mappings opened to the VPC endpoint service 33 Ports []PortMapping `json:"ports"` 34 // whether the client IP address and port number or marker_id information is transmitted to the server 35 TCPProxy string `json:"tcp_proxy"` 36 // the resource tags 37 Tags []tags.ResourceTag `json:"tags"` 38 // the error message when the status of the VPC endpoint service changes to failed 39 Error []ErrorInfo `json:"error"` 40 // the creation time of the VPC endpoint service 41 Created string `json:"created_at"` 42 // the update time of the VPC endpoint service 43 Updated string `json:"updated_at"` 44 } 45 46 // PortMapping contains the port mappings opened to the VPC endpoint service 47 type PortMapping struct { 48 // the protocol used in port mappings. The value can be TCP or UDP. 49 Protocol string `json:"protocol"` 50 // the port for accessing the VPC endpoint 51 ClientPort int `json:"client_port"` 52 // the port for accessing the VPC endpoint service 53 ServerPort int `json:"server_port"` 54 } 55 56 type ErrorInfo struct { 57 Code string `json:"error_code"` 58 Message string `json:"error_message"` 59 } 60 61 // PublicService contains the response of the public VPC endpoint service 62 type PublicService struct { 63 // the ID of the public VPC endpoint service 64 ID string `json:"id"` 65 // the owner of the VPC endpoint service 66 Owner string `json:"owner"` 67 // the name of the VPC endpoint service 68 ServiceName string `json:"service_name"` 69 // the type of the VPC endpoint service: gateway or interface 70 ServiceType string `json:"service_type"` 71 // whether the associated VPC endpoint carries a charge: true or false 72 IsChange bool `json:"is_charge"` 73 // the creation time of the VPC endpoint service 74 Created string `json:"created_at"` 75 } 76 77 type commonResult struct { 78 golangsdk.Result 79 } 80 81 // ListResult represents the result of a list operation. Call its ExtractServices 82 // method to interpret it as Services. 83 type ListResult struct { 84 commonResult 85 } 86 87 // ListPublicResult represents the result of a list public operation. Call its ExtractServices 88 // method to interpret it as PublicServices. 89 type ListPublicResult struct { 90 commonResult 91 } 92 93 // CreateResult represents the result of a create operation. Call its Extract 94 // method to interpret it as a Service. 95 type CreateResult struct { 96 commonResult 97 } 98 99 // GetResult represents the result of a get operation. Call its Extract 100 // method to interpret it as a Service. 101 type GetResult struct { 102 commonResult 103 } 104 105 // UpdateResult represents the result of an update operation. Call its Extract 106 // method to interpret it as a Service. 107 type UpdateResult struct { 108 commonResult 109 } 110 111 // DeleteResult represents the result of a delete operation. Call its ExtractErr 112 // method to determine if the request succeeded or failed. 113 type DeleteResult struct { 114 golangsdk.ErrResult 115 } 116 117 // Extract is a function that accepts a result and extracts a Service. 118 func (r commonResult) Extract() (*Service, error) { 119 var s Service 120 err := r.ExtractInto(&s) 121 return &s, err 122 } 123 124 // ExtractServices is a function that accepts a result and extracts the given Services 125 func (r ListResult) ExtractServices() ([]Service, error) { 126 var s struct { 127 Services []Service `json:"endpoint_services"` 128 } 129 130 err := r.ExtractInto(&s) 131 if err != nil { 132 return nil, err 133 } 134 return s.Services, nil 135 } 136 137 // ExtractServices is a function that accepts a result and extracts the given PublicService 138 func (r ListPublicResult) ExtractServices() ([]PublicService, error) { 139 var s struct { 140 Services []PublicService `json:"endpoint_services"` 141 } 142 143 err := r.ExtractInto(&s) 144 if err != nil { 145 return nil, err 146 } 147 return s.Services, nil 148 } 149 150 // Connection contains the response of querying Connections of a VPC Endpoint Service 151 type Connection struct { 152 // the ID of the VPC endpoint 153 EndpointID string `json:"id"` 154 // the packet ID of the VPC endpoint 155 MarkerID int `json:"marker_id"` 156 // the ID of the user's domain 157 DomainID string `json:"domain_id"` 158 // the connection status of the VPC endpoint 159 Status string `json:"status"` 160 // the creation time of the VPC endpoint 161 Created string `json:"created_at"` 162 // the update time of the VPC endpoint 163 Updated string `json:"updated_at"` 164 // the error message when the status of the VPC endpoint service changes to failed 165 Error []ErrorInfo `json:"error"` 166 } 167 168 // ConnectionResult represents the result of a list connections. 169 // Call its ExtractConnections method to interpret it as []Connection. 170 type ConnectionResult struct { 171 commonResult 172 } 173 174 // ExtractConnections is a function that accepts a result and extracts the given []Connection 175 func (r ConnectionResult) ExtractConnections() ([]Connection, error) { 176 var s struct { 177 Connections []Connection `json:"connections"` 178 } 179 180 err := r.ExtractInto(&s) 181 if err != nil { 182 return nil, err 183 } 184 return s.Connections, nil 185 } 186 187 // Permission contains the response of querying Permissions of a VPC Endpoint Service 188 type Permission struct { 189 // the unique ID of the permission. 190 ID string `json:"id"` 191 // the whitelist records. 192 Permission string `json:"permission"` 193 // the time of adding the whitelist record 194 Created string `json:"created_at"` 195 } 196 197 type PermActionResult struct { 198 commonResult 199 } 200 201 // ListPermResult represents the result of a list permissions. Call its ExtractPermissions 202 // method to interpret it as []Permission. 203 type ListPermResult struct { 204 commonResult 205 } 206 207 // ExtractPermissions is a function that accepts a result and extracts the given []Permission 208 func (r ListPermResult) ExtractPermissions() ([]Permission, error) { 209 var s struct { 210 Permissions []Permission `json:"permissions"` 211 } 212 213 err := r.ExtractInto(&s) 214 if err != nil { 215 return nil, err 216 } 217 return s.Permissions, nil 218 }