1 // Copyright (C) MongoDB, Inc. 2022-present. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 7 package options 8 9 // RewrapManyDataKeyOptions represents all possible options used to decrypt and encrypt all matching data keys with a 10 // possibly new masterKey. 11 type RewrapManyDataKeyOptions struct { 12 // Provider identifies the new KMS provider. If omitted, encrypting uses the current KMS provider. 13 Provider *string 14 15 // MasterKey identifies the new masterKey. If omitted, rewraps with the current masterKey. 16 MasterKey interface{} 17 } 18 19 // RewrapManyDataKey creates a new RewrapManyDataKeyOptions instance. 20 func RewrapManyDataKey() *RewrapManyDataKeyOptions { 21 return new(RewrapManyDataKeyOptions) 22 } 23 24 // SetProvider sets the value for the Provider field. 25 func (rmdko *RewrapManyDataKeyOptions) SetProvider(provider string) *RewrapManyDataKeyOptions { 26 rmdko.Provider = &provider 27 return rmdko 28 } 29 30 // SetMasterKey sets the value for the MasterKey field. 31 func (rmdko *RewrapManyDataKeyOptions) SetMasterKey(masterKey interface{}) *RewrapManyDataKeyOptions { 32 rmdko.MasterKey = masterKey 33 return rmdko 34 } 35 36 // MergeRewrapManyDataKeyOptions combines the given RewrapManyDataKeyOptions instances into a single 37 // RewrapManyDataKeyOptions in a last one wins fashion. 38 // 39 // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a 40 // single options struct instead. 41 func MergeRewrapManyDataKeyOptions(opts ...*RewrapManyDataKeyOptions) *RewrapManyDataKeyOptions { 42 rmdkOpts := RewrapManyDataKey() 43 for _, rmdko := range opts { 44 if rmdko == nil { 45 continue 46 } 47 if provider := rmdko.Provider; provider != nil { 48 rmdkOpts.Provider = provider 49 } 50 if masterKey := rmdko.MasterKey; masterKey != nil { 51 rmdkOpts.MasterKey = masterKey 52 } 53 } 54 return rmdkOpts 55 } 56