solvebio/resource/vault.py
def validate_full_path(cls, full_path, **kwargs):
        """Helper method to return a full path from a full or partial path.

            If no domain, assumes user's account domain
            If the vault is "~", assumes personal vault.

        Valid vault paths include:

            domain:vault
            domain:vault:/path
            domain:vault/path
            vault:/path
            vault
            ~/

        Invalid vault paths include:

            /vault/
            /path
            /
            :/

        Does not allow overrides for any vault path components.
        """
        _client = kwargs.pop('client', None) or cls._client or client

        full_path = full_path.strip()
        if not full_path:
            raise Exception(
                'Vault path "{0}" is invalid. Path must be in the format: '
                '"domain:vault:/path" or "vault:/path".'.format(full_path)
            )

        match = cls.VAULT_PATH_RE.match(full_path)
        if not match:
            raise Exception(
                'Vault path "{0}" is invalid. Path must be in the format: '
                '"domain:vault:/path" or "vault:/path".'.format(full_path)
            )
        path_parts = match.groupdict()

        # Handle the special case where "~" means personal vault
        if path_parts.get('vault') == '~':
            path_parts = dict(domain=None, vault=None)

        # If any values are None, set defaults from the user.
        if None in path_parts.values():
            user = _client.get('/v1/user', {})
            defaults = {
                'domain': user['account']['domain'],
                'vault': 'user-{0}'.format(user['id'])
            }
            path_parts = dict((k, v or defaults.get(k))
                              for k, v in path_parts.items())

        # Rebuild the full path
        full_path = '{domain}:{vault}'.format(**path_parts)
        path_parts['vault_full_path'] = full_path
        return full_path, path_parts
def validate_full_path(cls, full_path, **kwargs):
        _client = kwargs.pop('client', None) or cls._client or client

        full_path = full_path.strip()
        if not full_path:
            raise Exception(
                'Vault path "{0}" is invalid. Path must be in the format: '
                '"domain:vault:/path" or "vault:/path".'.format(full_path)
            )

        match = cls.VAULT_PATH_RE.match(full_path)
        if not match:
            raise Exception(
                'Vault path "{0}" is invalid. Path must be in the format: '
                '"domain:vault:/path" or "vault:/path".'.format(full_path)
            )
        path_parts = match.groupdict()

        # Handle the special case where "~" means personal vault
        if path_parts.get('vault') == '~':
            path_parts = dict(domain=None, vault=None)

        # If any values are None, set defaults from the user.
        if None in path_parts.values():
            user = _client.get('/v1/user', {})
            defaults = {
                'domain': user['account']['domain'],
                'vault': 'user-{0}'.format(user['id'])
            }
            path_parts = dict((k, v or defaults.get(k))
                              for k, v in path_parts.items())

        # Rebuild the full path
        full_path = '{domain}:{vault}'.format(**path_parts)
        path_parts['vault_full_path'] = full_path
        return full_path, path_parts
def validate_full_path ( cls , full_path , * * kwargs ) : _client = kwargs . pop ( 'client' , None ) or cls . _client or client full_path = full_path . strip ( ) if not full_path : raise Exception ( 'Vault path "{0}" is invalid. Path must be in the format: ' '"domain:vault:/path" or "vault:/path".' . format ( full_path ) ) match = cls . VAULT_PATH_RE . match ( full_path ) if not match : raise Exception ( 'Vault path "{0}" is invalid. Path must be in the format: ' '"domain:vault:/path" or "vault:/path".' . format ( full_path ) ) path_parts = match . groupdict ( ) # Handle the special case where "~" means personal vault if path_parts . get ( 'vault' ) == '~' : path_parts = dict ( domain = None , vault = None ) # If any values are None, set defaults from the user. if None in path_parts . values ( ) : user = _client . get ( '/v1/user' , { } ) defaults = { 'domain' : user [ 'account' ] [ 'domain' ] , 'vault' : 'user-{0}' . format ( user [ 'id' ] ) } path_parts = dict ( ( k , v or defaults . get ( k ) ) for k , v in path_parts . items ( ) ) # Rebuild the full path full_path = '{domain}:{vault}' . format ( * * path_parts ) path_parts [ 'vault_full_path' ] = full_path return full_path , path_parts
Helper method to return a full path from a full or partial path.

            If no domain, assumes user's account domain
            If the vault is "~", assumes personal vault.

        Valid vault paths include:

            domain:vault
            domain:vault:/path
            domain:vault/path
            vault:/path
            vault
            ~/

        Invalid vault paths include:

            /vault/
            /path
            /
            :/

        Does not allow overrides for any vault path components.
Helper method to return a full path from a full or partial path .