func (c *Client) Authentication() Authentication {
	return c.authentication
}
Authentication returns the client's current Authentication object
package codeship
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httputil"
	"os"
	"regexp"
	"strings"
	"time"
	"github.com/pkg/errors"
)
var ErrRateLimitExceeded = errors.New("rate limit exceeded")
type ErrNotFound struct {
	apiErrors
}
type ErrBadRequest struct {
	apiErrors
}
type apiErrors struct {
	Errors []string `json:"errors"`
}
func (e apiErrors) Error() string {
	return strings.Join(e.Errors, ", ")
}
type Organization struct {
	UUID   string
	Name   string
	Scopes []string
	client *Client
}
type Response struct {
	*http.Response
	Links
}
var (
	urlRegex = regexp.MustCompile(`\s*<(.+)>`)
	relRegex = regexp.MustCompile(`\s*rel="(\w+)"`)
)
func newResponse(r *http.Response) Response {
	response := Response{Response: r}
	if linkText := r.Header.Get("Link"); linkText != "" {
		linkMap := make(map[string]string)
		for _, chunk := range strings.Split(linkText, ",") {
			pieces := strings.Split(chunk, ";")
			urlMatch := urlRegex.FindStringSubmatch(pieces[0])
			relMatch := relRegex.FindStringSubmatch(pieces[1])
			if len(relMatch) > 1 && len(urlMatch) > 1 {
				linkMap[relMatch[1]] = urlMatch[1]
			}
		}
		response.Links.First = linkMap["first"]
		response.Links.Last = linkMap["last"]
		response.Links.Next = linkMap["next"]
		response.Links.Previous = linkMap["prev"]
	}
	return response
}
const apiURL = "https://api.codeship.com/v2"
type StdLogger interface {
	Println(...interface{})
}
var _ StdLogger = &log.Logger{}
type Client struct {
	baseURL        string
	authenticator  Authenticator
	authentication Authentication
	headers        http.Header
	httpClient     *http.Client
	logger         StdLogger
	verbose        bool
}
func New(auth Authenticator, opts ...Option) (*Client, error) {
	if auth == nil {
		return nil, errors.New("no authenticator provided")
	}
	client := &Client{
		authenticator: auth,
		baseURL:       apiURL,
		headers:       make(http.Header),
	}
	if err := client.parseOptions(opts...); err != nil {
		return nil, errors.Wrap(err, "options parsing failed")
	}
	if client.httpClient == nil {
		client.httpClient = &http.Client{
			Timeout: time.Second * 30,
		}
	}
	if client.logger == nil {
		logger := &log.Logger{}
		logger.SetOutput(os.Stdout)
		client.logger = logger
	}
	return client, nil
}
func (c *Client) Organization(ctx context.Context, name string) (*Organization, error) {
	if name == "" {
		return nil, errors.New("no organization name provided")
	}
	if c.AuthenticationRequired() {
		if _, err := c.Authenticate(ctx); err != nil {
			return nil, errors.Wrap(err, "authentication failed")
		}
	}
	for _, org := range c.authentication.Organizations {
		if org.Name == strings.ToLower(name) {
			return &Organization{
				UUID:   org.UUID,
				Name:   org.Name,
				Scopes: org.Scopes,
				client: c,
			}, nil
		}
	}
	return nil, ErrUnauthorized(fmt.Sprintf("organization %q not authorized. Authorized organizations: %v", name, c.authentication.Organizations))
}