code: def add_query(self, name, filter, **kwargs):
          
          # Ensure we have the correct types and get the new query object
          filter_obj = filters.legacy_filter_formatter(
              dict(filter=filter),
              Device._get_attributes_map()
          ) if filter else None
          query_map = Query._create_request_map(kwargs)
          # Create the DeviceQuery object
          f = DeviceQuery(name=name, query=filter_obj['filter'], **query_map)
          api = self._get_api(device_directory.DefaultApi)
          return Query(api.device_query_create(f))
docs: Add a new query to device query service.
  
          .. code-block:: python
  
              f = api.add_query(
                  name = "Query name",
                  filter = {
                      "device_id": {"$eq": "01234"},
                      custom_attributes = {
                          "foo": {"$eq": "bar"}
                      }
                  }
              )
              print(f.created_at)
  
          :param str name: Name of query (Required)
          :param dict filter: Filter properties to apply (Required)
          :param return: The newly created query object.
          :return: the newly created query object
          :rtype: Query