github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/vpcep/v1/services/results.go (about)

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