'Get a list of servers.
:param detailed: Whether to return detailed server info (optional).
:param search_opts: Search options to filter out servers which don\'t
match the search_opts (optional). The search opts format is a
dictionary of key / value pairs that will be appended to the query
string.  For a complete list of keys see:
https://developer.openstack.org/api-ref/compute/#list-servers
:param marker: Begin returning servers that appear later in the server
list than that represented by this server id (optional).
:param limit: Maximum number of servers to return (optional).
:param sort_keys: List of sort keys
:param sort_dirs: List of sort directions
:rtype: list of :class:`Server`
Examples:
client.servers.list() - returns detailed list of servers
client.servers.list(search_opts={\'status\': \'ERROR\'}) -
returns list of servers in error state.
client.servers.list(limit=10) - returns only 10 servers'

def list(self, detailed=True, search_opts=None, marker=None, limit=None, sort_keys=None, sort_dirs=None):

    if (search_opts is None):
        search_opts = {}
    qparams = {}
    for (opt, val) in search_opts.items():
        if val:
            if isinstance(val, six.text_type):
                val = val.encode('utf-8')
            qparams[opt] = val
    detail = ''
    if detailed:
        detail = '/detail'
    result = base.ListWithMeta([], None)
    while True:
        if marker:
            qparams['marker'] = marker
        if (limit and (limit != (-1))):
            qparams['limit'] = limit
        if (qparams or sort_keys or sort_dirs):
            items = list(qparams.items())
            if sort_keys:
                items.extend((('sort_key', sort_key) for sort_key in sort_keys))
            if sort_dirs:
                items.extend((('sort_dir', sort_dir) for sort_dir in sort_dirs))
            new_qparams = sorted(items, key=(lambda x: x[0]))
            query_string = ('?%s' % parse.urlencode(new_qparams))
        else:
            query_string = ''
        servers = self._list(('/servers%s%s' % (detail, query_string)), 'servers')
        result.extend(servers)
        result.append_request_ids(servers.request_ids)
        if ((not servers) or (limit != (-1))):
            break
        marker = result[(-1)].id
    return result
