Build the query object used to build the URI string

@param {Object} opts - Metadata query options
@param {bool} globalSearch - Whether we're searching globally or not
@return {Query}
324626
function buildQuery(opts, globalSearch) {
    var imboQuery = new ImboQuery();

    imboQuery.page(opts.page);
    imboQuery.limit(opts.limit);

    if (opts.users && globalSearch) {
        imboQuery.users(opts.users);
    }

    if (opts.fields) {
        imboQuery.fields(opts.fields);
    }

    if (opts.sort) {
        imboQuery.addSorts(opts.sort);
    }

    if (opts.metadata) {
        imboQuery.metadata(opts.metadata);
    }

    return imboQuery;
}
980756
function(opts) {
  if(!opts) opts = {};
  if(!opts.clientId  || typeof opts.clientId !== 'string') {
    throw new Error('Invalid or missing clientId');
  } else {
    this.clientId = opts.clientId;
  }
  if(!opts.clientSecret || typeof opts.clientSecret !== 'string') {
    throw new Error('Invalid or missing clientSecret');
  } else {
    this.clientSecret = opts.clientSecret;
  }
  if(!opts.redirectUri || typeof opts.redirectUri !== 'string') {
    throw new Error('Invalid or missing redirectUri');
  } else {
    this.redirectUri = opts.redirectUri;
  }
  // Allow custom login and test uris to be passed in
  // Addresses issue #5
  // @zachelrath 11/13/12
  opts.loginUri && (LOGIN_URI = opts.loginUri);
  opts.testLoginUri && (TEST_LOGIN_URI = opts.testLoginUri);

  if(typeof opts.cacheMetadata !== 'undefined') {
    if(typeof opts.cacheMetadata !== 'boolean') throw new Error('cacheMetadata must be a boolean');
    this.cacheMetadata = opts.cacheMetadata;
  } else {
    // caching is defaulted to false
    this.cacheMetadata = true;
  }
  if(this.cacheMetadata) {
    this._cache = {
      keyPrefixes: {},
      sObjects: {}
    }
  }
  if(opts.apiVersion) {
    if(typeof opts.apiVersion === 'number') {
      opts.apiVersion = opts.apiVersion.toString();
      if(opts.apiVersion.length === 2) opts.apiVersion = opts.apiVersion + '.0';
    }
    opts.apiVersion = opts.apiVersion.toLowerCase();
    if(/^\d\d\.\d$/g.test(opts.apiVersion)) {
      opts.apiVersion = 'v' + opts.apiVersion;
    } else if(/^\d\d$/g.test(opts.apiVersion)) {
      opts.apiVersion = 'v' + opts.apiVersion + '.0';
    } else if(/^v\d\d$/g.test(opts.apiVersion)) {
      opts.apiVersion = opts.apiVersion + '.0';
    }
    if(API_VERSIONS.indexOf(opts.apiVersion) === -1 ) {
      throw new Error(opts.apiVersion + ' is an invalid api version');
    } else {
      this.apiVersion = opts.apiVersion;
    }
  } else {
    this.apiVersion = API_VERSIONS[API_VERSIONS.length - 1];
  }
  if(opts.environment) {
    if(opts.environment.toLowerCase() == 'sandbox' || opts.environment.toLowerCase() == 'production') {
      this.environment = opts.environment.toLowerCase();
    } else {
      throw new Error(opts.environment + ' is an invalid environment');
    }
  } else {
    this.environment = 'production';
  }
  if(opts.mode && opts.mode.toLowerCase() === 'single') {
    this.mode = 'single';
  } else {
    this.mode = 'multi';
  }
}
566540
def system_global_search(input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/system/globalSearch', input_params, always_retry=always_retry, **kwargs)
340112
function lookup(uri, opts) {
    if (typeof uri === "object") {
      opts = uri;
      uri = undefined;
    }

    opts = opts || {};

    var parsed = url_1(uri);
    var source = parsed.source;
    var id = parsed.id;
    var path = parsed.path;
    var sameNamespace = cache[id] && path in cache[id].nsps;
    var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;

    var io;

    if (newConnection) {
      debug("ignoring socket cache for %s", source);
      io = manager(source, opts);
    } else {
      if (!cache[id]) {
        debug("new io instance for %s", source);
        cache[id] = manager(source, opts);
      }
      io = cache[id];
    }
    if (parsed.query && !opts.query) {
      opts.query = parsed.query;
    }
    return io.socket(parsed.path, opts);
  }
507711
function API(opts) {
  opts = opts || {};

  this.verbose = !!opts.verbose;
  this.request = opts.request || request;
  this.baseUrl = opts.baseUrl || BASE_URL;
  var parsedUrl = url.parse(this.baseUrl);
  this.basePath = parsedUrl.path;
  this.baseHost = parsedUrl.protocol + '//' + parsedUrl.host;
  this.timeout = opts.timeout || 50000;

  if (this.verbose) {
    log.setLevel('debug');
  } else {
    log.setLevel('info');
  }
}
435345
function (opts) {
            opts.meta.classes = [];
            Y.each(this.data.classes, function (v) {
                if (v.external) {
                    return;
                }
                opts.meta.classes.push({
                    displayName: v.name,
                    name: v.name,
                    namespace: v.namespace,
                    module: v.module,
                    description: v.description,
                    access: v.access || 'public'
                });
            });
            opts.meta.classes.sort(this.nameSort);
            return opts;
        }
1343013
function elasticsearchGlobal (elasticsearchClient) {
    // set client
    if (defined(elasticsearchClient)) {
        // set global client
        ImmutableCoreModel.global().defaultElasticsearchClient =  elasticsearchClient
        // return model when setting value
        return ImmutableCoreModel
    }
    else {
        return ImmutableCoreModel.global().defaultElasticsearchClient
    }
}
25516
function buildCount (opts) {
  // eslint-disable-next-line no-unused-vars
  const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
  /**
   * Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request
   *
   * @param {list} index - A comma-separated list of indices to restrict the results
   * @param {list} type - A comma-separated list of types to restrict the results
   * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
   * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
   * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
   * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
   * @param {number} min_score - Include only documents with a specific `_score` value in the result
   * @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
   * @param {list} routing - A comma-separated list of specific routing values
   * @param {string} q - Query in the Lucene query string syntax
   * @param {string} analyzer - The analyzer to use for the query string
   * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
   * @param {enum} default_operator - The default operator for query string query (AND or OR)
   * @param {string} df - The field to use as default where no field prefix is given in the query string
   * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
   * @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early
   * @param {object} body - A query to restrict the results specified with the Query DSL (optional)
   */

  const acceptedQuerystring = [
    'ignore_unavailable',
    'ignore_throttled',
    'allow_no_indices',
    'expand_wildcards',
    'min_score',
    'preference',
    'routing',
    'q',
    'analyzer',
    'analyze_wildcard',
    'default_operator',
    'df',
    'lenient',
    'terminate_after',
    'pretty',
    'human',
    'error_trace',
    'source',
    'filter_path'
  ]

  const snakeCase = {
    ignoreUnavailable: 'ignore_unavailable',
    ignoreThrottled: 'ignore_throttled',
    allowNoIndices: 'allow_no_indices',
    expandWildcards: 'expand_wildcards',
    minScore: 'min_score',
    analyzeWildcard: 'analyze_wildcard',
    defaultOperator: 'default_operator',
    terminateAfter: 'terminate_after',
    errorTrace: 'error_trace',
    filterPath: 'filter_path'
  }

  return function count (params, options, callback) {
    options = options || {}
    if (typeof options === 'function') {
      callback = options
      options = {}
    }
    if (typeof params === 'function' || params == null) {
      callback = params
      params = {}
      options = {}
    }

    // check required url components
    if (params['type'] != null && (params['index'] == null)) {
      const err = new ConfigurationError('Missing required parameter of the url: index')
      return handleError(err, callback)
    }

    // validate headers object
    if (options.headers != null && typeof options.headers !== 'object') {
      const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
      return handleError(err, callback)
    }

    var warnings = []
    var { method, body, index, type, ...querystring } = params
    querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)

    if (method == null) {
      method = body == null ? 'GET' : 'POST'
    }

    var ignore = options.ignore
    if (typeof ignore === 'number') {
      options.ignore = [ignore]
    }

    var path = ''

    if ((index) != null && (type) != null) {
      path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
    } else if ((index) != null) {
      path = '/' + encodeURIComponent(index) + '/' + '_count'
    } else {
      path = '/' + '_count'
    }

    // build request object
    const request = {
      method,
      path,
      body: body || '',
      querystring
    }

    options.warnings = warnings.length === 0 ? null : warnings
    return makeRequest(request, options, callback)
  }
}
967658
function (opts) {
      var value = opts.value
      if (value === undefined) value = null
      var expire = opts.expire || 0
      var time = Date.now()
      var v = {
        value: value,
        time: time,
        expire: expire
      }
      return JSON.stringify(v)
    }
715440
function createReqIdHeaders(opts) {

    assert.object(opts, 'opts');
    assert.arrayOfString(opts.headers, 'opts.headers');

    var headers = opts.headers.concat(DEFAULT_HEADERS);

    return function reqIdHeaders(req, res, next) {

        for (var i = 0; i < headers.length; i++) {
            var val = req.header(headers[i]);

            if (val) {
                req.id(val);
                break;
            }
        }

        return next();
    };
}
1294173
public function filter(callable $callback, $globalSearch = false)
    {
        $this->autoFilter      = $globalSearch;
        $this->isFilterApplied = true;
        $this->filterCallback  = $callback;

        return $this;
    }
742404
function(files, opts) {
		var self    = this,
			cwd     = this.getUI('cwd'),
			cwdHash = this.cwd().hash,
			newItem = $();
		
		opts = opts || {};
		
		$.each(files, function(i, f) {
			if (f.phash === cwdHash || self.searchStatus.state > 1) {
				newItem = newItem.add(cwd.find('#'+self.cwdHash2Id(f.hash)));
				if (opts.firstOnly) {
					return false;
				}
			}
		});
		
		return newItem;
	}
627715
function search (opts) {
    if (!R.is(Array, opts.keywords)) {
      return Promise.reject(Error('an array of seed keywords is required for this strategy'));
    }
    return getSearchKeywords(opts.keywords).then(getAppsFromKeywords);
  }
1313821
function buildTasksList (opts) {
  // eslint-disable-next-line no-unused-vars
  const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
  /**
   * Perform a [tasks.list](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request
   *
   * @param {list} nodes - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
   * @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all.
   * @param {boolean} detailed - Return detailed task information (default: false)
   * @param {string} parent_task_id - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
   * @param {boolean} wait_for_completion - Wait for the matching tasks to complete (default: false)
   * @param {enum} group_by - Group tasks by nodes or parent/child relationships
   * @param {time} timeout - Explicit operation timeout
   */

  const acceptedQuerystring = [
    'nodes',
    'actions',
    'detailed',
    'parent_task_id',
    'wait_for_completion',
    'group_by',
    'timeout',
    'pretty',
    'human',
    'error_trace',
    'source',
    'filter_path'
  ]

  const snakeCase = {
    parentTaskId: 'parent_task_id',
    waitForCompletion: 'wait_for_completion',
    groupBy: 'group_by',
    errorTrace: 'error_trace',
    filterPath: 'filter_path'
  }

  return function tasksList (params, options, callback) {
    options = options || {}
    if (typeof options === 'function') {
      callback = options
      options = {}
    }
    if (typeof params === 'function' || params == null) {
      callback = params
      params = {}
      options = {}
    }

    // check required parameters
    if (params.body != null) {
      const err = new ConfigurationError('This API does not require a body')
      return handleError(err, callback)
    }

    // validate headers object
    if (options.headers != null && typeof options.headers !== 'object') {
      const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
      return handleError(err, callback)
    }

    var warnings = []
    var { method, body, ...querystring } = params
    querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)

    if (method == null) {
      method = 'GET'
    }

    var ignore = options.ignore
    if (typeof ignore === 'number') {
      options.ignore = [ignore]
    }

    var path = ''

    path = '/' + '_tasks'

    // build request object
    const request = {
      method,
      path,
      body: null,
      querystring
    }

    options.warnings = warnings.length === 0 ? null : warnings
    return makeRequest(request, options, callback)
  }
}
16545
function defaults(opts) {
  opts = opts || {}

  if (!opts.streamer) {
    throw new Error('No streamer found. Must pass a streamer to multipart-pipe')
  }

  opts.limit = opts.limit === undefined ? '128mb' : opts.limit;
  opts.limit = typeof opts.limit === 'string' ? parseBytes(opts.limit) : opts.limit;
  opts.allow = opts.allow instanceof RegExp ? opts.allow : new RegExp(opts.allow || '.*');

  if (!opts.filename || typeof opts.filename !== 'function') {
    opts.filename = function (filename, mime) { return filename; };
  }

  return opts
}
977296
function do_select(self, types, search_opts, traits) {
	return nr_fcall("nopg:do_select", function() {
		return prepare_select_query(self, types, search_opts, traits).then(function(q) {
			var result = q.compile();

			// Unnecessary since do_query() does it too
			//if(NoPg.debug) {
			//	debug.log('query = ', result.query);
			//	debug.log('params = ', result.params);
			//}

			debug.assert(result).is('object');
			debug.assert(result.query).is('string');
			debug.assert(result.params).is('array');

			var builder;
			var type = result.documentType;

			if( (result.ObjType === NoPg.Document) &&
			  is.string(type) &&
			  self._documentBuilders &&
			  self._documentBuilders.hasOwnProperty(type) &&
			  is.func(self._documentBuilders[type]) ) {
				builder = self._documentBuilders[type];
			}
			debug.assert(builder).ignore(undefined).is('function');

			return do_query(self, result.query, result.params ).then(get_results(result.ObjType, {
				'fieldMap': result.fieldMap
			})).then(function(data) {
				if(!builder) {
					return data;
				}
				debug.log('data = ', data);
				return builder(data);
			});
		});
	});
}
1108841
def search(cls, query, search_opts=None):
        

        if search_opts is None:
            search_opts = {}

        xmlrpc = XMLRPCConnection()
        try:
            search_result = xmlrpc.connection.search_pool(
                {
                    'query': query,
                    'search_options': search_opts,
                    'auth': AuthOptions().options
                })
        except xmlrpclib.Fault as xml_fault:
            raise _fault_to_exception(xml_fault)
        result = dict()
        result['result'] = []
        result['search_options'] = search_result['search_options']
        for pool in search_result['result']:
            p = Pool.from_dict(pool)
            result['result'].append(p)

        return result