Do a query to the System API

        :param path: url to the API
        :param method: the kind of query to do
        :param params: a dict with all the
        necessary things to query the API
        :return json data
542618
async def query(self, path, method='get', **params):
        
        if method in ('get', 'post', 'patch', 'delete', 'put'):
            full_path = self.host + path
            if method == 'get':
                resp = await self.aio_sess.get(full_path, params=params)
            elif method == 'post':
                resp = await self.aio_sess.post(full_path, data=params)
            elif method == 'patch':
                resp = await self.aio_sess.patch(full_path, data=params)
            elif method == 'delete':
                resp = await self.aio_sess.delete(full_path, params=params, headers=params)
            elif method == 'put':
                resp = await self.aio_sess.put(full_path, data=params)

            async with resp:
                # return the content if its a binary one
                if resp.content_type.startswith('application/pdf') or \
                        resp.content_type.startswith('application/epub'):
                    return await resp.read()

                return await self.handle_json_response(resp)
        else:
            raise ValueError('method expected: get, post, patch, delete, put')
921149
function makeRequest (path, params) {
    // The api key will always be sent as a query parameter
    params = params || {}
    params.token = apiKey

    return new Promise(function (resolve, reject) {
      request(`${hostname}${path}?${querystring.stringify(params)}`,
        function (error, response, body) {
          if (error) {
            reject(error)
          }
          try {
            var result = JSON.parse(body)
            if (response.statusCode === 200) {
              resolve(result)
            }
            reject(result.error)
          } catch (error) {
            reject(response.statusMessage)
          }
        })
    })
  }
1372332
def get(path, params = {})
      headers = request_headers(:get, path, params)
      request(:get, path, params, headers)
    end
854495
def request(http_method, path, params)
      response = connection.send(http_method, path, params)
      response.body
    end
569196
def send_method_request(self, method: str, method_params: dict) -> dict:
        
        url = '/'.join((self.METHOD_URL, method))
        method_params['v'] = self.API_VERSION
        if self._access_token:
            method_params['access_token'] = self._access_token
        response = self.post(url, method_params, timeout=10)
        response.raise_for_status()
        return json.loads(response.text)
1145188
def request(self, method, path, params=None, headers=None, body=None):
        
        if not headers:
            headers = {}
        if not params:
            params = {}

        headers["Accept"] = "application/json"
        headers["Accept-Version"] = "^1.15.0"
        if self.auth_token:
            headers["Authorization"] = "Bearer {0}".format(self.auth_token)

        path = self.url + path
        params = self.flatten_params(params)
        response = requests.request(method, path, params=params, headers=headers, json=body)

        result = response.text
        try:
            result = response.json()
        except Exception:
            pass

        if response.status_code >= 400:
            raise LosantError(response.status_code, result)

        return result
1893
def request(method, path, options, format)
      begin
        response = connection(format).send(method) do |request|
          case method.to_sym
          when :get, :delete
            request.url(formatted_path(path, format), options)
          when :post, :put
            request.path = formatted_path(path, format)
            request.body = options unless options.empty?
          end
      end
        'raw' == format.to_s.downcase ? response : response.body
      rescue MultiJson::DecodeError
        Hashie::Mash.new
      end
    end
1206359
def request(method, path, options = {})
      options = options.dup

      raw = raw? || options.delete(:raw)
      params(options)
      response = connection.send method, path, (@raw_body || @params), @headers
      raw ? response : @scopeable.parse(response)
    end
301610
def post_query(path, data = {})
      @request_uri = "#{@base_uri}#{path}" 
      body = URI.encode_www_form(data)
      extheader = { 'Content-Type' => 'application/x-www-form-urlencoded' }
      req  = post_request(path, body, extheader)
      @res = http_connection.start {|http| http.request(req) }
      handle_error(@res, @request_uri)
      JSON.parse(@res.body)
    end
962825
protected HttpUriRequest setupRequestJson(final String path, final String method, final String params) {
        final HttpUriRequest request = buildMethod(method, path, params);
        request.addHeader(new BasicHeader("Accept", "application/json"));
        request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));
        request.setHeader(new BasicHeader("Authorization", "Basic " + new String(Base64.encodeBase64((this.token + ":" + this.secret).getBytes()))));
        return request;
    }
586491
def get(path, params = {})
      uri = path
      if params.count > 0
        uri += "?#{URI.encode_www_form(params)}"
      end

      headers = {}

      request('GET', uri, nil, headers) do |resp|
        if params[:fetch_all] == true &&
            resp.body.has_key?('pagination') &&
            resp.body['pagination']['next_uri'] != nil
          params[:starting_after] = resp.body['data'].last['id']
          get(path, params) do |page|
            body = resp.body
            body['data'] += page.data
            resp.body = body
            yield(resp) if block_given?
          end
        else
          yield(resp) if block_given?
        end
      end
    end
767395
def get(path, params = nil, headers = {}, auth = true)
      request(path: path, query: params, headers: headers, auth: auth)
    end
132708
def request(http_method, path, body = '', headers = {})
      puts "#{http_method}: #{path} - [#{body}]" if @http_debug
      @request_client.request(http_method, path, body, headers)
    end
1260909
def execute(method, path, parameters, headers = { accept: :json }, &block)
      payload = {}.merge(parameters)
      url = base_url + path

      request_arguments = {
        method:  method,
        url:     url,
        payload: payload,
        headers: headers
      }

      RestClient::Request.execute(request_arguments, &block)
    rescue RestClient::Unauthorized
      raise AuthError, "Authentication failed"
    rescue RestClient::InternalServerError
      raise ServerError, "Server error"
    rescue RestClient::Forbidden => e
      raise BadRequest, e.http_body
    end
660616
def get(self, path, data=None, return_fields=None):
        
        return self.session.get(self._request_url(path, return_fields),
                                data=json.dumps(data),
                                auth=self.auth, verify=False)
1055420
def request(self, method, resource, params=None):
        

        url = self.get_url(resource, params)

        # headers

        headers = {
            'Content-Type': 'application/json'
        }

        auth = requests.auth.HTTPBasicAuth(self.username, self.password)

        # request

        log.info('Request to %s. Data: %s' % (url, params))

        response = requests.request(method, url, data=json.dumps(params), headers=headers, auth=auth)
        response.raise_for_status()

        # response

        log.info('Response from %s: %s' % (url, response.text))
        content = response.json()

        self.parse_status(content.get('status'))

        return content
207028
def _query(method='GET', profile=None, url=None, path='api/v1',
           action=None, api_key=None, service=None, params=None,
           data=None, subdomain=None, verify_ssl=True):
    '''
    

    '''

    if profile:
        creds = __salt__['config.option'](profile)
    else:
        creds = {
            'pagerduty.api_key': api_key,
            'pagerduty.subdomain': subdomain,
        }

    if url is None:
        url = 'https://{0}.pagerduty.com/{1}/{2}'.format(
            creds['pagerduty.subdomain'],
            path,
            action
        )

    if params is None:
        params = {}

    if data is None:
        data = {}

    headers = {
        'Authorization': 'Token token={0}'.format(creds['pagerduty.api_key'])
    }

    if method != 'GET':
        headers['Content-type'] = 'application/json'

    result = requests.request(
        method,
        url,
        headers=headers,
        params=params,
        data=salt.utils.json.dumps(data),
        verify=verify_ssl
    )

    if result.text is None or result.text == '':
        return None
    result_json = result.json()
    # if this query supports pagination, loop and fetch all results, merge them together
    if 'total' in result_json and 'offset' in result_json and 'limit' in result_json:
        offset = result_json['offset']
        limit = result_json['limit']
        total = result_json['total']
        while offset + limit < total:
            offset = offset + limit
            limit = 100
            data['offset'] = offset
            data['limit'] = limit
            next_page_results = requests.request(method,
                                                 url,
                                                 headers=headers,
                                                 params=params,
                                                 data=data,  # Already serialized above, don't do it again
                                                 verify=verify_ssl).json()
            offset = next_page_results['offset']
            limit = next_page_results['limit']
            # merge results
            for k, v in result_json.items():
                if isinstance(v, list):
                    result_json[k] += next_page_results[k]
    return result_json