func NewAnnotateImageSource(source string) *vision.Image {
	return &vision.Image{
		Source: &vision.ImageSource{
			GcsImageUri: source,
		},
	}
}
NewAnnotateImageSource returns a pointer to a new vision's Image.
It's contained external image source (i.e. Google Cloud Storage image
location).
package pigeon
import (
	"context"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"golang.org/x/oauth2/google"
	vision "google.golang.org/api/vision/v1"
	"github.com/kaneshin/pigeon/credentials"
)
type (
	Client struct {
		config *Config
		service *vision.Service
	}
)
func New(c *Config, httpClient ...*http.Client) (*Client, error) {
	if c == nil {
		c = NewConfig()
	}
	if len(httpClient) > 0 {
		srv, err := vision.New(httpClient[0])
		if err != nil {
			return nil, fmt.Errorf("Unable to retrieve vision Client %v", err)
		}
		return &Client{
			config:  c,
			service: srv,
		}, nil
	}
	if c.Credentials == nil {
		c.Credentials = credentials.NewApplicationCredentials("")
	}
	creds, err := c.Credentials.Get()
	if err != nil {
		return nil, err
	}
	b, err := json.Marshal(creds)
	config, err := google.JWTConfigFromJSON(b, vision.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("Unable to parse client secret file to config: %v", err)
	}
	client := config.Client(context.Background())
	srv, err := vision.New(client)
	if err != nil {
		return nil, fmt.Errorf("Unable to retrieve vision Client %v", err)
	}
	return &Client{
		config:  c,
		service: srv,
	}, nil
}
func (c Client) ImagesService() *vision.ImagesService {
	return c.service.Images
}
func (c Client) NewBatchAnnotateImageRequest(list []string, features ...*vision.Feature) (*vision.BatchAnnotateImagesRequest, error) {
	batch := &vision.BatchAnnotateImagesRequest{}
	batch.Requests = []*vision.AnnotateImageRequest{}
	for _, v := range list {
		req, err := c.NewAnnotateImageRequest(v, features...)
		if err != nil {
			return nil, err
		}
		batch.Requests = append(batch.Requests, req)
	}
	return batch, nil
}
func (c Client) NewAnnotateImageRequest(v interface{}, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
	switch v.(type) {
	case []byte:
		return NewAnnotateImageContentRequest(v.([]byte), features...)
	case string:
		u, err := url.Parse(v.(string))
		if err != nil {
			return nil, err
		}
		switch u.Scheme {
		case "gs":
			return NewAnnotateImageSourceRequest(u.String(), features...)
		case "http", "https":
			httpClient := c.config.HTTPClient
			if httpClient == nil {
				httpClient = http.DefaultClient
			}
			resp, err := httpClient.Get(u.String())
			if err != nil {
				return nil, err
			}
			defer resp.Body.Close()
			if resp.StatusCode >= http.StatusBadRequest {
				return nil, http.ErrMissingFile
			}
			body, err := ioutil.ReadAll(resp.Body)
			if err != nil {
				return nil, err
			}
			return c.NewAnnotateImageRequest(body, features...)
		}
		b, err := ioutil.ReadFile(v.(string))
		if err != nil {
			return nil, err
		}
		return c.NewAnnotateImageRequest(b, features...)
	}
	return &vision.AnnotateImageRequest{}, nil
}
func NewAnnotateImageContentRequest(body []byte, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
	req := &vision.AnnotateImageRequest{
		Image:    NewAnnotateImageContent(body),
		Features: features,
	}
	return req, nil
}
func NewAnnotateImageSourceRequest(source string, features ...*vision.Feature) (*vision.AnnotateImageRequest, error) {
	req := &vision.AnnotateImageRequest{
		Image:    NewAnnotateImageSource(source),
		Features: features,
	}
	return req, nil
}
func NewAnnotateImageContent(body []byte) *vision.Image {
	return &vision.Image{
		Content: base64.StdEncoding.EncodeToString(body),
	}
}