github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/shares/requests.go (about)

     1  package shares
     2  
     3  import (
     4  	"github.com/gophercloud/gophercloud"
     5  	"github.com/gophercloud/gophercloud/pagination"
     6  )
     7  
     8  // CreateOptsBuilder allows extensions to add additional parameters to the
     9  // Create request.
    10  type CreateOptsBuilder interface {
    11  	ToShareCreateMap() (map[string]interface{}, error)
    12  }
    13  
    14  // CreateOpts contains the options for create a Share. This object is
    15  // passed to shares.Create(). For more information about these parameters,
    16  // please refer to the Share object, or the shared file systems API v2
    17  // documentation
    18  type CreateOpts struct {
    19  	// Defines the share protocol to use
    20  	ShareProto string `json:"share_proto" required:"true"`
    21  	// Size in GB
    22  	Size int `json:"size" required:"true"`
    23  	// Defines the share name
    24  	Name string `json:"name,omitempty"`
    25  	// Share description
    26  	Description string `json:"description,omitempty"`
    27  	// DisplayName is equivalent to Name. The API supports using both
    28  	// This is an inherited attribute from the block storage API
    29  	DisplayName string `json:"display_name,omitempty"`
    30  	// DisplayDescription is equivalent to Description. The API supports using both
    31  	// This is an inherited attribute from the block storage API
    32  	DisplayDescription string `json:"display_description,omitempty"`
    33  	// ShareType defines the sharetype. If omitted, a default share type is used
    34  	ShareType string `json:"share_type,omitempty"`
    35  	// VolumeType is deprecated but supported. Either ShareType or VolumeType can be used
    36  	VolumeType string `json:"volume_type,omitempty"`
    37  	// The UUID from which to create a share
    38  	SnapshotID string `json:"snapshot_id,omitempty"`
    39  	// Determines whether or not the share is public
    40  	IsPublic *bool `json:"is_public,omitempty"`
    41  	// Key value pairs of user defined metadata
    42  	Metadata map[string]string `json:"metadata,omitempty"`
    43  	// The UUID of the share network to which the share belongs to
    44  	ShareNetworkID string `json:"share_network_id,omitempty"`
    45  	// The UUID of the consistency group to which the share belongs to
    46  	ConsistencyGroupID string `json:"consistency_group_id,omitempty"`
    47  	// The availability zone of the share
    48  	AvailabilityZone string `json:"availability_zone,omitempty"`
    49  }
    50  
    51  // ToShareCreateMap assembles a request body based on the contents of a
    52  // CreateOpts.
    53  func (opts CreateOpts) ToShareCreateMap() (map[string]interface{}, error) {
    54  	return gophercloud.BuildRequestBody(opts, "share")
    55  }
    56  
    57  // Create will create a new Share based on the values in CreateOpts. To extract
    58  // the Share object from the response, call the Extract method on the
    59  // CreateResult.
    60  func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
    61  	b, err := opts.ToShareCreateMap()
    62  	if err != nil {
    63  		r.Err = err
    64  		return
    65  	}
    66  	resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
    67  		OkCodes: []int{200, 201},
    68  	})
    69  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
    70  	return
    71  }
    72  
    73  // ListOpts holds options for listing Shares. It is passed to the
    74  // shares.List function.
    75  type ListOpts struct {
    76  	// (Admin only). Defines whether to list the requested resources for all projects.
    77  	AllTenants bool `q:"all_tenants"`
    78  	// The share name.
    79  	Name string `q:"name"`
    80  	// Filters by a share status.
    81  	Status string `q:"status"`
    82  	// The UUID of the share server.
    83  	ShareServerID string `q:"share_server_id"`
    84  	// One or more metadata key and value pairs as a dictionary of strings.
    85  	Metadata map[string]string `q:"metadata"`
    86  	// The extra specifications for the share type.
    87  	ExtraSpecs map[string]string `q:"extra_specs"`
    88  	// The UUID of the share type.
    89  	ShareTypeID string `q:"share_type_id"`
    90  	// The maximum number of shares to return.
    91  	Limit int `q:"limit"`
    92  	// The offset to define start point of share or share group listing.
    93  	Offset int `q:"offset"`
    94  	// The key to sort a list of shares.
    95  	SortKey string `q:"sort_key"`
    96  	// The direction to sort a list of shares.
    97  	SortDir string `q:"sort_dir"`
    98  	// The UUID of the share’s base snapshot to filter the request based on.
    99  	SnapshotID string `q:"snapshot_id"`
   100  	// The share host name.
   101  	Host string `q:"host"`
   102  	// The share network ID.
   103  	ShareNetworkID string `q:"share_network_id"`
   104  	// The UUID of the project in which the share was created. Useful with all_tenants parameter.
   105  	ProjectID string `q:"project_id"`
   106  	// The level of visibility for the share.
   107  	IsPublic *bool `q:"is_public"`
   108  	// The UUID of a share group to filter resource.
   109  	ShareGroupID string `q:"share_group_id"`
   110  	// The export location UUID that can be used to filter shares or share instances.
   111  	ExportLocationID string `q:"export_location_id"`
   112  	// The export location path that can be used to filter shares or share instances.
   113  	ExportLocationPath string `q:"export_location_path"`
   114  	// The name pattern that can be used to filter shares, share snapshots, share networks or share groups.
   115  	NamePattern string `q:"name~"`
   116  	// The description pattern that can be used to filter shares, share snapshots, share networks or share groups.
   117  	DescriptionPattern string `q:"description~"`
   118  	// Whether to show count in API response or not, default is False.
   119  	WithCount bool `q:"with_count"`
   120  	// DisplayName is equivalent to Name. The API supports using both
   121  	// This is an inherited attribute from the block storage API
   122  	DisplayName string `q:"display_name"`
   123  	// Equivalent to NamePattern.
   124  	DisplayNamePattern string `q:"display_name~"`
   125  	// VolumeTypeID is deprecated but supported. Either ShareTypeID or VolumeTypeID can be used
   126  	VolumeTypeID string `q:"volume_type_id"`
   127  	// The UUID of the share group snapshot.
   128  	ShareGroupSnapshotID string `q:"share_group_snapshot_id"`
   129  	// DisplayDescription is equivalent to Description. The API supports using both
   130  	// This is an inherited attribute from the block storage API
   131  	DisplayDescription string `q:"display_description"`
   132  	// Equivalent to DescriptionPattern
   133  	DisplayDescriptionPattern string `q:"display_description~"`
   134  }
   135  
   136  // ListOptsBuilder allows extensions to add additional parameters to the List
   137  // request.
   138  type ListOptsBuilder interface {
   139  	ToShareListQuery() (string, error)
   140  }
   141  
   142  // ToShareListQuery formats a ListOpts into a query string.
   143  func (opts ListOpts) ToShareListQuery() (string, error) {
   144  	q, err := gophercloud.BuildQueryString(opts)
   145  	return q.String(), err
   146  }
   147  
   148  // ListDetail returns []Share optionally limited by the conditions provided in ListOpts.
   149  func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
   150  	url := listDetailURL(client)
   151  	if opts != nil {
   152  		query, err := opts.ToShareListQuery()
   153  		if err != nil {
   154  			return pagination.Pager{Err: err}
   155  		}
   156  		url += query
   157  	}
   158  
   159  	return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
   160  		p := SharePage{pagination.MarkerPageBase{PageResult: r}}
   161  		p.MarkerPageBase.Owner = p
   162  		return p
   163  	})
   164  }
   165  
   166  // Delete will delete an existing Share with the given UUID.
   167  func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
   168  	resp, err := client.Delete(deleteURL(client, id), nil)
   169  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   170  	return
   171  }
   172  
   173  // Get will get a single share with given UUID
   174  func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
   175  	resp, err := client.Get(getURL(client, id), &r.Body, nil)
   176  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   177  	return
   178  }
   179  
   180  // ListExportLocations will list shareID's export locations.
   181  // Client must have Microversion set; minimum supported microversion for ListExportLocations is 2.9.
   182  func ListExportLocations(client *gophercloud.ServiceClient, id string) (r ListExportLocationsResult) {
   183  	resp, err := client.Get(listExportLocationsURL(client, id), &r.Body, nil)
   184  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   185  	return
   186  }
   187  
   188  // GetExportLocation will get shareID's export location by an ID.
   189  // Client must have Microversion set; minimum supported microversion for GetExportLocation is 2.9.
   190  func GetExportLocation(client *gophercloud.ServiceClient, shareID string, id string) (r GetExportLocationResult) {
   191  	resp, err := client.Get(getExportLocationURL(client, shareID, id), &r.Body, nil)
   192  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   193  	return
   194  }
   195  
   196  // GrantAccessOptsBuilder allows extensions to add additional parameters to the
   197  // GrantAccess request.
   198  type GrantAccessOptsBuilder interface {
   199  	ToGrantAccessMap() (map[string]interface{}, error)
   200  }
   201  
   202  // GrantAccessOpts contains the options for creation of an GrantAccess request.
   203  // For more information about these parameters, please, refer to the shared file systems API v2,
   204  // Share Actions, Grant Access documentation
   205  type GrantAccessOpts struct {
   206  	// The access rule type that can be "ip", "cert" or "user".
   207  	AccessType string `json:"access_type"`
   208  	// The value that defines the access that can be a valid format of IP, cert or user.
   209  	AccessTo string `json:"access_to"`
   210  	// The access level to the share is either "rw" or "ro".
   211  	AccessLevel string `json:"access_level"`
   212  }
   213  
   214  // ToGrantAccessMap assembles a request body based on the contents of a
   215  // GrantAccessOpts.
   216  func (opts GrantAccessOpts) ToGrantAccessMap() (map[string]interface{}, error) {
   217  	return gophercloud.BuildRequestBody(opts, "allow_access")
   218  }
   219  
   220  // GrantAccess will grant access to a Share based on the values in GrantAccessOpts. To extract
   221  // the GrantAccess object from the response, call the Extract method on the GrantAccessResult.
   222  // Client must have Microversion set; minimum supported microversion for GrantAccess is 2.7.
   223  func GrantAccess(client *gophercloud.ServiceClient, id string, opts GrantAccessOptsBuilder) (r GrantAccessResult) {
   224  	b, err := opts.ToGrantAccessMap()
   225  	if err != nil {
   226  		r.Err = err
   227  		return
   228  	}
   229  	resp, err := client.Post(grantAccessURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
   230  		OkCodes: []int{200},
   231  	})
   232  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   233  	return
   234  }
   235  
   236  // RevokeAccessOptsBuilder allows extensions to add additional parameters to the
   237  // RevokeAccess request.
   238  type RevokeAccessOptsBuilder interface {
   239  	ToRevokeAccessMap() (map[string]interface{}, error)
   240  }
   241  
   242  // RevokeAccessOpts contains the options for creation of a RevokeAccess request.
   243  // For more information about these parameters, please, refer to the shared file systems API v2,
   244  // Share Actions, Revoke Access documentation
   245  type RevokeAccessOpts struct {
   246  	AccessID string `json:"access_id"`
   247  }
   248  
   249  // ToRevokeAccessMap assembles a request body based on the contents of a
   250  // RevokeAccessOpts.
   251  func (opts RevokeAccessOpts) ToRevokeAccessMap() (map[string]interface{}, error) {
   252  	return gophercloud.BuildRequestBody(opts, "deny_access")
   253  }
   254  
   255  // RevokeAccess will revoke an existing access to a Share based on the values in RevokeAccessOpts.
   256  // RevokeAccessResult contains only the error. To extract it, call the ExtractErr method on
   257  // the RevokeAccessResult. Client must have Microversion set; minimum supported microversion
   258  // for RevokeAccess is 2.7.
   259  func RevokeAccess(client *gophercloud.ServiceClient, id string, opts RevokeAccessOptsBuilder) (r RevokeAccessResult) {
   260  	b, err := opts.ToRevokeAccessMap()
   261  	if err != nil {
   262  		r.Err = err
   263  		return
   264  	}
   265  
   266  	resp, err := client.Post(revokeAccessURL(client, id), b, nil, &gophercloud.RequestOpts{
   267  		OkCodes: []int{200, 202},
   268  	})
   269  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   270  	return
   271  }
   272  
   273  // ListAccessRights lists all access rules assigned to a Share based on its id. To extract
   274  // the AccessRight slice from the response, call the Extract method on the ListAccessRightsResult.
   275  // Client must have Microversion set; minimum supported microversion for ListAccessRights is 2.7.
   276  func ListAccessRights(client *gophercloud.ServiceClient, id string) (r ListAccessRightsResult) {
   277  	requestBody := map[string]interface{}{"access_list": nil}
   278  	resp, err := client.Post(listAccessRightsURL(client, id), requestBody, &r.Body, &gophercloud.RequestOpts{
   279  		OkCodes: []int{200},
   280  	})
   281  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   282  	return
   283  }
   284  
   285  // ExtendOptsBuilder allows extensions to add additional parameters to the
   286  // Extend request.
   287  type ExtendOptsBuilder interface {
   288  	ToShareExtendMap() (map[string]interface{}, error)
   289  }
   290  
   291  // ExtendOpts contains options for extending a Share.
   292  // For more information about these parameters, please, refer to the shared file systems API v2,
   293  // Share Actions, Extend share documentation
   294  type ExtendOpts struct {
   295  	// New size in GBs.
   296  	NewSize int `json:"new_size"`
   297  }
   298  
   299  // ToShareExtendMap assembles a request body based on the contents of a
   300  // ExtendOpts.
   301  func (opts ExtendOpts) ToShareExtendMap() (map[string]interface{}, error) {
   302  	return gophercloud.BuildRequestBody(opts, "extend")
   303  }
   304  
   305  // Extend will extend the capacity of an existing share. ExtendResult contains only the error.
   306  // To extract it, call the ExtractErr method on the ExtendResult.
   307  // Client must have Microversion set; minimum supported microversion for Extend is 2.7.
   308  func Extend(client *gophercloud.ServiceClient, id string, opts ExtendOptsBuilder) (r ExtendResult) {
   309  	b, err := opts.ToShareExtendMap()
   310  	if err != nil {
   311  		r.Err = err
   312  		return
   313  	}
   314  
   315  	resp, err := client.Post(extendURL(client, id), b, nil, &gophercloud.RequestOpts{
   316  		OkCodes: []int{202},
   317  	})
   318  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   319  	return
   320  }
   321  
   322  // ShrinkOptsBuilder allows extensions to add additional parameters to the
   323  // Shrink request.
   324  type ShrinkOptsBuilder interface {
   325  	ToShareShrinkMap() (map[string]interface{}, error)
   326  }
   327  
   328  // ShrinkOpts contains options for shrinking a Share.
   329  // For more information about these parameters, please, refer to the shared file systems API v2,
   330  // Share Actions, Shrink share documentation
   331  type ShrinkOpts struct {
   332  	// New size in GBs.
   333  	NewSize int `json:"new_size"`
   334  }
   335  
   336  // ToShareShrinkMap assembles a request body based on the contents of a
   337  // ShrinkOpts.
   338  func (opts ShrinkOpts) ToShareShrinkMap() (map[string]interface{}, error) {
   339  	return gophercloud.BuildRequestBody(opts, "shrink")
   340  }
   341  
   342  // Shrink will shrink the capacity of an existing share. ShrinkResult contains only the error.
   343  // To extract it, call the ExtractErr method on the ShrinkResult.
   344  // Client must have Microversion set; minimum supported microversion for Shrink is 2.7.
   345  func Shrink(client *gophercloud.ServiceClient, id string, opts ShrinkOptsBuilder) (r ShrinkResult) {
   346  	b, err := opts.ToShareShrinkMap()
   347  	if err != nil {
   348  		r.Err = err
   349  		return
   350  	}
   351  
   352  	resp, err := client.Post(shrinkURL(client, id), b, nil, &gophercloud.RequestOpts{
   353  		OkCodes: []int{202},
   354  	})
   355  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   356  	return
   357  }
   358  
   359  // UpdateOptsBuilder allows extensions to add additional parameters to the
   360  // Update request.
   361  type UpdateOptsBuilder interface {
   362  	ToShareUpdateMap() (map[string]interface{}, error)
   363  }
   364  
   365  // UpdateOpts contain options for updating an existing Share. This object is passed
   366  // to the share.Update function. For more information about the parameters, see
   367  // the Share object.
   368  type UpdateOpts struct {
   369  	// Share name. Manila share update logic doesn't have a "name" alias.
   370  	DisplayName *string `json:"display_name,omitempty"`
   371  	// Share description. Manila share update logic doesn't have a "description" alias.
   372  	DisplayDescription *string `json:"display_description,omitempty"`
   373  	// Determines whether or not the share is public
   374  	IsPublic *bool `json:"is_public,omitempty"`
   375  }
   376  
   377  // ToShareUpdateMap assembles a request body based on the contents of an
   378  // UpdateOpts.
   379  func (opts UpdateOpts) ToShareUpdateMap() (map[string]interface{}, error) {
   380  	return gophercloud.BuildRequestBody(opts, "share")
   381  }
   382  
   383  // Update will update the Share with provided information. To extract the updated
   384  // Share from the response, call the Extract method on the UpdateResult.
   385  func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) {
   386  	b, err := opts.ToShareUpdateMap()
   387  	if err != nil {
   388  		r.Err = err
   389  		return
   390  	}
   391  	resp, err := client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
   392  		OkCodes: []int{200},
   393  	})
   394  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   395  	return
   396  }
   397  
   398  // GetMetadata retrieves metadata of the specified share. To extract the retrieved
   399  // metadata from the response, call the Extract method on the MetadataResult.
   400  func GetMetadata(client *gophercloud.ServiceClient, id string) (r MetadataResult) {
   401  	resp, err := client.Get(getMetadataURL(client, id), &r.Body, nil)
   402  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   403  	return
   404  }
   405  
   406  // GetMetadatum retrieves a single metadata item of the specified share. To extract the retrieved
   407  // metadata from the response, call the Extract method on the GetMetadatumResult.
   408  func GetMetadatum(client *gophercloud.ServiceClient, id, key string) (r GetMetadatumResult) {
   409  	resp, err := client.Get(getMetadatumURL(client, id, key), &r.Body, nil)
   410  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   411  	return
   412  }
   413  
   414  // SetMetadataOpts contains options for setting share metadata.
   415  // For more information about these parameters, please, refer to the shared file systems API v2,
   416  // Share Metadata, Show share metadata documentation.
   417  type SetMetadataOpts struct {
   418  	Metadata map[string]string `json:"metadata"`
   419  }
   420  
   421  // ToSetMetadataMap assembles a request body based on the contents of an
   422  // SetMetadataOpts.
   423  func (opts SetMetadataOpts) ToSetMetadataMap() (map[string]interface{}, error) {
   424  	return gophercloud.BuildRequestBody(opts, "")
   425  }
   426  
   427  // SetMetadataOptsBuilder allows extensions to add additional parameters to the
   428  // SetMetadata request.
   429  type SetMetadataOptsBuilder interface {
   430  	ToSetMetadataMap() (map[string]interface{}, error)
   431  }
   432  
   433  // SetMetadata sets metadata of the specified share.
   434  // Existing metadata items are either kept or overwritten by the metadata from the request.
   435  // To extract the updated metadata from the response, call the Extract
   436  // method on the MetadataResult.
   437  func SetMetadata(client *gophercloud.ServiceClient, id string, opts SetMetadataOptsBuilder) (r MetadataResult) {
   438  	b, err := opts.ToSetMetadataMap()
   439  	if err != nil {
   440  		r.Err = err
   441  		return
   442  	}
   443  
   444  	resp, err := client.Post(setMetadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
   445  		OkCodes: []int{200},
   446  	})
   447  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   448  	return
   449  }
   450  
   451  // UpdateMetadataOpts contains options for updating share metadata.
   452  // For more information about these parameters, please, refer to the shared file systems API v2,
   453  // Share Metadata, Update share metadata documentation.
   454  type UpdateMetadataOpts struct {
   455  	Metadata map[string]string `json:"metadata"`
   456  }
   457  
   458  // ToUpdateMetadataMap assembles a request body based on the contents of an
   459  // UpdateMetadataOpts.
   460  func (opts UpdateMetadataOpts) ToUpdateMetadataMap() (map[string]interface{}, error) {
   461  	return gophercloud.BuildRequestBody(opts, "")
   462  }
   463  
   464  // UpdateMetadataOptsBuilder allows extensions to add additional parameters to the
   465  // UpdateMetadata request.
   466  type UpdateMetadataOptsBuilder interface {
   467  	ToUpdateMetadataMap() (map[string]interface{}, error)
   468  }
   469  
   470  // UpdateMetadata updates metadata of the specified share.
   471  // All existing metadata items are discarded and replaced by the metadata from the request.
   472  // To extract the updated metadata from the response, call the Extract
   473  // method on the MetadataResult.
   474  func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts UpdateMetadataOptsBuilder) (r MetadataResult) {
   475  	b, err := opts.ToUpdateMetadataMap()
   476  	if err != nil {
   477  		r.Err = err
   478  		return
   479  	}
   480  
   481  	resp, err := client.Post(updateMetadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
   482  		OkCodes: []int{200},
   483  	})
   484  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   485  	return
   486  }
   487  
   488  // DeleteMetadatum deletes a single key-value pair from the metadata of the specified share.
   489  func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) (r DeleteMetadatumResult) {
   490  	resp, err := client.Delete(deleteMetadatumURL(client, id, key), &gophercloud.RequestOpts{
   491  		OkCodes: []int{200},
   492  	})
   493  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   494  	return
   495  }
   496  
   497  // RevertOptsBuilder allows extensions to add additional parameters to the
   498  // Revert request.
   499  type RevertOptsBuilder interface {
   500  	ToShareRevertMap() (map[string]interface{}, error)
   501  }
   502  
   503  // RevertOpts contains options for reverting a Share to a snapshot.
   504  // For more information about these parameters, please, refer to the shared file systems API v2,
   505  // Share Actions, Revert share documentation.
   506  // Available only since Manila Microversion 2.27
   507  type RevertOpts struct {
   508  	// SnapshotID is a Snapshot ID to revert a Share to
   509  	SnapshotID string `json:"snapshot_id"`
   510  }
   511  
   512  // ToShareRevertMap assembles a request body based on the contents of a
   513  // RevertOpts.
   514  func (opts RevertOpts) ToShareRevertMap() (map[string]interface{}, error) {
   515  	return gophercloud.BuildRequestBody(opts, "revert")
   516  }
   517  
   518  // Revert will revert the existing share to a Snapshot. RevertResult contains only the error.
   519  // To extract it, call the ExtractErr method on the RevertResult.
   520  // Client must have Microversion set; minimum supported microversion for Revert is 2.27.
   521  func Revert(client *gophercloud.ServiceClient, id string, opts RevertOptsBuilder) (r RevertResult) {
   522  	b, err := opts.ToShareRevertMap()
   523  	if err != nil {
   524  		r.Err = err
   525  		return
   526  	}
   527  
   528  	resp, err := client.Post(revertURL(client, id), b, nil, &gophercloud.RequestOpts{
   529  		OkCodes: []int{202},
   530  	})
   531  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   532  	return
   533  }
   534  
   535  // ResetStatusOptsBuilder allows extensions to add additional parameters to the
   536  // ResetStatus request.
   537  type ResetStatusOptsBuilder interface {
   538  	ToShareResetStatusMap() (map[string]interface{}, error)
   539  }
   540  
   541  // ResetStatusOpts contains options for resetting a Share status.
   542  // For more information about these parameters, please, refer to the shared file systems API v2,
   543  // Share Actions, ResetStatus share documentation.
   544  type ResetStatusOpts struct {
   545  	// Status is a share status to reset to. Must be "new", "error" or "active".
   546  	Status string `json:"status"`
   547  }
   548  
   549  // ToShareResetStatusMap assembles a request body based on the contents of a
   550  // ResetStatusOpts.
   551  func (opts ResetStatusOpts) ToShareResetStatusMap() (map[string]interface{}, error) {
   552  	return gophercloud.BuildRequestBody(opts, "reset_status")
   553  }
   554  
   555  // ResetStatus will reset the existing share status. ResetStatusResult contains only the error.
   556  // To extract it, call the ExtractErr method on the ResetStatusResult.
   557  // Client must have Microversion set; minimum supported microversion for ResetStatus is 2.7.
   558  func ResetStatus(client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult) {
   559  	b, err := opts.ToShareResetStatusMap()
   560  	if err != nil {
   561  		r.Err = err
   562  		return
   563  	}
   564  
   565  	resp, err := client.Post(resetStatusURL(client, id), b, nil, &gophercloud.RequestOpts{
   566  		OkCodes: []int{202},
   567  	})
   568  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   569  	return
   570  }
   571  
   572  // ForceDelete will delete the existing share in any state. ForceDeleteResult contains only the error.
   573  // To extract it, call the ExtractErr method on the ForceDeleteResult.
   574  // Client must have Microversion set; minimum supported microversion for ForceDelete is 2.7.
   575  func ForceDelete(client *gophercloud.ServiceClient, id string) (r ForceDeleteResult) {
   576  	b := map[string]interface{}{
   577  		"force_delete": nil,
   578  	}
   579  	resp, err := client.Post(forceDeleteURL(client, id), b, nil, &gophercloud.RequestOpts{
   580  		OkCodes: []int{202},
   581  	})
   582  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   583  	return
   584  }
   585  
   586  // Unmanage will remove a share from the management of the Shared File System
   587  // service without deleting the share. UnmanageResult contains only the error.
   588  // To extract it, call the ExtractErr method on the UnmanageResult.
   589  // Client must have Microversion set; minimum supported microversion for Unmanage is 2.7.
   590  func Unmanage(client *gophercloud.ServiceClient, id string) (r UnmanageResult) {
   591  	b := map[string]interface{}{
   592  		"unmanage": nil,
   593  	}
   594  	resp, err := client.Post(unmanageURL(client, id), b, nil, &gophercloud.RequestOpts{
   595  		OkCodes: []int{202},
   596  	})
   597  	_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
   598  	return
   599  }