func Run(config Config) (int, error) {
	if err := config.Validate(); err != nil {
		return codeFailedConfigValidation, err
	}
	destinationFile := defaultDestinationFile
	hostAddress := fmt.Sprint(config.Host, ":", config.Port)
	cloudSpec, code, err := decodeFile(config.Source, destinationFile, config.Client)
	if err != nil {
		return code, err
	}
	if err := apivalidator.NewHTTPRequests(hostAddress, config.Client, cloudSpec); err != nil {
		cleanupFile(destinationFile)
		return codeFailedAPISpecValidation, err
	}
	defer cleanupFile(destinationFile)
	return 0, nil
}
Run runs a series of validation requests based off a specified api spec against
the specified validation proxy address.
package requests
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"time"
	"github.com/go-openapi/spec"
	"github.com/elastic/cloud-sdk-go/internal/pkg/apivalidator"
	"github.com/elastic/cloud-sdk-go/pkg/multierror"
)
const (
	_ = iota
	codeFailedConfigValidation
	codeFailedDownloadingSpec
	codeCannotReadFile
	codeFailedUnmarshalingSpec
	codeFailedAPISpecValidation
)
var (
	defaultDestinationFile = fmt.Sprint(time.Now().Format(time.RFC3339), "-apidocs.json")
	errInvalidSource = errors.New("an api specification file must be specified")
	errInvalidHost   = errors.New("a host for connecting to the validation proxy must be specified")
	errInvalidPort   = errors.New("a port for connecting to the validation proxy must be specified")
	errInvalidClient = errors.New("an http client must be specified")
)
type Config struct {
	Source string
	Host   string
	Port   string
	Client *http.Client
}
func (c Config) Validate() error {
	var err = multierror.NewPrefixed("api validation configuration")
	if c.Source == "" {
		err = err.Append(errInvalidSource)
	}
	if c.Host == "" {
		err = err.Append(errInvalidHost)
	}
	if c.Port == "" {
		err = err.Append(errInvalidPort)
	}
	if c.Client == nil {
		err = err.Append(errInvalidClient)
	}
	return err.ErrorOrNil()
}