Perform a query directly against the Vultr REST API
12429
def _query(path, method='GET', data=None, params=None, header_dict=None, decode=True):
    '''
    
    '''
    api_key = config.get_cloud_config_value(
        'api_key',
        get_configured_provider(),
        __opts__,
        search_global=False,
    )
    management_host = config.get_cloud_config_value(
        'management_host',
        get_configured_provider(),
        __opts__,
        search_global=False,
        default='api.vultr.com'
    )
    url = 'https://{management_host}/v1/{path}?api_key={api_key}'.format(
        management_host=management_host,
        path=path,
        api_key=api_key,
    )

    if header_dict is None:
        header_dict = {}

    result = __utils__['http.query'](
        url,
        method=method,
        params=params,
        data=data,
        header_dict=header_dict,
        port=443,
        text=True,
        decode=decode,
        decode_type='json',
        hide_fields=['api_key'],
        opts=__opts__,
    )
    if 'dict' in result:
        return result['dict']

    return result
857256
def query(key, value=None, service=None, profile=None):  # pylint: disable=W0613
    '''
    
    '''
    comps = key.split('?')
    key = comps[0]
    key_vars = {}
    for pair in comps[1].split('&'):
        pair_key, pair_val = pair.split('=')
        key_vars[pair_key] = pair_val

    renderer = __opts__.get('renderer', 'jinja|yaml')
    rend = salt.loader.render(__opts__, {})
    blacklist = __opts__.get('renderer_blacklist')
    whitelist = __opts__.get('renderer_whitelist')
    url = compile_template(
        ':string:',
        rend,
        renderer,
        blacklist,
        whitelist,
        input_data=profile[key]['url'],
        **key_vars
    )

    extras = {}
    for item in profile[key]:
        if item not in ('backend', 'url'):
            extras[item] = profile[key][item]

    result = http.query(
        url,
        decode=True,
        **extras
    )

    return result['dict']
317945
def parse_querystring(self, req, name, field):
        """"""
        return core.get_value(req.query, name, field)
150114
function query(params, callback) {
  const args = utils.getArgs(params, [config], callback);
  const url = `http://${args.options.ip}:${args.options.port}/`;

  return request.get({
    url,
    qs: args.options,
  }, function(err, res, body) {
    if (err) {
      return args.callback(err);
    }
    return args.callback(null, body);
  });
}
558834
def query_string(context, **kwargs):
    """"""
    params = context["request"].GET.copy()

    for key, value in list(kwargs.items()):
        params[key] = value

    return "?" + params.urlencode()
238385
function query(base, q, callback) {
    // Added unescape to fix URI errors resulting from hexadecimal escape sequences
    var url = util.format("%s?%s", base, querystring.unescape(querystring.stringify(q)));
    request(url, function (err, response) {
        if (err) return callback(err);
        callback(null, response.body);
    });
}
258636
def query(self, query, interpolations=None):
        
        return self._client.ts_query(self, query, interpolations)
1291068
def query(self):
        """"""
        if self._query is None:
            query_string = self.environ.get('QUERY_STRING')
            self._query = QueryDict([
                (k.decode('utf-8'), v.decode('utf-8'))
                for k, v in urlparse.parse_qsl(
                    query_string, keep_blank_values=True)
            ])
        return self._query
1019888
def _query(action=None,
           command=None,
           args=None,
           method='GET',
           header_dict=None,
           data=None,
           url='https://api.linode.com/'):
    '''
    
    '''
    global LASTCALL
    vm_ = get_configured_provider()

    ratelimit_sleep = config.get_cloud_config_value(
        'ratelimit_sleep', vm_, __opts__, search_global=False, default=0,
    )
    apikey = config.get_cloud_config_value(
        'apikey', vm_, __opts__, search_global=False
    )

    if not isinstance(args, dict):
        args = {}

    if 'api_key' not in args.keys():
        args['api_key'] = apikey

    if action and 'api_action' not in args.keys():
        args['api_action'] = '{0}.{1}'.format(action, command)

    if header_dict is None:
        header_dict = {}

    if method != 'POST':
        header_dict['Accept'] = 'application/json'

    decode = True
    if method == 'DELETE':
        decode = False

    now = int(time.mktime(datetime.datetime.now().timetuple()))
    if LASTCALL >= now:
        time.sleep(ratelimit_sleep)

    result = __utils__['http.query'](
        url,
        method,
        params=args,
        data=data,
        header_dict=header_dict,
        decode=decode,
        decode_type='json',
        text=True,
        status=True,
        hide_fields=['api_key', 'rootPass'],
        opts=__opts__,
    )

    if 'ERRORARRAY' in result['dict']:
        if result['dict']['ERRORARRAY']:
            error_list = []

            for error in result['dict']['ERRORARRAY']:
                msg = error['ERRORMESSAGE']

                if msg == "Authentication failed":
                    raise SaltCloudSystemExit(
                        'Linode API Key is expired or invalid'
                    )
                else:
                    error_list.append(msg)
            raise SaltCloudException(
                'Linode API reported error(s): {}'.format(", ".join(error_list))
            )

    LASTCALL = int(time.mktime(datetime.datetime.now().timetuple()))
    log.debug('Linode Response Status Code: %s', result['status'])

    return result['dict']
220985
def query(input, representation, resolvers=None, **kwargs):
    
    apiurl = API_BASE+'/%s/%s/xml' % (urlquote(input), representation)
    if resolvers:
        kwargs['resolver'] = ",".join(resolvers)
    if kwargs:
        apiurl+= '?%s' % urlencode(kwargs)
    result = []
    try:
        tree = ET.parse(urlopen(apiurl))
        for data in tree.findall(".//data"):
            datadict = {'resolver':data.attrib['resolver'],
                        'notation':data.attrib['notation'],
                        'value':[]}
            for item in data.findall("item"):
                datadict['value'].append(item.text)
            if len(datadict['value']) == 1:
                datadict['value'] = datadict['value'][0]
            result.append(datadict)
    except HTTPError:
        # TODO: Proper handling of 404, for now just returns None
        pass
    return result if result else None
1278554
private InputStream runSparqlQuery(String query) throws IOException {
		try {
			String queryString = "query=" + URLEncoder.encode(query, "UTF-8")
					+ "&format=json";
			URL url = new URL("https://query.wikidata.org/sparql?"
					+ queryString);
			HttpURLConnection connection = (HttpURLConnection) url
					.openConnection();
			connection.setRequestMethod("GET");

			return connection.getInputStream();
		} catch (UnsupportedEncodingException | MalformedURLException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
	}
695062
function(query, callback) {
      return nano.request({ path: encodeURIComponent(db) + '/_find',
        method: 'post',
        body: query}, callback);
    }
1122357
def query(self):
        
        query_context = QueryContext(**json.loads(request.form.get('query_context')))
        security_manager.assert_datasource_permission(query_context.datasource)
        payload_json = query_context.get_payload()
        return json.dumps(
            payload_json,
            default=utils.json_int_dttm_ser,
            ignore_nan=True,
        )
809135
def vtquery(apikey, checksums):
    """"""
    data = {'apikey': apikey,
            'resource': isinstance(checksums, str) and checksums
                        or ', '.join(checksums)}

    while 1:
        response = requests.post(VT_REPORT_URL, data=data)
        response.raise_for_status()

        if response.status_code == 200:
            return response.json()
        elif response.status_code == 204:
            logging.debug("API key request rate limit reached, throttling.")
            time.sleep(VT_THROTTLE)
        else:
            raise RuntimeError("Response status code %s" % response.status_code)
831148
function Vultr(apiKey) {
  this.version = 'v1';
  this.endpoint = 'https://api.vultr.com/' + this.version + '/';
  this.apiKey = (apiKey ? apiKey : config.vultr.apiKey);

  this.account = new account(this);
  this.dns = new dns(this);
  this.os = new os(this);
  this.iso = new iso(this);
  this.backup = new backup(this);
  this.plans = new plans(this);
  this.regions = new regions(this);
  this.server = new server(this);
  this.snapshot = new snapshot(this);
  this.sshkey = new sshkey(this);
  this.startupscript = new startupscript(this);
}
185620
def get(self, type: Type[T], query: Mapping[str, Any], context: PipelineContext = None) -> T:
        
        pass
57796
def query(self):
        """"""

        if not hasattr(self, '_decoded_query'):
            self._decoded_query = list(urls._url_decode_impl(
                self.querystr.split('&'), 'utf-8', False, True, 'strict'))
        return self.query_cls(self._decoded_query)