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