net

package
v6.46.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 29 Imported by: 602

Documentation

Index

Constants

View Source
const (
	JobFinished            = "finished"
	JobFailed              = "failed"
	DefaultPollingThrottle = 5 * time.Second
	DefaultDialTimeout     = 5 * time.Second
)
View Source
const DeprecatedEndpointWarning = "Endpoint deprecated"

Variables

View Source
var NewHTTPClient = func(tr *http.Transport, dumper RequestDumper) HTTPClientInterface {
	c := client{
		&http.Client{
			Transport: tr,
		},
		dumper,
	}
	c.CheckRedirect = c.checkRedirect

	return &c
}

Functions

func NewTLSConfig

func NewTLSConfig(trustedCerts []tls.Certificate, disableSSL bool) (TLSConfig *tls.Config)

func WrapNetworkErrors

func WrapNetworkErrors(host string, err error) error

Types

type AsyncResource

type AsyncResource struct {
	Metadata struct {
		URL string
	}
}

type Gateway

type Gateway struct {
	PollingEnabled  bool
	PollingThrottle time.Duration

	Clock func() time.Time

	DialTimeout time.Duration
	// contains filtered or unexported fields
}

func NewCloudControllerGateway

func NewCloudControllerGateway(config coreconfig.Reader, clock func() time.Time, ui terminal.UI, logger trace.Printer, envDialTimeout string) Gateway

func NewRoutingAPIGateway

func NewRoutingAPIGateway(config coreconfig.Reader, clock func() time.Time, ui terminal.UI, logger trace.Printer, envDialTimeout string) Gateway

func NewUAAGateway

func NewUAAGateway(config coreconfig.Reader, ui terminal.UI, logger trace.Printer, envDialTimeout string) Gateway

func (*Gateway) AsyncTimeout

func (gateway *Gateway) AsyncTimeout() time.Duration

func (Gateway) CreateResource

func (gateway Gateway) CreateResource(endpoint, apiURL string, body io.ReadSeeker, resource ...interface{}) error

func (Gateway) CreateResourceFromStruct

func (gateway Gateway) CreateResourceFromStruct(endpoint, url string, resource interface{}) error

func (Gateway) DeleteResource

func (gateway Gateway) DeleteResource(endpoint, apiURL string) error

func (Gateway) DeleteResourceSynchronously

func (gateway Gateway) DeleteResourceSynchronously(endpoint, apiURL string) error

func (Gateway) GetResource

func (gateway Gateway) GetResource(url string, resource interface{}) (err error)

func (Gateway) ListPaginatedResources

func (gateway Gateway) ListPaginatedResources(
	target string,
	path string,
	resource interface{},
	cb func(interface{}) bool,
) error

func (Gateway) NewRequest

func (gateway Gateway) NewRequest(method, path, accessToken string, body io.ReadSeeker) (*Request, error)

func (Gateway) NewRequestForFile

func (gateway Gateway) NewRequestForFile(method, fullURL, accessToken string, body *os.File) (*Request, error)

func (Gateway) PerformPollingRequestForJSONResponse

func (gateway Gateway) PerformPollingRequestForJSONResponse(endpoint string, request *Request, response interface{}, timeout time.Duration) (http.Header, error)

func (Gateway) PerformRequest

func (gateway Gateway) PerformRequest(request *Request) (*http.Response, error)

func (Gateway) PerformRequestForJSONResponse

func (gateway Gateway) PerformRequestForJSONResponse(request *Request, response interface{}) (http.Header, error)

func (Gateway) PerformRequestForTextResponse

func (gateway Gateway) PerformRequestForTextResponse(request *Request) (string, http.Header, error)

func (*Gateway) SetTokenRefresher

func (gateway *Gateway) SetTokenRefresher(auth tokenRefresher)

func (*Gateway) SetTrustedCerts

func (gateway *Gateway) SetTrustedCerts(certificates []tls.Certificate)

func (Gateway) UpdateResource

func (gateway Gateway) UpdateResource(endpoint, apiURL string, body io.ReadSeeker, resource ...interface{}) error

func (Gateway) UpdateResourceFromStruct

func (gateway Gateway) UpdateResourceFromStruct(endpoint, apiURL string, resource interface{}) error

func (Gateway) UpdateResourceSync

func (gateway Gateway) UpdateResourceSync(endpoint, apiURL string, body io.ReadSeeker, resource ...interface{}) error

func (Gateway) Warnings

func (gateway Gateway) Warnings() []string

type HTTPClientInterface

type HTTPClientInterface interface {
	RequestDumperInterface

	Do(*http.Request) (*http.Response, error)
	ExecuteCheckRedirect(req *http.Request, via []*http.Request) error
}

type JobResource

type JobResource struct {
	Entity struct {
		Status       string
		ErrorDetails struct {
			Description string
		} `json:"error_details"`
	}
}

type PaginatedResources

type PaginatedResources struct {
	NextURL        string          `json:"next_url"`
	ResourcesBytes json.RawMessage `json:"resources"`
	// contains filtered or unexported fields
}

func NewPaginatedResources

func NewPaginatedResources(exampleResource interface{}) PaginatedResources

func (PaginatedResources) Resources

func (pr PaginatedResources) Resources() ([]interface{}, error)

type ProgressReader

type ProgressReader struct {
	// contains filtered or unexported fields
}

func NewProgressReader

func NewProgressReader(readSeeker io.ReadSeeker, ui terminal.UI, outputInterval time.Duration) *ProgressReader

func (*ProgressReader) Read

func (progressReader *ProgressReader) Read(p []byte) (int, error)

func (*ProgressReader) Seek

func (progressReader *ProgressReader) Seek(offset int64, whence int) (int64, error)

func (*ProgressReader) SetTotalSize

func (progressReader *ProgressReader) SetTotalSize(size int64)

type Request

type Request struct {
	HTTPReq      *http.Request
	SeekableBody io.ReadSeeker
}

type RequestDumper

type RequestDumper struct {
	// contains filtered or unexported fields
}

func NewRequestDumper

func NewRequestDumper(printer trace.Printer) RequestDumper

func (RequestDumper) DumpRequest

func (p RequestDumper) DumpRequest(req *http.Request)

func (RequestDumper) DumpResponse

func (p RequestDumper) DumpResponse(res *http.Response)

type RequestDumperInterface

type RequestDumperInterface interface {
	DumpRequest(*http.Request)
	DumpResponse(*http.Response)
}

type WarningProducer

type WarningProducer interface {
	Warnings() []string
}

type WarningsCollector

type WarningsCollector struct {
	// contains filtered or unexported fields
}

func NewWarningsCollector

func NewWarningsCollector(ui terminal.UI, warningsProducers ...WarningProducer) WarningsCollector

func (WarningsCollector) PrintWarnings

func (warningsCollector WarningsCollector) PrintWarnings() error

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL