Class: Mongo::Crypt::ExplicitEncryptionContext Private

Inherits:
Context
  • Object
show all
Defined in:
build/ruby-driver-v2.19/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 RangePreview 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”, “RangePreview”.

  • :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 “RangePreview”. Allowed values are “equality” and “rangePreview”.

  • :range_opts (Hash | nil)

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

    • :min

    • :max

    • :sparsity

    • :precision

    min, max, sparsity, and range 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:



66
67
68
69
70
71
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/explicit_encryption_context.rb', line 66

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.



73
74
75
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/explicit_encryption_context.rb', line 73

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