api

package
v0.7.4 Latest Latest
Warning

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

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

Documentation

Overview

Package api contains the common code shared by all Azure API libraries.

Index

Constants

View Source
const AzureTimeFormat = "2006-01-02T15:04:05Z"

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(res *http.Response) error

CheckResponse returns an error (of type *Error) if the response status code is not 2xx.

func ExpandURL

func ExpandURL(u *url.URL, expansions map[string]string) error

ExpandURL subsitutes any {{encoded}} strings in the URL passed in using the map supplied.

func ResolveRelative

func ResolveRelative(basestr, relstr string) string

ResolveRelative combines a url base with a relative path.

Types

type Error

type Error struct {
	// StatusCode is the HTTP response status code and will always be populated.
	StatusCode int `json:"statusCode"`
	// Code is the API error code that is given in the error message.
	Code string `json:"code"`
	// Message is the server response message and is only populated when
	// explicitly referenced by the JSON server response.
	Message string `json:"message"`
	// Body is the raw response returned by the server.
	// It is often but not always JSON, depending on how the request fails.
	Body string
	// Header contains the response header fields from the server.
	Header http.Header
	// URL is the URL of the original HTTP request and will always be populated.
	URL string
}

Error contains an error response from the server.

func (*Error) Error

func (e *Error) Error() string

Error converts the Error type to a readable string.

type JSONTime

type JSONTime time.Time

JSONTime assumes the time format is RFC3339.

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON ensures that the time is serialized as RFC3339.

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that the time is deserialized as RFC3339.

type ResponseMetadata

type ResponseMetadata struct {
	// HTTPStatusCode is the server's response status code.
	HTTPStatusCode int
	// Header contains the response header fields from the server.
	Header http.Header
}

ResponseMetadata is embedded in each response and contains the HTTP response code and headers from the server.

Jump to

Keyboard shortcuts

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