// GetZone retrieves a DNS Zone for a given hostname
555933
func GetZone(hostname string) (*Zone, error) {
	zone := NewZone(hostname)
	req, err := client.NewRequest(
		Config,
		"GET",
		"/config-dns/v1/zones/"+hostname,
		nil,
	)
	if err != nil {
		return nil, err
	}

	res, err := client.Do(Config, req)
	if err != nil {
		return nil, err
	}

	if client.IsError(res) && res.StatusCode != 404 {
		return nil, client.NewAPIError(res)
	} else if res.StatusCode == 404 {
		return nil, &ZoneError{zoneName: hostname}
	} else {
		err = client.BodyJSON(res, zone)
		if err != nil {
			return nil, err
		}

		return zone, nil
	}
}
1367845
func (p *propZone) GetZoneID() int64 {
	if p.Zone == nil {
		return -1
	}
	return p.Zone.GetID()
}
79349
func (f *FakeCloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error) {
	f.addCall("get-zone-by-node-name")
	return f.Zone, f.Err
}
783091
func (pc *PCCloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error) {
	return cloudprovider.Zone{}, errors.New("GetZoneByProviderID not implemented")
}
1339130
func (api *ZonesAPI) GetAll() (result *Zones, err error) {
	uri := api.client.Endpoint + zoneUrl
	res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions)
	if err != nil {
		return
	}

	result = &Zones{}
	err = json.Unmarshal(res, result)
	return
}
336694
func (api *API) ListZones(z ...string) ([]Zone, error) {
	v := url.Values{}
	var res []byte
	var r ZonesResponse
	var zones []Zone
	var err error
	if len(z) > 0 {
		for _, zone := range z {
			v.Set("name", zone)
			res, err = api.makeRequest("GET", "/zones?"+v.Encode(), nil)
			if err != nil {
				return []Zone{}, errors.Wrap(err, errMakeRequestError)
			}
			err = json.Unmarshal(res, &r)
			if err != nil {
				return []Zone{}, errors.Wrap(err, errUnmarshalError)
			}
			if !r.Success {
				// TODO: Provide an actual error message instead of always returning nil
				return []Zone{}, err
			}
			for zi := range r.Result {
				zones = append(zones, r.Result[zi])
			}
		}
	} else {
		res, err = api.makeRequest("GET", "/zones?per_page=50", nil)
		if err != nil {
			return []Zone{}, errors.Wrap(err, errMakeRequestError)
		}
		err = json.Unmarshal(res, &r)
		if err != nil {
			return []Zone{}, errors.Wrap(err, errUnmarshalError)
		}

		totalPageCount := r.TotalPages
		var wg sync.WaitGroup
		wg.Add(totalPageCount)
		errc := make(chan error)

		for i := 1; i <= totalPageCount; i++ {
			go func(pageNumber int) error {
				res, err = api.makeRequest("GET", fmt.Sprintf("/zones?per_page=50&page=%d", pageNumber), nil)
				if err != nil {
					errc <- err
				}

				err = json.Unmarshal(res, &r)
				if err != nil {
					errc <- err
				}

				for _, zone := range r.Result {
					zones = append(zones, zone)
				}

				select {
				case err := <-errc:
					return err
				default:
					wg.Done()
				}

				return nil
			}(i)
		}

		wg.Wait()
	}

	return zones, nil
}
828770
func (p *PingEvent) GetZen() string {
	if p == nil || p.Zen == nil {
		return ""
	}
	return *p.Zen
}
962878
func (s *DomainsService) GetDomain(accountID string, domainIdentifier string) (*domainResponse, error) {
	path := versioned(domainPath(accountID, domainIdentifier))
	domainResponse := &domainResponse{}

	resp, err := s.client.get(path, domainResponse)
	if err != nil {
		return nil, err
	}

	domainResponse.HttpResponse = resp
	return domainResponse, nil
}
56040
func (cs *CSCloud) GetZoneByProviderID(ctx context.Context, providerID string) (cloudprovider.Zone, error) {
	zone := cloudprovider.Zone{}

	instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByID(
		providerID,
		cloudstack.WithProject(cs.projectID),
	)
	if err != nil {
		if count == 0 {
			return zone, fmt.Errorf("could not find node by ID: %v", providerID)
		}
		return zone, fmt.Errorf("error retrieving zone: %v", err)
	}

	klog.V(2).Infof("Current zone is %v", cs.zone)
	zone.FailureDomain = instance.Zonename
	zone.Region = instance.Zonename

	return zone, nil
}
924922
func (p *proxy_PerHost) AddZone(zone string) {
	if strings.HasSuffix(zone, ".") {
		zone = zone[:len(zone)-1]
	}
	if !strings.HasPrefix(zone, ".") {
		zone = "." + zone
	}
	p.bypassZones = append(p.bypassZones, zone)
}
160819
func (c *Client) GetDomain(i *GetDomainInput) (*Domain, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Name == "" {
		return nil, ErrMissingName
	}

	path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.Service, i.Version, i.Name)
	resp, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var d *Domain
	if err := decodeJSON(&d, resp.Body); err != nil {
		return nil, err
	}
	return d, nil
}
1220176
func (c *ConvenientClient) DeleteZone(zone string) error {
	url := fmt.Sprintf("Zone/%s/", zone)

	if err := c.Do("DELETE", url, nil, nil); err != nil {
		return fmt.Errorf("Failed to delete zone: %s", err)
	}

	return nil
}
264892
func (os *OpenStack) GetZone() (cloudprovider.Zone, error) {
	md, err := getMetadata()
	if err != nil {
		return cloudprovider.Zone{}, err
	}

	zone := cloudprovider.Zone{
		FailureDomain: md.AvailabilityZone,
		Region:        os.region,
	}
	glog.V(1).Infof("Current zone is %v", zone)

	return zone, nil
}
951183
func (client *Client) AddZone(args *AddZoneArgs) (response *AddZoneResponse, err error) {
	response = &AddZoneResponse{}

	err = client.Invoke("AddZone", args, &response)

	return response, err
}
110968
func GetDomain(ctx sessionctx.Context) *Domain {
	v, ok := ctx.Value(domainKey).(*Domain)
	if !ok {
		return nil
	}
	return v
}
603362
func (l *Locale) GetDomain() string {
	l.RLock()
	dom := l.defaultDomain
	l.RUnlock()
	return dom
}
1017327
func (api *API) DeleteZone(zoneID string) (ZoneID, error) {
	res, err := api.makeRequest("DELETE", "/zones/"+zoneID, nil)
	if err != nil {
		return ZoneID{}, errors.Wrap(err, errMakeRequestError)
	}
	var r ZoneIDResponse
	err = json.Unmarshal(res, &r)
	if err != nil {
		return ZoneID{}, errors.Wrap(err, errUnmarshalError)
	}
	return r.Result, nil
}