func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacenter, *Response, error) {
	path := "/datacenters?name=" + url.QueryEscape(name)
	req, err := c.client.NewRequest(ctx, "GET", path, nil)
	if err != nil {
		return nil, nil, err
	}
	var body schema.DatacenterListResponse
	resp, err := c.client.Do(req, &body)
	if err != nil {
		return nil, nil, err
	}
	if len(body.Datacenters) == 0 {
		return nil, resp, nil
	}
	return DatacenterFromSchema(body.Datacenters[0]), resp, nil
}
GetByName retrieves an datacenter by its name.
package hcloud
import (
	"context"
	"fmt"
	"net/url"
	"strconv"
	"github.com/hetznercloud/hcloud-go/hcloud/schema"
)
type Datacenter struct {
	ID          int
	Name        string
	Description string
	Location    *Location
	ServerTypes DatacenterServerTypes
}
type DatacenterServerTypes struct {
	Supported []*ServerType
	Available []*ServerType
}
type DatacenterClient struct {
	client *Client
}
func (c *DatacenterClient) GetByID(ctx context.Context, id int) (*Datacenter, *Response, error) {
	req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/datacenters/%d", id), nil)
	if err != nil {
		return nil, nil, err
	}
	var body schema.DatacenterGetResponse
	resp, err := c.client.Do(req, &body)
	if err != nil {
		if IsError(err, ErrorCodeNotFound) {
			return nil, resp, nil
		}
		return nil, resp, err
	}
	return DatacenterFromSchema(body.Datacenter), resp, nil
}