// doGCForRegion used for gc for region.
// these two errors should not return together, for more, see the func 'doGC'
425309
func (w *gcTaskWorker) doGCForRegion(bo *tikv.Backoffer, safePoint uint64, region tikv.RegionVerID) (*errorpb.Error, error) {
	req := &tikvrpc.Request{
		Type: tikvrpc.CmdGC,
		GC: &kvrpcpb.GCRequest{
			SafePoint: safePoint,
		},
	}

	resp, err := w.store.SendReq(bo, req, region, tikv.GCTimeout)
	if err != nil {
		return nil, errors.Trace(err)
	}
	regionErr, err := resp.GetRegionError()
	if err != nil {
		return nil, errors.Trace(err)
	}
	if regionErr != nil {
		return regionErr, nil
	}

	gcResp := resp.GC
	if gcResp == nil {
		return nil, errors.Trace(tikv.ErrBodyMissing)
	}
	if gcResp.GetError() != nil {
		return nil, errors.Errorf("unexpected gc error: %s", gcResp.GetError())
	}

	return nil, nil
}
459735
func (c *codecPDClient) GetRegion(ctx context.Context, key []byte) (*metapb.Region, *metapb.Peer, error) {
	encodedKey := codec.EncodeBytes([]byte(nil), key)
	region, peer, err := c.Client.GetRegion(ctx, encodedKey)
	return processRegionResult(region, peer, err)
}
248962
func (s *Connection) SetRegion(v string) *Connection {
	s.Region = &v
	return s
}
1225318
func (env *joyentEnviron) Region() (simplestreams.CloudSpec, error) {
	return simplestreams.CloudSpec{
		Region:   env.cloud.Region,
		Endpoint: env.cloud.Endpoint,
	}, nil
}
419475
func (c *RegionsClient) Create(ctx context.Context, createRegion *CreateRegion) (*Region, error) {
	p := "/regions/"

	req, err := c.backend.NewRequest(http.MethodPost, p, nil, createRegion)
	if err != nil {
		return nil, err
	}

	var resp Region
	_, err = c.backend.Do(ctx, req, &resp, func(code int) error {
		switch code {
		case 400, 409, 500:
			return &Error{}
		default:
			return nil
		}
	})
	if err != nil {
		return nil, err
	}

	return &resp, nil
}
513055
func (s *ElasticLoadBalancer) SetRegion(v string) *ElasticLoadBalancer {
	s.Region = &v
	return s
}
134620
func (s *AlarmIdentifier) SetRegion(v string) *AlarmIdentifier {
	s.Region = &v
	return s
}
1324801
func (g *Cloud) CreateRegionForwardingRule(rule *compute.ForwardingRule, region string) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newForwardingRuleMetricContext("create", region)
	return mc.Observe(g.c.ForwardingRules().Insert(ctx, meta.RegionalKey(rule.Name, region), rule))
}
957823
func (c *Config) WithRegion(region string) *Config {
	c.Region = &region
	return c
}
422090
func (s *TrustedAdvisorResourceDetail) SetRegion(v string) *TrustedAdvisorResourceDetail {
	s.Region = &v
	return s
}
187135
func (p *propZone) GetRegion() *Region {
	if p.Zone == nil {
		return nil
	}
	return p.Zone.GetRegion()
}
26902
func (s *ResourceCountFilters) SetRegion(v string) *ResourceCountFilters {
	s.Region = &v
	return s
}
730183
func RegionName(s string) (string, error) {
	name, err := RegionCodeInfo(s)
	return name, err
}
465629
func (c *Config) determineRegion(region string) string {
	// If a resource-level region was not specified, and a provider-level region was set,
	// use the provider-level region.
	if region == "" && c.Region != "" {
		region = c.Region
	}

	log.Printf("[DEBUG] OpenStack Region is: %s", region)
	return region
}
1315641
func (a *Agent) Region() (string, error) {
	// Return from cache if we have it
	if a.region != "" {
		return a.region, nil
	}

	// Query the agent for the region
	_, err := a.Self()
	return a.region, err
}
1179871
func getCountryCodeForValidRegion(regionCode string) int {
	var metadata *PhoneMetadata = getMetadataForRegion(regionCode)
	return int(metadata.GetCountryCode())
}
175679
func ZonesOfRegion(hc *http.Client, project, region string) (zones []string, err error) {
	s, err := compute.New(hc)
	if err != nil {
		return nil, err
	}
	zl, err := compute.NewZonesService(s).List(project).Do()
	if err != nil {
		return nil, fmt.Errorf("could not get a list of zones: %v", err)
	}
	if zl.NextPageToken != "" {
		return nil, errors.New("TODO: more than one page of zones found; use NextPageToken")
	}
	for _, z := range zl.Items {
		if path.Base(z.Region) != region {
			continue
		}
		zones = append(zones, z.Name)
	}
	return zones, nil
}