// Fetch queries a whois server and returns a Response.
11961
func Fetch(query string) (*Response, error) {
	req, err := NewRequest(query)
	if err != nil {
		return nil, err
	}
	return DefaultClient.Fetch(req)
}
460208
func (t *SwitchesTable) fetch(c context.Context) error {
	db := database.Get(c)
	rows, err := db.QueryContext(c, `
		SELECT id, name, description, ports, state, rack_id
		FROM switches
	`)
	if err != nil {
		return errors.Annotate(err, "failed to select switches").Err()
	}
	defer rows.Close()
	for rows.Next() {
		s := &Switch{}
		if err := rows.Scan(&s.Id, &s.Name, &s.Description, &s.Ports, &s.State, &s.RackId); err != nil {
			return errors.Annotate(err, "failed to scan switch").Err()
		}
		t.current = append(t.current, s)
	}
	return nil
}
802914
func (t *KVMsTable) fetch(c context.Context) error {
	db := database.Get(c)
	rows, err := db.QueryContext(c, `
		SELECT k.id, h.id, h.name, i.ipv4, k.description, k.mac_address, k.state, k.platform_id, k.rack_id
		FROM kvms k, hostnames h, ips i
		WHERE k.hostname_id = h.id AND i.hostname_id = h.id
	`)
	if err != nil {
		return errors.Annotate(err, "failed to select KVMs").Err()
	}
	defer rows.Close()
	for rows.Next() {
		kvm := &KVM{}
		if err := rows.Scan(&kvm.Id, &kvm.HostnameId, &kvm.Name, &kvm.IPv4, &kvm.Description, &kvm.MacAddress, &kvm.State, &kvm.PlatformId, &kvm.RackId); err != nil {
			return errors.Annotate(err, "failed to scan KVM").Err()
		}
		t.current = append(t.current, kvm)
	}
	return nil
}
1013129
func (c *Client) Get(ctx context.Context, url string) (*http.Response, error) {
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}

	return c.Do(ctx, req)
}
1224450
func (s *SitesService) Get(id string) (*Site, *Response, error) {
	site := &Site{Id: id, client: s.client}
	site.Deploys = &DeploysService{client: s.client, site: site}
	resp, err := site.Reload()

	return site, resp, err
}
1038730
func (c *Cache) Fetch(key string, duration time.Duration, fetch func() (interface{}, error)) (*Item, error) {
	item := c.Get(key)
	if item != nil && !item.Expired() {
		return item, nil
	}
	value, err := fetch()
	if err != nil {
		return nil, err
	}
	return c.set(key, value, duration), nil
}
516461
func (i *Client) Fetch(c context.Context, digest isolated.HexDigest, dest io.Writer) error {
	// Perform initial request.
	name := ""
	switch i.h {
	case crypto.SHA1:
		name = "sha-1"
	case crypto.SHA256:
		name = "sha-256"
	case crypto.SHA512:
		name = "sha-512"
	}
	url := i.url + "/_ah/api/isolateservice/v1/retrieve"
	in := &isolateservice.HandlersEndpointsV1RetrieveRequest{
		Digest: string(digest),
		Namespace: &isolateservice.HandlersEndpointsV1Namespace{
			DigestHash: name,
			Namespace:  i.namespace,
		},
		Offset: 0,
	}
	var out isolateservice.HandlersEndpointsV1RetrievedContent
	if _, err := lhttp.PostJSON(c, i.retryFactory, i.authClient, url, nil, in, &out); err != nil {
		return err
	}

	// Handle DB items.
	if out.Content != "" {
		decoded, err := base64.StdEncoding.DecodeString(out.Content)
		if err != nil {
			return err
		}
		decompressor, err := isolated.GetDecompressor(i.namespace, bytes.NewReader(decoded))
		if err != nil {
			return err
		}
		defer decompressor.Close()
		_, err = io.Copy(dest, decompressor)
		return err
	}

	// Handle GCS items.
	return i.gcsHandler.Fetch(c, i, out, dest)
}
600456
func (httpRequester *HTTPRequester) Fetch(url string) (io.ReadCloser, error) {
	resp, err := http.Get(url)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("bad http status from %s: %v", url, resp.Status)
	}

	return resp.Body, nil
}
883218
func (t *PlatformsTable) fetch(c context.Context) error {
	db := database.Get(c)
	rows, err := db.QueryContext(c, `
		SELECT id, name, description, manufacturer
		FROM platforms
	`)
	if err != nil {
		return errors.Annotate(err, "failed to select platforms").Err()
	}
	defer rows.Close()
	for rows.Next() {
		p := &Platform{}
		if err := rows.Scan(&p.Id, &p.Name, &p.Description, &p.Manufacturer); err != nil {
			return errors.Annotate(err, "failed to scan platform").Err()
		}
		t.current = append(t.current, p)
	}
	return nil
}
981528
func (sto *overlayStorage) Fetch(ctx context.Context, br blob.Ref) (file io.ReadCloser, size uint32, err error) {
	if sto.isDeleted(br) {
		return nil, 0, os.ErrNotExist
	}

	file, size, err = sto.upper.Fetch(ctx, br)
	if err != os.ErrNotExist {
		return file, size, err
	}

	return sto.lower.Fetch(ctx, br)
}
379027
func (s *server) Fetch(ctx context.Context, req *v2.DiscoveryRequest) (*v2.DiscoveryResponse, error) {
	if s.callbacks != nil {
		if err := s.callbacks.OnFetchRequest(ctx, req); err != nil {
			return nil, err
		}
	}
	resp, err := s.cache.Fetch(ctx, *req)
	if err != nil {
		return nil, err
	}
	out, err := createResponse(resp, req.TypeUrl)
	if s.callbacks != nil {
		s.callbacks.OnFetchResponse(req, out)
	}
	return out, err
}
329809
func Fetch(urlstring string, options ...Option) (*Set, error) {
	u, err := url.Parse(urlstring)
	if err != nil {
		return nil, errors.Wrap(err, `failed to parse url`)
	}

	switch u.Scheme {
	case "http", "https":
		return FetchHTTP(urlstring, options...)
	case "file":
		f, err := os.Open(u.Path)
		if err != nil {
			return nil, errors.Wrap(err, `failed to open jwk file`)
		}
		defer f.Close()

		buf, err := ioutil.ReadAll(f)
		if err != nil {
			return nil, errors.Wrap(err, `failed read content from jwk file`)
		}
		return ParseBytes(buf)
	}
	return nil, errors.Errorf(`invalid url scheme %s`, u.Scheme)
}
802623
func (s *SearchService) FetchSource(fetchSource bool) *SearchService {
	s.searchSource = s.searchSource.FetchSource(fetchSource)
	return s
}
671557
func (r *ReindexSource) FetchSource(fetchSource bool) *ReindexSource {
	r.request = r.request.FetchSource(fetchSource)
	return r
}
551079
func Fetch(dir, target string, pool int, dynamic bool) error {
	local, err := GetOrigin(dir)
	if err != nil {
		log.Error("bad local origin:", err)
		return err
	}
	localHashes, localSource, err := local.Scan()
	if target != "" {
		localSource = target
	}
	global, err := GetOrigin(localSource)
	if err != nil {
		log.Error("bad global origin:", err)
		return err
	}
	globalHashes, globalSource, err := global.Scan()
	if globalSource != localSource {
		log.Warning("unverified origin:", globalSource)
	} else {
		log.Notice("verified origin:", globalSource)
	}

	missingHashes := Compare(localHashes, globalHashes)
	if pool < 2 {
		err = FetchSpecific(dir, global, missingHashes)
	} else {
		if dynamic {
			pool *= runtime.NumCPU()
		}
		err = FetchSpecificAsync(dir, global, missingHashes, pool)
	}
	if err != nil {
		log.Error("failed to fetch files:", err)
		return err
	}
	log.Notice("fetched", len(missingHashes), "files from origin")

	return Write(dir, globalSource, globalHashes)
}
69156
func fetch(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, src string, err error) {
	var f io.ReadCloser

	if sourceURL, timeout := adjustURL(source, duration, timeout); sourceURL != "" {
		ui.Print("Fetching profile over HTTP from " + sourceURL)
		if duration > 0 {
			ui.Print(fmt.Sprintf("Please wait... (%v)", duration))
		}
		f, err = fetchURL(sourceURL, timeout, tr)
		src = sourceURL
	} else if isPerfFile(source) {
		f, err = convertPerfData(source, ui)
	} else {
		f, err = os.Open(source)
	}
	if err == nil {
		defer f.Close()
		p, err = profile.Parse(f)
	}
	return
}
206490
func (wxa *MiniProgram) fetchData(urlStr string, body interface{}) (response []byte, err error) {
	var accessToken string
	accessToken, err = wxa.GetAccessToken()
	if err != nil {
		return
	}
	urlStr = fmt.Sprintf(urlStr, accessToken)
	response, err = util.PostJSON(urlStr, body)
	return
}