@@ -304,3 +304,108 @@ func RemoveAccess(client *gophercloud.ServiceClient, id string, opts RemoveAcces
304304 _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
305305 return
306306}
307+
308+ // CreateEncryptionOptsBuilder allows extensions to add additional parameters to the
309+ // Create Encryption request.
310+ type CreateEncryptionOptsBuilder interface {
311+ ToEncryptionCreateMap () (map [string ]interface {}, error )
312+ }
313+
314+ // CreateEncryptionOpts contains options for creating an Encryption Type object.
315+ // This object is passed to the volumetypes.CreateEncryption function.
316+ // For more information about these parameters,see the Encryption Type object.
317+ type CreateEncryptionOpts struct {
318+ // The size of the encryption key.
319+ KeySize int `json:"key_size"`
320+ // The class of that provides the encryption support.
321+ Provider string `json:"provider" required:"true"`
322+ // Notional service where encryption is performed.
323+ ControlLocation string `json:"control_location"`
324+ // The encryption algorithm or mode.
325+ Cipher string `json:"cipher"`
326+ }
327+
328+ // ToEncryptionCreateMap assembles a request body based on the contents of a
329+ // CreateEncryptionOpts.
330+ func (opts CreateEncryptionOpts ) ToEncryptionCreateMap () (map [string ]interface {}, error ) {
331+ return gophercloud .BuildRequestBody (opts , "encryption" )
332+ }
333+
334+ // CreateEncryption will creates an Encryption Type object based on the CreateEncryptionOpts.
335+ // To extract the Encryption Type object from the response, call the Extract method on the
336+ // EncryptionCreateResult.
337+ func CreateEncryption (client * gophercloud.ServiceClient , id string , opts CreateEncryptionOptsBuilder ) (r CreateEncryptionResult ) {
338+ b , err := opts .ToEncryptionCreateMap ()
339+ if err != nil {
340+ r .Err = err
341+ return
342+ }
343+ resp , err := client .Post (createEncryptionURL (client , id ), b , & r .Body , & gophercloud.RequestOpts {
344+ OkCodes : []int {200 },
345+ })
346+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
347+ return
348+ }
349+
350+ // Delete will delete an encryption type for an existing Volume Type with the provided ID.
351+ func DeleteEncryption (client * gophercloud.ServiceClient , id , encryptionID string ) (r DeleteEncryptionResult ) {
352+ resp , err := client .Delete (deleteEncryptionURL (client , id , encryptionID ), nil )
353+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
354+ return
355+ }
356+
357+ // GetEncryption retrieves the encryption type for an existing VolumeType with the provided ID.
358+ func GetEncryption (client * gophercloud.ServiceClient , id string ) (r GetEncryptionResult ) {
359+ resp , err := client .Get (getEncryptionURL (client , id ), & r .Body , nil )
360+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
361+ return
362+ }
363+
364+ // GetEncryptionSpecs retrieves the encryption type specs for an existing VolumeType with the provided ID.
365+ func GetEncryptionSpec (client * gophercloud.ServiceClient , id , key string ) (r GetEncryptionSpecResult ) {
366+ resp , err := client .Get (getEncryptionSpecURL (client , id , key ), & r .Body , nil )
367+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
368+ return
369+ }
370+
371+ // UpdateEncryptionOptsBuilder allows extensions to add additional parameters to the
372+ // Update encryption request.
373+ type UpdateEncryptionOptsBuilder interface {
374+ ToUpdateEncryptionMap () (map [string ]interface {}, error )
375+ }
376+
377+ // Update Encryption Opts contains options for creating an Update Encryption Type. This object is passed to
378+ // the volumetypes.UpdateEncryption function. For more information about these parameters,
379+ // see the Update Encryption Type object.
380+ type UpdateEncryptionOpts struct {
381+ // The size of the encryption key.
382+ KeySize int `json:"key_size"`
383+ // The class of that provides the encryption support.
384+ Provider string `json:"provider"`
385+ // Notional service where encryption is performed.
386+ ControlLocation string `json:"control_location"`
387+ // The encryption algorithm or mode.
388+ Cipher string `json:"cipher"`
389+ }
390+
391+ // ToEncryptionCreateMap assembles a request body based on the contents of a
392+ // UpdateEncryptionOpts.
393+ func (opts UpdateEncryptionOpts ) ToUpdateEncryptionMap () (map [string ]interface {}, error ) {
394+ return gophercloud .BuildRequestBody (opts , "encryption" )
395+ }
396+
397+ // Update will update an existing encryption for a Volume Type based on the values in UpdateEncryptionOpts.
398+ // To extract the UpdateEncryption Type object from the response, call the Extract method on the
399+ // UpdateEncryptionResult.
400+ func UpdateEncryption (client * gophercloud.ServiceClient , id , encryptionID string , opts UpdateEncryptionOptsBuilder ) (r UpdateEncryptionResult ) {
401+ b , err := opts .ToUpdateEncryptionMap ()
402+ if err != nil {
403+ r .Err = err
404+ return
405+ }
406+ resp , err := client .Put (updateEncryptionURL (client , id , encryptionID ), b , & r .Body , & gophercloud.RequestOpts {
407+ OkCodes : []int {200 },
408+ })
409+ _ , r .Header , r .Err = gophercloud .ParseResponse (resp , err )
410+ return
411+ }
0 commit comments