github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/sharetypes/results.go (about) 1 package sharetypes 2 3 import ( 4 "github.com/gophercloud/gophercloud" 5 "github.com/gophercloud/gophercloud/pagination" 6 ) 7 8 // ShareType contains all the information associated with an OpenStack 9 // ShareType. 10 type ShareType struct { 11 // The Share Type ID 12 ID string `json:"id"` 13 // The Share Type name 14 Name string `json:"name"` 15 // Indicates whether a share type is publicly accessible 16 IsPublic bool `json:"os-share-type-access:is_public"` 17 // The required extra specifications for the share type 18 RequiredExtraSpecs map[string]interface{} `json:"required_extra_specs"` 19 // The extra specifications for the share type 20 ExtraSpecs map[string]interface{} `json:"extra_specs"` 21 } 22 23 type commonResult struct { 24 gophercloud.Result 25 } 26 27 // Extract will get the ShareType object out of the commonResult object. 28 func (r commonResult) Extract() (*ShareType, error) { 29 var s struct { 30 ShareType *ShareType `json:"share_type"` 31 } 32 err := r.ExtractInto(&s) 33 return s.ShareType, err 34 } 35 36 // CreateResult contains the response body and error from a Create request. 37 type CreateResult struct { 38 commonResult 39 } 40 41 // DeleteResult contains the response body and error from a Delete request. 42 type DeleteResult struct { 43 gophercloud.ErrResult 44 } 45 46 // ShareTypePage is a pagination.pager that is returned from a call to the List function. 47 type ShareTypePage struct { 48 pagination.SinglePageBase 49 } 50 51 // IsEmpty returns true if a ListResult contains no ShareTypes. 52 func (r ShareTypePage) IsEmpty() (bool, error) { 53 if r.StatusCode == 204 { 54 return true, nil 55 } 56 57 shareTypes, err := ExtractShareTypes(r) 58 return len(shareTypes) == 0, err 59 } 60 61 // ExtractShareTypes extracts and returns ShareTypes. It is used while 62 // iterating over a sharetypes.List call. 63 func ExtractShareTypes(r pagination.Page) ([]ShareType, error) { 64 var s struct { 65 ShareTypes []ShareType `json:"share_types"` 66 } 67 err := (r.(ShareTypePage)).ExtractInto(&s) 68 return s.ShareTypes, err 69 } 70 71 // GetDefaultResult contains the response body and error from a Get Default request. 72 type GetDefaultResult struct { 73 commonResult 74 } 75 76 // ExtraSpecs contains all the information associated with extra specifications 77 // for an Openstack ShareType. 78 type ExtraSpecs map[string]interface{} 79 80 type extraSpecsResult struct { 81 gophercloud.Result 82 } 83 84 // Extract will get the ExtraSpecs object out of the commonResult object. 85 func (r extraSpecsResult) Extract() (ExtraSpecs, error) { 86 var s struct { 87 Specs ExtraSpecs `json:"extra_specs"` 88 } 89 err := r.ExtractInto(&s) 90 return s.Specs, err 91 } 92 93 // GetExtraSpecsResult contains the response body and error from a Get Extra Specs request. 94 type GetExtraSpecsResult struct { 95 extraSpecsResult 96 } 97 98 // SetExtraSpecsResult contains the response body and error from a Set Extra Specs request. 99 type SetExtraSpecsResult struct { 100 extraSpecsResult 101 } 102 103 // UnsetExtraSpecsResult contains the response body and error from a Unset Extra Specs request. 104 type UnsetExtraSpecsResult struct { 105 gophercloud.ErrResult 106 } 107 108 // ShareTypeAccess contains all the information associated with an OpenStack 109 // ShareTypeAccess. 110 type ShareTypeAccess struct { 111 // The share type ID of the member. 112 ShareTypeID string `json:"share_type_id"` 113 // The UUID of the project for which access to the share type is granted. 114 ProjectID string `json:"project_id"` 115 } 116 117 type shareTypeAccessResult struct { 118 gophercloud.Result 119 } 120 121 // ShowAccessResult contains the response body and error from a Show access request. 122 type ShowAccessResult struct { 123 shareTypeAccessResult 124 } 125 126 // Extract will get the ShareTypeAccess objects out of the shareTypeAccessResult object. 127 func (r ShowAccessResult) Extract() ([]ShareTypeAccess, error) { 128 var s struct { 129 ShareTypeAccess []ShareTypeAccess `json:"share_type_access"` 130 } 131 err := r.ExtractInto(&s) 132 return s.ShareTypeAccess, err 133 } 134 135 // AddAccessResult contains the response body and error from a Add Access request. 136 type AddAccessResult struct { 137 gophercloud.ErrResult 138 } 139 140 // RemoveAccessResult contains the response body and error from a Remove Access request. 141 type RemoveAccessResult struct { 142 gophercloud.ErrResult 143 }