This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
results.go
96 lines (86 loc) · 2.94 KB
/
results.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package endpoints
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/openstack/common/tags"
)
// Endpoint contains the response of the VPC endpoint
type Endpoint struct {
// the ID of the VPC endpoint
ID string `json:"id"`
// the connection status of the VPC endpoint
Status string `json:"status"`
// the account status: frozen or active
ActiveStatus []string `json:"active_status"`
// the type of the VPC endpoint service that is associated with the VPC endpoint
ServiceType string `json:"service_type"`
// the name of the VPC endpoint service
ServiceName string `json:"endpoint_service_name"`
// the ID of the VPC endpoint service
ServiceID string `json:"endpoint_service_id"`
// the ID of the VPC where the VPC endpoint is to be created
VpcID string `json:"vpc_id"`
// the network ID of the subnet in the VPC specified by vpc_id
SubnetID string `json:"subnet_id"`
// the IP address for accessing the associated VPC endpoint service
IPAddr string `json:"ip"`
// the packet ID of the VPC endpoint
MarkerID int `json:"marker_id"`
// whether to create a private domain name
EnableDNS bool `json:"enable_dns"`
// the domain name for accessing the associated VPC endpoint service
DNSNames []string `json:"dns_names"`
// whether to enable access control
EnableWhitelist bool `json:"enable_whitelist"`
// the whitelist for controlling access to the VPC endpoint
Whitelist []string `json:"whitelist"`
// the IDs of route tables
RouteTables []string `json:"routetables"`
// the resource tags
Tags []tags.ResourceTag `json:"tags"`
// the project ID
ProjectID string `json:"project_id"`
// the creation time of the VPC endpoint
Created string `json:"created_at"`
// the update time of the VPC endpoint
Updated string `json:"updated_at"`
}
type commonResult struct {
golangsdk.Result
}
// CreateResult represents the result of a create operation. Call its Extract
// method to interpret it as a Endpoint.
type CreateResult struct {
commonResult
}
// GetResult represents the result of a get operation. Call its Extract
// method to interpret it as a Endpoint.
type GetResult struct {
commonResult
}
// DeleteResult represents the result of a delete operation. Call its ExtractErr
// method to determine if the request succeeded or failed.
type DeleteResult struct {
golangsdk.ErrResult
}
// ListResult represents the result of a list operation. Call its ExtractEndpoints
// method to interpret it as Endpoints.
type ListResult struct {
commonResult
}
// Extract is a function that accepts a result and extracts a Endpoint
func (r commonResult) Extract() (*Endpoint, error) {
var ep Endpoint
err := r.ExtractInto(&ep)
return &ep, err
}
// ExtractEndpoints is a function that accepts a result and extracts the given Endpoints
func (r ListResult) ExtractEndpoints() ([]Endpoint, error) {
var s struct {
Endpoints []Endpoint `json:"endpoints"`
}
err := r.ExtractInto(&s)
if err != nil {
return nil, err
}
return s.Endpoints, nil
}