...
1
2
3
4
5
6
7 package options
8
9 import (
10 "go.mongodb.org/mongo-driver/bson/primitive"
11 "go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
12 )
13
14
15 type DataKeyOptions struct {
16 KeyAltNames []string
17 KeyMaterial []byte
18 MasterKey bsoncore.Document
19 }
20
21
22 func DataKey() *DataKeyOptions {
23 return &DataKeyOptions{}
24 }
25
26
27 func (dko *DataKeyOptions) SetKeyAltNames(names []string) *DataKeyOptions {
28 dko.KeyAltNames = names
29 return dko
30 }
31
32
33 func (dko *DataKeyOptions) SetMasterKey(key bsoncore.Document) *DataKeyOptions {
34 dko.MasterKey = key
35 return dko
36 }
37
38
39 func (dko *DataKeyOptions) SetKeyMaterial(keyMaterial []byte) *DataKeyOptions {
40 dko.KeyMaterial = keyMaterial
41 return dko
42 }
43
44
45 type QueryType int
46
47
48 const (
49 QueryTypeEquality QueryType = 1
50 )
51
52
53 type ExplicitEncryptionOptions struct {
54 KeyID *primitive.Binary
55 KeyAltName *string
56 Algorithm string
57 QueryType string
58 ContentionFactor *int64
59 RangeOptions *ExplicitRangeOptions
60 }
61
62
63 type ExplicitRangeOptions struct {
64 Min *bsoncore.Value
65 Max *bsoncore.Value
66 Sparsity int64
67 Precision *int32
68 }
69
70
71 func ExplicitEncryption() *ExplicitEncryptionOptions {
72 return &ExplicitEncryptionOptions{}
73 }
74
75
76 func (eeo *ExplicitEncryptionOptions) SetKeyID(keyID primitive.Binary) *ExplicitEncryptionOptions {
77 eeo.KeyID = &keyID
78 return eeo
79 }
80
81
82 func (eeo *ExplicitEncryptionOptions) SetKeyAltName(keyAltName string) *ExplicitEncryptionOptions {
83 eeo.KeyAltName = &keyAltName
84 return eeo
85 }
86
87
88 func (eeo *ExplicitEncryptionOptions) SetAlgorithm(algorithm string) *ExplicitEncryptionOptions {
89 eeo.Algorithm = algorithm
90 return eeo
91 }
92
93
94 func (eeo *ExplicitEncryptionOptions) SetQueryType(queryType string) *ExplicitEncryptionOptions {
95 eeo.QueryType = queryType
96 return eeo
97 }
98
99
100 func (eeo *ExplicitEncryptionOptions) SetContentionFactor(contentionFactor int64) *ExplicitEncryptionOptions {
101 eeo.ContentionFactor = &contentionFactor
102 return eeo
103 }
104
105
106 func (eeo *ExplicitEncryptionOptions) SetRangeOptions(ro ExplicitRangeOptions) *ExplicitEncryptionOptions {
107 eeo.RangeOptions = &ro
108 return eeo
109 }
110
111
112
113 type RewrapManyDataKeyOptions struct {
114
115 Provider *string
116
117
118 MasterKey bsoncore.Document
119 }
120
121
122 func RewrapManyDataKey() *RewrapManyDataKeyOptions {
123 return new(RewrapManyDataKeyOptions)
124 }
125
126
127 func (rmdko *RewrapManyDataKeyOptions) SetProvider(provider string) *RewrapManyDataKeyOptions {
128 rmdko.Provider = &provider
129 return rmdko
130 }
131
132
133 func (rmdko *RewrapManyDataKeyOptions) SetMasterKey(masterKey bsoncore.Document) *RewrapManyDataKeyOptions {
134 rmdko.MasterKey = masterKey
135 return rmdko
136 }
137
138
139
140
141
142
143 func MergeRewrapManyDataKeyOptions(opts ...*RewrapManyDataKeyOptions) *RewrapManyDataKeyOptions {
144 rmdkOpts := RewrapManyDataKey()
145 for _, rmdko := range opts {
146 if rmdko == nil {
147 continue
148 }
149 if provider := rmdko.Provider; provider != nil {
150 rmdkOpts.Provider = provider
151 }
152 if masterKey := rmdko.MasterKey; masterKey != nil {
153 rmdkOpts.MasterKey = masterKey
154 }
155 }
156 return rmdkOpts
157 }
158
View as plain text