Class: Mongo::Crypt::ExplicitEncryptionContext Private

Inherits:
Context
  • Object
show all
Defined in:
lib/mongo/crypt/explicit_encryption_context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A Context object initialized for explicit encryption

Direct Known Subclasses

ExplicitEncryptionExpressionContext

Instance Attribute Summary

Attributes inherited from Context

#ctx_p

Instance Method Summary collapse

Methods inherited from Context

#run_state_machine, #state

Constructor Details

#initialize(mongocrypt, io, doc, options = {}) ⇒ ExplicitEncryptionContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

The Range algorithm is experimental only. It is not intended for

Create a new ExplicitEncryptionContext object

public use.

Parameters:

  • mongocrypt (Mongo::Crypt::Handle)

    a Handle that wraps a mongocrypt_t object used to create a new mongocrypt_ctx_t

  • io (ClientEncryption::IO)

    A instance of the IO class that implements driver I/O methods required to run the state machine

  • doc (BSON::Document)

    A document to encrypt

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :key_id (BSON::Binary)

    A BSON::Binary object of type :uuid representing the UUID of the data key to use for encryption.

  • :key_alt_name (String)

    The alternate name of the data key that will be used to encrypt the value.

  • :algorithm (String)

    The algorithm used to encrypt the value. Valid algorithms are “AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic”, “AEAD_AES_256_CBC_HMAC_SHA_512-Random”, “Indexed”, “Unindexed”, “Range”.

  • :contention_factor (Integer | nil)

    Contention factor to be applied if encryption algorithm is set to “Indexed”. If not provided, it defaults to a value of 0. Contention factor should be set only if encryption algorithm is set to “Indexed”.

  • query_type (String | nil)

    Query type to be applied if encryption algorithm is set to “Indexed” or “Range”. Allowed values are “equality” and “range”.

  • :range_opts (Hash | nil)

    Specifies index options for a Queryable Encryption field supporting “range” queries. Allowed options are:

    • :min

    • :max

    • :trim_factor

    • :sparsity

    • :precision

    min, max, trim_factor, sparsity, and precision must match the values set in the encryptedFields of the destination collection. For double and decimal128, min/max/precision must all be set, or all be unset.

Raises:



67
68
69
70
71
72
# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 67

def initialize(mongocrypt, io, doc, options = {})
  super(mongocrypt, io)
  set_key_opts(options)
  set_algorithm_opts(options)
  init(doc)
end

Instance Method Details

#init(doc) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



74
75
76
# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 74

def init(doc)
  Binding.ctx_explicit_encrypt_init(self, doc)
end