github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/sfs_turbo/v1/shares/results.go (about) 1 package shares 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 6 ) 7 8 // TurboResponse contains the information of creating response 9 type TurboResponse struct { 10 ID string `json:"id"` 11 Name string `json:"name"` 12 Status string `json:"status"` 13 } 14 15 // Turbo contains all information associated with an SFS Turbo file system 16 type Turbo struct { 17 // The UUID of the SFS Turbo file system 18 ID string `json:"id"` 19 // The name of the SFS Turbo file system 20 Name string `json:"name"` 21 // Size of the share in GB 22 Size string `json:"size"` 23 // The statue of the SFS Turbo file system 24 Status string `json:"status"` 25 // The sub-statue of the SFS Turbo file system 26 SubStatus string `json:"sub_status"` 27 // The version ID of the SFS Turbo file system 28 Version string `json:"version"` 29 // The mount location 30 ExportLocation string `json:"export_location"` 31 // The creation progress of the SFS Turbo file system 32 Actions []string `json:"actions"` 33 // The protocol type of the SFS Turbo file system 34 ShareProto string `json:"share_proto"` 35 // The type of the SFS Turbo file system, STANDARD or PERFORMANCE. 36 ShareType string `json:"share_type"` 37 // The region of the SFS Turbo file system 38 Region string `json:"region"` 39 // The code of the availability zone 40 AvailabilityZone string `json:"availability_zone"` 41 // The name of the availability zone 42 AZName string `json:"az_name"` 43 // The VPC ID 44 VpcID string `json:"vpc_id"` 45 // The subnet ID 46 SubnetID string `json:"subnet_id"` 47 // The security group ID 48 SecurityGroupID string `json:"security_group_id"` 49 // The available capacity if the SFS Turbo file system 50 AvailCapacity string `json:"avail_capacity"` 51 // bandwidth is returned for an enhanced file system 52 ExpandType string `json:"expand_type"` 53 // The ID of the encryption key 54 CryptKeyID string `json:"crypt_key_id"` 55 // The billing mode, 0 indicates pay-per-use, 1 indicates yearly/monthly subscription 56 PayModel string `json:"pay_model"` 57 // Timestamp when the share was created 58 CreatedAt string `json:"created_at"` 59 } 60 61 type commonResult struct { 62 golangsdk.Result 63 } 64 65 // CreateResult contains the response body and error from a Create request. 66 type CreateResult struct { 67 commonResult 68 } 69 70 // GetResult contains the response body and error from a Get request. 71 type GetResult struct { 72 commonResult 73 } 74 75 // DeleteResult contains the error from a Delete request. 76 type DeleteResult struct { 77 golangsdk.ErrResult 78 } 79 80 // ExpandResult contains the error from an Expand request. 81 type ExpandResult struct { 82 golangsdk.ErrResult 83 } 84 85 // ChangeSGResult contains the error from a ChangeSG request. 86 type ChangeSGResult struct { 87 golangsdk.ErrResult 88 } 89 90 // Extract will get the Turbo response object from the CreateResult 91 func (r CreateResult) Extract() (*TurboResponse, error) { 92 var s TurboResponse 93 err := r.ExtractInto(&s) 94 return &s, err 95 } 96 97 // Extract will get the Turbo object from the GetResult 98 func (r GetResult) Extract() (*Turbo, error) { 99 var s Turbo 100 err := r.ExtractInto(&s) 101 return &s, err 102 } 103 104 // TurboPage is the page returned by a pager when traversing over a 105 // collection of Shares. 106 type TurboPage struct { 107 pagination.LinkedPageBase 108 } 109 110 // ExtractTurbos accepts a Page struct, specifically a TurboPage struct, 111 // and extracts the elements into a slice of share structs. In other words, 112 // a generic collection is mapped into a relevant slice. 113 func ExtractTurbos(r pagination.Page) ([]Turbo, error) { 114 var s struct { 115 ListedShares []Turbo `json:"shares"` 116 } 117 err := (r.(TurboPage)).ExtractInto(&s) 118 return s.ListedShares, err 119 } 120 121 // IsEmpty returns true if a ListResult contains no Shares. 122 func (r TurboPage) IsEmpty() (bool, error) { 123 shares, err := ExtractTurbos(r) 124 return len(shares) == 0, err 125 } 126 127 // NextPageURL is invoked when a paginated collection of shares has reached 128 // the end of a page and the pager seeks to traverse over a new one. In order 129 // to do this, it needs to construct the next page's URL. 130 func (r TurboPage) NextPageURL() (string, error) { 131 var s struct { 132 Links []golangsdk.Link `json:"shares_links"` 133 } 134 err := r.ExtractInto(&s) 135 if err != nil { 136 return "", err 137 } 138 return golangsdk.ExtractNextURL(s.Links) 139 }