github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/workspace/v2/terminals/results.go (about)

     1  package terminals
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  // TerminalBindingResp is the structure that represents the bind information between MAC addresses and desktops.
     6  type TerminalBindingResp struct {
     7  	// Line info.
     8  	Line int `json:"line"`
     9  	// Terminal MAC address.
    10  	MAC string `json:"mac"`
    11  	// Desktop name.
    12  	DesktopName string `json:"desktop_name"`
    13  	// Description.
    14  	Description string `json:"description"`
    15  	// Bind ID.
    16  	ID string `json:"id"`
    17  	// SID.
    18  	SID string `json:"sid"`
    19  	// The validation result code.
    20  	ValidationResultCode string `json:"validation_result_code"`
    21  }
    22  
    23  // TerminalBindingPage is a single page maximum result representing a query by offset page.
    24  type TerminalBindingPage struct {
    25  	pagination.OffsetPageBase
    26  }
    27  
    28  // IsEmpty checks whether a TerminalBindingPage struct is empty.
    29  func (b TerminalBindingPage) IsEmpty() (bool, error) {
    30  	arr, err := ExtractTerminalBindings(b)
    31  	return len(arr) == 0, err
    32  }
    33  
    34  // ExtractTerminalBindings is a method to extract the list of terminal binding desktops information.
    35  func ExtractTerminalBindings(r pagination.Page) ([]TerminalBindingResp, error) {
    36  	var s []TerminalBindingResp
    37  	err := r.(TerminalBindingPage).Result.ExtractIntoSlicePtr(&s, "bind_list")
    38  	return s, err
    39  }
    40  
    41  type deleteResp struct {
    42  	// Delete result list.
    43  	ResultList []DeleteResult `json:"result_list"`
    44  }
    45  
    46  // DeleteResult is the structure that represents the request response of the terminal binding.
    47  type DeleteResult struct {
    48  	// Bind ID.
    49  	ID string `json:"id"`
    50  	// Delete result code.
    51  	DeleteResultCode string `json:"delete_result_code"`
    52  	// Delete result message.
    53  	DeleteResultMsg string `json:"delete_result_msg"`
    54  }