internal

package
v2.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package internal contains functionality that is only accessible from within the Admin SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Opts      []option.ClientOption
	Creds     *google.DefaultCredentials
	ProjectID string
	Version   string
}

AuthConfig represents the configuration of Firebase Auth service.

type ErrorParser

type ErrorParser func([]byte) string

ErrorParser is a function that is used to construct custom error messages.

type HTTPClient

type HTTPClient struct {
	Client    *http.Client
	ErrParser ErrorParser
}

HTTPClient is a convenient API to make HTTP calls.

This API handles some of the repetitive tasks such as entity serialization and deserialization involved in making HTTP calls. It provides a convenient mechanism to set headers and query parameters on outgoing requests, while enforcing that an explicit context is used per request. Responses returned by HTTPClient can be easily parsed as JSON, and provide a simple mechanism to extract error details.

func (*HTTPClient) Do

func (c *HTTPClient) Do(ctx context.Context, r *Request) (*Response, error)

Do executes the given Request, and returns a Response.

type HTTPEntity

type HTTPEntity interface {
	Bytes() ([]byte, error)
	Mime() string
}

HTTPEntity represents a payload that can be included in an outgoing HTTP request.

func NewJSONEntity

func NewJSONEntity(v interface{}) HTTPEntity

NewJSONEntity creates a new HTTPEntity that will be serialized into JSON.

type HTTPOption

type HTTPOption func(*http.Request)

HTTPOption is an additional parameter that can be specified to customize an outgoing request.

func WithHeader

func WithHeader(key, value string) HTTPOption

WithHeader creates an HTTPOption that will set an HTTP header on the request.

func WithQueryParam

func WithQueryParam(key, value string) HTTPOption

WithQueryParam creates an HTTPOption that will set a query parameter on the request.

func WithQueryParams

func WithQueryParams(qp map[string]string) HTTPOption

WithQueryParams creates an HTTPOption that will set all the entries of qp as query parameters on the request.

type InstanceIDConfig

type InstanceIDConfig struct {
	Opts      []option.ClientOption
	ProjectID string
}

InstanceIDConfig represents the configuration of Firebase Instance ID service.

type MessagingConfig

type MessagingConfig struct {
	Opts      []option.ClientOption
	ProjectID string
	Version   string
}

MessagingConfig represents the configuration of Firebase Cloud Messaging service.

type MockTokenSource

type MockTokenSource struct {
	AccessToken string
}

MockTokenSource is a TokenSource implementation that can be used for testing.

func (*MockTokenSource) Token

func (ts *MockTokenSource) Token() (*oauth2.Token, error)

Token returns the test token associated with the TokenSource.

type Request

type Request struct {
	Method string
	URL    string
	Body   HTTPEntity
	Opts   []HTTPOption
}

Request contains all the parameters required to construct an outgoing HTTP request.

type Response

type Response struct {
	Status int
	Header http.Header
	Body   []byte
	// contains filtered or unexported fields
}

Response contains information extracted from an HTTP response.

func (*Response) CheckStatus

func (r *Response) CheckStatus(want int) error

CheckStatus checks whether the Response status code has the given HTTP status code.

Returns an error if the status code does not match. If an ErroParser is specified, uses that to construct the returned error message. Otherwise includes the full response body in the error.

func (*Response) Unmarshal

func (r *Response) Unmarshal(want int, v interface{}) error

Unmarshal checks if the Response has the given HTTP status code, and if so unmarshals the response body into the variable pointed by v.

Unmarshal uses https://golang.org/pkg/encoding/json/#Unmarshal internally, and hence v has the same requirements as the json package.

type StorageConfig

type StorageConfig struct {
	Opts   []option.ClientOption
	Bucket string
}

StorageConfig represents the configuration of Google Cloud Storage service.

Jump to

Keyboard shortcuts

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