# Path: cloudify_secrets/sdk.py
# class SecretsSDK(object):
# 
#     DEFAULT_SEPARATOR = '__'
# 
#     @staticmethod
#     def _try_to_serialize(value):
#         if isinstance(value, (dict, list, tuple)):
#             return json.dumps(value)
# 
#         return str(value)
# 
#     @staticmethod
#     def _try_to_parse(value):
#         try:
#             return json.loads(value)
#         except ValueError:
#             return value
# 
#     def __init__(self, logger, rest_client, separator=DEFAULT_SEPARATOR, **_):
#         self._logger = logger
#         self._rest_client = rest_client
#         self._separator = separator
# 
#     def _handle_variant(self, key, variant=None):
#         if variant:
#             return '{0}{1}{2}'.format(key, self._separator, variant)
# 
#         return key
# 
#     def _write(self, rest_client_method, entries, variant=None):
#         result = {}
# 
#         for key, value in entries.items():
#             self._logger.debug(
#                 'Creating secret "{0}" with value: {1}'
#                 .format(key, value)
#             )
# 
#             result[key] = rest_client_method(
#                 key=self._handle_variant(key, variant),
#                 value=self._try_to_serialize(value)
#             )
# 
#         return result
# 
#     def create(self, entries, variant=None, **_):
#         return self._write(self._rest_client.secrets.create, entries, variant)
# 
#     def update(self, entries, variant=None, **_):
#         return self._write(self._rest_client.secrets.patch, entries, variant)
# 
#     def delete(self, secrets, variant=None, **_):
#         for key in secrets.keys():
#             self._logger.debug(
#                 'Deleting secret "{0}" ...'.format(key)
#             )
# 
#             self._rest_client.secrets.delete(
#                 key=self._handle_variant(key, variant)
#             )
# 
#     def read(self, keys, variant=None, **_):
#         result = {}
# 
#         for key in keys:
#             self._logger.debug('Reading secret "{0}" ...'.format(key))
# 
#             response = self._rest_client.secrets.get(
#                 key=self._handle_variant(key, variant)
#             )
# 
#             response['value'] = self._try_to_parse(response['value'])
#             result[key] = response
# 
#         return result


from cloudify.decorators import operation
from cloudify.manager import get_rest_client
from .sdk import SecretsSDK
        False
    )
    ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY] = result


@operation(resumable=True)
def update(ctx, **kwargs):
    parameters = _get_parameters(ctx.node.properties, kwargs)

    result = SecretsSDK(ctx.logger, get_rest_client(), **parameters).update(
        **parameters
    )

    ctx.instance.runtime_properties[DO_NOT_DELETE_PROPERTY] = parameters.get(
        DO_NOT_DELETE_PROPERTY,
        False
    )
    ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY] = result


@operation(resumable=True)
def delete(ctx, **kwargs):
    if ctx.instance.runtime_properties.get(DO_NOT_DELETE_PROPERTY, False):
        ctx.logger.info(
            '"do_not_delete" property set to <true> - skipping deletion ...'
        )
    else:
        parameters = _get_parameters(ctx.node.properties, kwargs)
        secrets = ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY]


# Path: cloudify_secrets/sdk.py
# class SecretsSDK(object):
# 
#     DEFAULT_SEPARATOR = '__'
# 
#     @staticmethod
#     def _try_to_serialize(value):
#         if isinstance(value, (dict, list, tuple)):
#             return json.dumps(value)
# 
#         return str(value)
# 
#     @staticmethod
#     def _try_to_parse(value):
#         try:
#             return json.loads(value)
#         except ValueError:
#             return value
# 
#     def __init__(self, logger, rest_client, separator=DEFAULT_SEPARATOR, **_):
#         self._logger = logger
#         self._rest_client = rest_client
#         self._separator = separator
# 
#     def _handle_variant(self, key, variant=None):
#         if variant:
#             return '{0}{1}{2}'.format(key, self._separator, variant)
# 
#         return key
# 
#     def _write(self, rest_client_method, entries, variant=None):
#         result = {}
# 
#         for key, value in entries.items():
#             self._logger.debug(
#                 'Creating secret "{0}" with value: {1}'
#                 .format(key, value)
#             )
# 
#             result[key] = rest_client_method(
#                 key=self._handle_variant(key, variant),
#                 value=self._try_to_serialize(value)
#             )
# 
#         return result
# 
#     def create(self, entries, variant=None, **_):
#         return self._write(self._rest_client.secrets.create, entries, variant)
# 
#     def update(self, entries, variant=None, **_):
#         return self._write(self._rest_client.secrets.patch, entries, variant)
# 
#     def delete(self, secrets, variant=None, **_):
#         for key in secrets.keys():
#             self._logger.debug(
#                 'Deleting secret "{0}" ...'.format(key)
#             )
# 
#             self._rest_client.secrets.delete(
#                 key=self._handle_variant(key, variant)
#             )
# 
#     def read(self, keys, variant=None, **_):
#         result = {}
# 
#         for key in keys:
#             self._logger.debug('Reading secret "{0}" ...'.format(key))
# 
#             response = self._rest_client.secrets.get(
#                 key=self._handle_variant(key, variant)
#             )
# 
#             response['value'] = self._try_to_parse(response['value'])
#             result[key] = response
# 
#         return result


# Path: cloudify_secrets/tasks.py
from cloudify.decorators import operation
from cloudify.manager import get_rest_client
from .sdk import SecretsSDK

        False
    )
    ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY] = result


@operation(resumable=True)
def update(ctx, **kwargs):
    parameters = _get_parameters(ctx.node.properties, kwargs)

    result = SecretsSDK(ctx.logger, get_rest_client(), **parameters).update(
        **parameters
    )

    ctx.instance.runtime_properties[DO_NOT_DELETE_PROPERTY] = parameters.get(
        DO_NOT_DELETE_PROPERTY,
        False
    )
    ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY] = result


@operation(resumable=True)
def delete(ctx, **kwargs):
    if ctx.instance.runtime_properties.get(DO_NOT_DELETE_PROPERTY, False):
        ctx.logger.info(
            '"do_not_delete" property set to <true> - skipping deletion ...'
        )
    else:
        parameters = _get_parameters(ctx.node.properties, kwargs)
        secrets = ctx.instance.runtime_properties[DATA_RUNTIME_PROPERTY]


        SecretsSDK(ctx.logger, get_rest_client(), **parameters).delete(