confidant_client/__init__.py
def update_blind_credential(
            self,
            id,
            blind_keys=None,
            contexts=None,
            name=None,
            credential_pairs=None,
            metadata=None,
            cipher_type=None,
            cipher_version=None,
            store_keys=True,
            enabled=None,
            documentation=None
            ):
        """Update a server blinded credential in Confidant."""
        # Return a dict, always with an attribute that specifies whether or not
        # the function was able to successfully get a result.
        ret = {'result': False}
        cred = self.get_blind_credential(id)
        if not cred['result']:
            return ret
        data = cred['blind_credential']
        del data['revision']
        del data['modified_by']
        del data['modified_date']
        if name is not None:
            data['name'] = name
        if metadata is not None:
            _context = data['metadata']['context']
            data['metadata'] = metadata
            data['metadata']['context'] = _context
        if documentation is not None:
            data['documentation'] = documentation
        if credential_pairs is not None:
            if contexts is not None:
                data['metadata']['context'] = contexts
            else:
                contexts = data['metadata']['context']
            if cipher_type is not None:
                data['cipher_type'] = cipher_type
            else:
                cipher_type = data['cipher_type']
            if cipher_version is not None:
                data['cipher_version'] = cipher_version
            else:
                cipher_version = data['cipher_version']
            data_keys, _credential_pairs = self._get_keys_and_encrypted_pairs(
                blind_keys,
                contexts,
                credential_pairs,
                cipher_type,
                cipher_version
            )
            data['data_key'] = data_keys
            data['credential_pairs'] = _credential_pairs
            if store_keys:
                data['credential_keys'] = list(credential_pairs.keys())
        if enabled is not None:
            data['enabled'] = enabled
        try:
            response = self._execute_request(
                'put',
                '{0}/v1/blind_credentials/{1}'.format(self.config['url'], id),
                headers=JSON_HEADERS,
                data=json.dumps(data)
            )
        except RequestExecutionError:
            logging.exception('Error with executing request')
            return ret
        try:
            data = response.json()
        except ValueError:
            logging.error('Received badly formatted json data from confidant.')
            return ret
        ret['blind_credential'] = data
        ret['result'] = True
        return ret
Update a server blinded credential in Confidant.
Update a server blinded credential in Confidant.
Update a server blinded credential in Confidant .
def update_blind_credential(
            self,
            id,
            blind_keys=None,
            contexts=None,
            name=None,
            credential_pairs=None,
            metadata=None,
            cipher_type=None,
            cipher_version=None,
            store_keys=True,
            enabled=None,
            documentation=None
            ):
        ret = {'result': False}
        cred = self.get_blind_credential(id)
        if not cred['result']:
            return ret
        data = cred['blind_credential']
        del data['revision']
        del data['modified_by']
        del data['modified_date']
        if name is not None:
            data['name'] = name
        if metadata is not None:
            _context = data['metadata']['context']
            data['metadata'] = metadata
            data['metadata']['context'] = _context
        if documentation is not None:
            data['documentation'] = documentation
        if credential_pairs is not None:
            if contexts is not None:
                data['metadata']['context'] = contexts
            else:
                contexts = data['metadata']['context']
            if cipher_type is not None:
                data['cipher_type'] = cipher_type
            else:
                cipher_type = data['cipher_type']
            if cipher_version is not None:
                data['cipher_version'] = cipher_version
            else:
                cipher_version = data['cipher_version']
            data_keys, _credential_pairs = self._get_keys_and_encrypted_pairs(
                blind_keys,
                contexts,
                credential_pairs,
                cipher_type,
                cipher_version
            )
            data['data_key'] = data_keys
            data['credential_pairs'] = _credential_pairs
            if store_keys:
                data['credential_keys'] = list(credential_pairs.keys())
        if enabled is not None:
            data['enabled'] = enabled
        try:
            response = self._execute_request(
                'put',
                '{0}/v1/blind_credentials/{1}'.format(self.config['url'], id),
                headers=JSON_HEADERS,
                data=json.dumps(data)
            )
        except RequestExecutionError:
            logging.exception('Error with executing request')
            return ret
        try:
            data = response.json()
        except ValueError:
            logging.error('Received badly formatted json data from confidant.')
            return ret
        ret['blind_credential'] = data
        ret['result'] = True
        return ret
def update_blind_credential ( self , id , blind_keys = None , contexts = None , name = None , credential_pairs = None , metadata = None , cipher_type = None , cipher_version = None , store_keys = True , enabled = None , documentation = None ) : ret = { 'result' : False } cred = self . get_blind_credential ( id ) if not cred [ 'result' ] : return ret data = cred [ 'blind_credential' ] del data [ 'revision' ] del data [ 'modified_by' ] del data [ 'modified_date' ] if name is not None : data [ 'name' ] = name if metadata is not None : _context = data [ 'metadata' ] [ 'context' ] data [ 'metadata' ] = metadata data [ 'metadata' ] [ 'context' ] = _context if documentation is not None : data [ 'documentation' ] = documentation if credential_pairs is not None : if contexts is not None : data [ 'metadata' ] [ 'context' ] = contexts else : contexts = data [ 'metadata' ] [ 'context' ] if cipher_type is not None : data [ 'cipher_type' ] = cipher_type else : cipher_type = data [ 'cipher_type' ] if cipher_version is not None : data [ 'cipher_version' ] = cipher_version else : cipher_version = data [ 'cipher_version' ] data_keys , _credential_pairs = self . _get_keys_and_encrypted_pairs ( blind_keys , contexts , credential_pairs , cipher_type , cipher_version ) data [ 'data_key' ] = data_keys data [ 'credential_pairs' ] = _credential_pairs if store_keys : data [ 'credential_keys' ] = list ( credential_pairs . keys ( ) ) if enabled is not None : data [ 'enabled' ] = enabled try : response = self . _execute_request ( 'put' , '{0}/v1/blind_credentials/{1}' . format ( self . config [ 'url' ] , id ) , headers = JSON_HEADERS , data = json . dumps ( data ) ) except RequestExecutionError : logging . exception ( 'Error with executing request' ) return ret try : data = response . json ( ) except ValueError : logging . error ( 'Received badly formatted json data from confidant.' ) return ret ret [ 'blind_credential' ] = data ret [ 'result' ] = True return ret
Update a server blinded credential in Confidant.
Update a server blinded credential in Confidant .
"""Update a server blinded credential in Confidant.""" # Return a dict, always with an attribute that specifies whether or not # the function was able to successfully get a result.
self
id
blind_keys
contexts
name
credential_pairs
metadata
cipher_type
cipher_version
store_keys
enabled
documentation