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

     1  package repositories
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  type CreateResult struct {
     9  	golangsdk.ErrResult
    10  }
    11  
    12  type DeleteResult struct {
    13  	golangsdk.ErrResult
    14  }
    15  
    16  type UpdateResult struct {
    17  	golangsdk.ErrResult
    18  }
    19  
    20  type GetResult struct {
    21  	golangsdk.Result
    22  }
    23  
    24  type ImageRepository struct {
    25  	ID             int    `json:"id"`
    26  	OrganizationID int    `json:"ns_id"`
    27  	Name           string `json:"name"`
    28  	Category       string `json:"category"`
    29  	Description    string `json:"description"`
    30  	CreatorID      string `json:"creator_id"`
    31  	CreatorName    string `json:"creator_name"`
    32  	Size           int    `json:"size"`
    33  	IsPublic       bool   `json:"is_public"`
    34  	NumImages      int    `json:"num_images"`
    35  	NumDownloads   int    `json:"num_downloads"`
    36  	URL            string `json:"url"`
    37  	Path           string `json:"path"`
    38  	InternalPath   string `json:"internal_path"`
    39  	Created        string `json:"created"`
    40  	Updated        string `json:"updated"`
    41  	DomainID       string `json:"domain_id"`
    42  	Prioriry       int    `json:"poriroty"`
    43  }
    44  
    45  func (r GetResult) Extract() (*ImageRepository, error) {
    46  	var repo ImageRepository
    47  	err := r.ExtractInto(&repo)
    48  	return &repo, err
    49  }
    50  
    51  type RepositoryPage struct {
    52  	pagination.LinkedPageBase
    53  }
    54  
    55  func ExtractRepositories(p pagination.Page) ([]ImageRepository, error) {
    56  	var repos []ImageRepository
    57  	err := (p.(RepositoryPage)).ExtractIntoSlicePtr(&repos, "")
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	return repos, nil
    62  }