github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/vpcep/v1/endpoints/results.go (about)

     1  package endpoints
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/vpcep/v1/services"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/pagination"
     8  )
     9  
    10  type Status string
    11  
    12  const (
    13  	StatusPendingAcceptance Status = "pendingAcceptance"
    14  	StatusCreating          Status = "creating"
    15  	StatusAccepted          Status = "accepted"
    16  	StatusFailed            Status = "failed"
    17  )
    18  
    19  type Endpoint struct {
    20  	// Specifies the unique ID of the VPC endpoint.
    21  	ID string `json:"id"`
    22  
    23  	// Specifies the type of the VPC endpoint service that is associated with the VPC endpoint.
    24  	ServiceType services.ServiceType `json:"service_type"`
    25  
    26  	// Specifies the packet ID of the VPC endpoint.
    27  	MarkerID int `json:"marker_id"`
    28  
    29  	// Specifies the connection status of the VPC endpoint.
    30  	//
    31  	//    pendingAcceptance: indicates that the VPC endpoint is pending acceptance.
    32  	//    creating: indicates the VPC endpoint is being created.
    33  	//    accepted: indicates the VPC endpoint has been accepted.
    34  	//    failed: indicates the creation of the VPC endpoint failed.
    35  	Status Status `json:"status"`
    36  
    37  	// Specifies the domain status.
    38  	//    frozen: indicates that the domain is frozen.
    39  	//    active: indicates that the domain is normal.
    40  	ActiveStatus []string `json:"active_status"`
    41  
    42  	// Specifies the ID of the VPC where the VPC endpoint is to be created.
    43  	RouterID string `json:"vpc_id"`
    44  
    45  	// Specifies the ID of the subnet (OS network) in the VPC specified by `vpc_id`. The value is in the UUID format.
    46  	NetworkID string `json:"subnet_id"`
    47  
    48  	// Specifies whether to create a private domain name.
    49  	EnableDNS bool `json:"enable_dns"`
    50  
    51  	// Specifies the domain name for accessing the associated VPC endpoint service.
    52  	DNSNames []string `json:"dns_names"`
    53  
    54  	// Specifies the IP address for accessing the associated VPC endpoint service.
    55  	IP string `json:"ip"`
    56  
    57  	// Specifies the name of the VPC endpoint service.
    58  	ServiceName string `json:"endpoint_service_name"`
    59  
    60  	// Specifies the ID of the VPC endpoint service.
    61  	ServiceID string `json:"endpoint_service_id"`
    62  
    63  	// Specifies the project ID.
    64  	ProjectID string `json:"project_id"`
    65  
    66  	// Specifies the whitelist for controlling access to the VPC endpoint.
    67  	Whitelist []string `json:"whitelist"`
    68  
    69  	// Specifies whether to enable access control.
    70  	EnableWhitelist bool `json:"enable_whitelist"`
    71  
    72  	// Lists the IDs of route tables.
    73  	RouteTables []string `json:"routetables"`
    74  
    75  	// Specifies the creation time of the VPC endpoint.
    76  	CreatedAt string `json:"created_at"`
    77  
    78  	// Specifies the update time of the VPC endpoint.
    79  	UpdatedAt string `json:"updated_at"`
    80  
    81  	// Lists the resource tags.
    82  	Tags []tags.ResourceTag `json:"tags"`
    83  }
    84  
    85  type commonResult struct {
    86  	golangsdk.Result
    87  }
    88  
    89  func (r commonResult) Extract() (*Endpoint, error) {
    90  	ep := new(Endpoint)
    91  	err := r.ExtractIntoStructPtr(ep, "")
    92  	if err != nil {
    93  		return nil, err
    94  	}
    95  	return ep, nil
    96  }
    97  
    98  type CreateResult struct {
    99  	commonResult
   100  }
   101  
   102  type GetResult struct {
   103  	commonResult
   104  }
   105  
   106  type UpdateResult struct {
   107  	commonResult
   108  }
   109  
   110  type DeleteResult struct {
   111  	golangsdk.ErrResult
   112  }
   113  
   114  type EndpointPage struct {
   115  	pagination.OffsetPageBase
   116  }
   117  
   118  func (p EndpointPage) IsEmpty() (bool, error) {
   119  	eps, err := ExtractEndpoints(p)
   120  	if err != nil {
   121  		return false, err
   122  	}
   123  	return len(eps) == 0, nil
   124  }
   125  
   126  func ExtractEndpoints(p pagination.Page) ([]Endpoint, error) {
   127  	var eps []Endpoint
   128  	err := p.(EndpointPage).ExtractIntoSlicePtr(&eps, "endpoints")
   129  	return eps, err
   130  }