Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, options):
"""Abstracts libmongocrypt's mongocrypt_t type.
:Parameters:
- `options`: A :class:`MongoCryptOptions`.
"""
self.__opts = options
self.__crypt = None
if not isinstance(options, MongoCryptOptions):
raise TypeError("options must be a MongoCryptOptions")
self.__crypt = lib.mongocrypt_new()
if self.__crypt == ffi.NULL:
raise MongoCryptError("unable to create new mongocrypt object")
try:
self.__init()
except Exception:
# Destroy the mongocrypt object on error.
self.close()
raise
def endpoint(self):
"""The kms hostname to connect over TLS."""
p = ffi.new("char *[]", 1)
try:
if not lib.mongocrypt_kms_ctx_endpoint(self.__ctx, p):
self.__raise_from_status()
return _to_string(p[0])
finally:
ffi.release(p)
def endpoint(self):
"""The kms hostname to connect over TLS."""
p = ffi.new("char *[]", 1)
try:
if not lib.mongocrypt_kms_ctx_endpoint(self.__ctx, p):
self.__raise_from_status()
return _to_string(p[0])
finally:
ffi.release(p)
def _create_context(self):
"""Returns a new mongocrypt_ctx_t"""
ctx = lib.mongocrypt_ctx_new(self.__crypt)
if ctx == ffi.NULL:
self.__raise_from_status()
return ctx