rest

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 181

Documentation

Index

Constants

View Source
const (
	Path = "/rest"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*soap.Client
}

Client extends soap.Client to support JSON encoding, while inheriting security features, debug tracing and session persistence.

func NewClient

func NewClient(c *vim25.Client) *Client

NewClient creates a new Client instance.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) error

Do sends the http.Request, decoding resBody if provided.

func (*Client) Login

func (c *Client) Login(ctx context.Context, user *url.Userinfo) error

Login creates a new session via Basic Authentication with the given url.Userinfo.

func (*Client) LoginByToken added in v0.20.0

func (c *Client) LoginByToken(ctx context.Context) error

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

Logout deletes the current session.

func (*Client) Resource added in v0.22.0

func (c *Client) Resource(path string) *Resource

Resource helper for the given path.

func (*Client) Session added in v0.22.0

func (c *Client) Session(ctx context.Context) (*Session, error)

Session returns the user's current session. Nil is returned if the session is not authenticated.

func (*Client) WithSigner added in v0.20.0

func (c *Client) WithSigner(ctx context.Context, s Signer) context.Context

type LocalizableMessage added in v0.21.0

type LocalizableMessage struct {
	Args           []string `json:"args,omitempty"`
	DefaultMessage string   `json:"default_message,omitempty"`
	ID             string   `json:"id,omitempty"`
}

LocalizableMessage represents a localizable error

func (*LocalizableMessage) Error added in v0.21.0

func (m *LocalizableMessage) Error() string

type Resource added in v0.22.0

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

Resource wraps url.URL with helpers

func (*Resource) Request added in v0.22.0

func (r *Resource) Request(method string, body ...interface{}) *http.Request

Request returns a new http.Request for the given method. An optional body can be provided for POST and PATCH methods.

func (*Resource) String added in v0.22.0

func (r *Resource) String() string

func (*Resource) WithAction added in v0.22.0

func (r *Resource) WithAction(action string) *Resource

WithAction sets adds action to the URL.RawQuery

func (*Resource) WithID added in v0.22.0

func (r *Resource) WithID(id string) *Resource

WithID appends id to the URL.Path

func (*Resource) WithParam added in v0.22.0

func (r *Resource) WithParam(name string, value string) *Resource

WithParam sets adds a parameter to the URL.RawQuery

type Session added in v0.22.0

type Session struct {
	User         string    `json:"user"`
	Created      time.Time `json:"created_time"`
	LastAccessed time.Time `json:"last_accessed_time"`
}

Session information

type Signer added in v0.20.0

type Signer interface {
	SignRequest(*http.Request) error
}

Jump to

Keyboard shortcuts

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