code: def federated_query(self,
                          environment_id,
                          filter=None,
                          query=None,
                          natural_language_query=None,
                          passages=None,
                          aggregation=None,
                          count=None,
                          return_fields=None,
                          offset=None,
                          sort=None,
                          highlight=None,
                          passages_fields=None,
                          passages_count=None,
                          passages_characters=None,
                          deduplicate=None,
                          deduplicate_field=None,
                          collection_ids=None,
                          similar=None,
                          similar_document_ids=None,
                          similar_fields=None,
                          bias=None,
                          logging_opt_out=None,
                          **kwargs):
          if environment_id is None:
              raise ValueError('environment_id must be provided')
          headers = {'X-Watson-Logging-Opt-Out': logging_opt_out}
          if 'headers' in kwargs:
              headers.update(kwargs.get('headers'))
          sdk_headers = get_sdk_headers('discovery', 'V1', 'federated_query')
          headers.update(sdk_headers)
          params = {'version': self.version}
          data = {
              'filter': filter,
              'query': query,
              'natural_language_query': natural_language_query,
              'passages': passages,
              'aggregation': aggregation,
              'count': count,
              'return': return_fields,
              'offset': offset,
              'sort': sort,
              'highlight': highlight,
              'passages.fields': passages_fields,
              'passages.count': passages_count,
              'passages.characters': passages_characters,
              'deduplicate': deduplicate,
              'deduplicate.field': deduplicate_field,
              'collection_ids': collection_ids,
              'similar': similar,
              'similar.document_ids': similar_document_ids,
              'similar.fields': similar_fields,
              'bias': bias
          }
          url = '/v1/environments/{0}/query'.format(
              *self._encode_path_vars(environment_id))
          response = self.request(
              method='POST',
              url=url,
              headers=headers,
              params=params,
              json=data,
              accept_json=True)
          return response