github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cbr/v3/members/results.go (about)

     1  package members
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  // Member is the structure that represents the backup shared member detail.
     6  type Member struct {
     7  	// The status of the backup share.
     8  	Status string `json:"status"`
     9  	// The creation time of the backup sharing member.
    10  	CreatedAt string `json:"created_at"`
    11  	// The latest update time of the backup sharing member.
    12  	UpdatedAt string `json:"updated_at"`
    13  	// The backup ID.
    14  	BackupId string `json:"backup_id"`
    15  	// The latest update time of the backup shared member.
    16  	ImageId string `json:"image_id"`
    17  	// The ID of the project with which the backup is shared.
    18  	DestProjectId string `json:"dest_project_id"`
    19  	// The ID of the vault where the shared backup is stored.
    20  	VaultId string `json:"vault_id"`
    21  	// The ID of the backup shared member record.
    22  	ID string `json:"id"`
    23  }
    24  
    25  // MemberPage is a single page maximum result representing a query by offset page.
    26  type MemberPage struct {
    27  	pagination.OffsetPageBase
    28  }
    29  
    30  // IsEmpty checks whether a MemberPage struct is empty.
    31  func (b MemberPage) IsEmpty() (bool, error) {
    32  	arr, err := ExtractMembers(b)
    33  	return len(arr) == 0, err
    34  }
    35  
    36  // ExtractMembers is a method to extract the list of sharing members.
    37  func ExtractMembers(r pagination.Page) ([]Member, error) {
    38  	var s []Member
    39  	err := r.(MemberPage).Result.ExtractIntoSlicePtr(&s, "members")
    40  	return s, err
    41  }