github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vpcep/v1/endpoints/results.go (about)

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