...

Source file src/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options/mongocrypt_options.go

Documentation: go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options

     1  // Copyright (C) MongoDB, Inc. 2017-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  import (
    10  	"net/http"
    11  
    12  	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
    13  )
    14  
    15  // MongoCryptOptions specifies options to configure a MongoCrypt instance.
    16  type MongoCryptOptions struct {
    17  	KmsProviders               bsoncore.Document
    18  	LocalSchemaMap             map[string]bsoncore.Document
    19  	BypassQueryAnalysis        bool
    20  	EncryptedFieldsMap         map[string]bsoncore.Document
    21  	CryptSharedLibDisabled     bool
    22  	CryptSharedLibOverridePath string
    23  	HTTPClient                 *http.Client
    24  }
    25  
    26  // MongoCrypt creates a new MongoCryptOptions instance.
    27  func MongoCrypt() *MongoCryptOptions {
    28  	return &MongoCryptOptions{}
    29  }
    30  
    31  // SetKmsProviders specifies the KMS providers map.
    32  func (mo *MongoCryptOptions) SetKmsProviders(kmsProviders bsoncore.Document) *MongoCryptOptions {
    33  	mo.KmsProviders = kmsProviders
    34  	return mo
    35  }
    36  
    37  // SetLocalSchemaMap specifies the local schema map.
    38  func (mo *MongoCryptOptions) SetLocalSchemaMap(localSchemaMap map[string]bsoncore.Document) *MongoCryptOptions {
    39  	mo.LocalSchemaMap = localSchemaMap
    40  	return mo
    41  }
    42  
    43  // SetBypassQueryAnalysis skips the NeedMongoMarkings state.
    44  func (mo *MongoCryptOptions) SetBypassQueryAnalysis(bypassQueryAnalysis bool) *MongoCryptOptions {
    45  	mo.BypassQueryAnalysis = bypassQueryAnalysis
    46  	return mo
    47  }
    48  
    49  // SetEncryptedFieldsMap specifies the encrypted fields map.
    50  func (mo *MongoCryptOptions) SetEncryptedFieldsMap(efcMap map[string]bsoncore.Document) *MongoCryptOptions {
    51  	mo.EncryptedFieldsMap = efcMap
    52  	return mo
    53  }
    54  
    55  // SetCryptSharedLibDisabled explicitly disables loading the crypt_shared library if set to true.
    56  func (mo *MongoCryptOptions) SetCryptSharedLibDisabled(disabled bool) *MongoCryptOptions {
    57  	mo.CryptSharedLibDisabled = disabled
    58  	return mo
    59  }
    60  
    61  // SetCryptSharedLibOverridePath sets the override path to the crypt_shared library file. Setting
    62  // an override path disables the default operating system dynamic library search path.
    63  func (mo *MongoCryptOptions) SetCryptSharedLibOverridePath(path string) *MongoCryptOptions {
    64  	mo.CryptSharedLibOverridePath = path
    65  	return mo
    66  }
    67  
    68  // SetHTTPClient sets the http client.
    69  func (mo *MongoCryptOptions) SetHTTPClient(httpClient *http.Client) *MongoCryptOptions {
    70  	mo.HTTPClient = httpClient
    71  	return mo
    72  }
    73  

View as plain text