def details(client, wid=None, name=None, owner=None):
    """ Fetch the details of a workspace by name or id.

    This function calls the Quetzal API endpoint to retrieve workspace
    details. When the `wid` parameter is set, it will use directly this number
    to do a `GET` on `/workspaces/:id`. When the `name` is set, it will fetch
    and filter the workspace list by this name and its `owner`. Note that
    `name` and `wid` are mutually exclusive options.

    Parameters
    ----------
    client: quetzal.client.Client
        Client object that will be used for the Quetzal API operation.
    wid: int, optional
        Workspace identifier.
    name: str, optional
        Workspace name.
    owner: str, optional
        Username of the workspace owner. If not set and `name` is set, it will
        use the username saved on the `client` configuration object.

    Returns
    -------
    w_details: quetzal.openapi_client.models.Workspace
        Details on the workspace, or ``None`` when it was not found.

    Raises
    ------
    quetzal.client.exceptions.QuetzalAPIException
        When the API returns an error. When the `wid` parameter is set and the
        workspace does not exist, this exception will be raised with its
        `status` member set to 404 (not found).
    urllib3.exceptions.RequestError
        When there was a problem connecting to the server.

    """
    if wid is None and name is None:
        raise ValueError('One of wid or name is needed.')
    if name:
        username = owner or client.configuration.username
        response = client.workspace_fetch(owner=username, name=name)
        if not response.results:
            return None
        w_details = response.results[0]
    else:
        w_details = client.workspace_details(wid)
    return w_details
