def query_relations(self,
                        environment_id,
                        collection_id,
                        entities=None,
                        context=None,
                        sort=None,
                        filter=None,
                        count=None,
                        evidence_count=None,
                        **kwargs):
        if environment_id is None:
            raise ValueError('environment_id must be provided')
        if collection_id is None:
            raise ValueError('collection_id must be provided')
        if entities is not None:
            entities = [
                self._convert_model(x, QueryRelationsEntity) for x in entities
            ]
        if context is not None:
            context = self._convert_model(context, QueryEntitiesContext)
        if filter is not None:
            filter = self._convert_model(filter, QueryRelationsFilter)
        headers = {}
        if 'headers' in kwargs:
            headers.update(kwargs.get('headers'))
        sdk_headers = get_sdk_headers('discovery', 'V1', 'query_relations')
        headers.update(sdk_headers)
        params = {'version': self.version}
        data = {
            'entities': entities,
            'context': context,
            'sort': sort,
            'filter': filter,
            'count': count,
            'evidence_count': evidence_count
        }
        url = '/v1/environments/{0}/collections/{1}/query_relations'.format(
            *self._encode_path_vars(environment_id, collection_id))
        response = self.request(
            method='POST',
            url=url,
            headers=headers,
            params=params,
            json=data,
            accept_json=True)
        return response