simulator

package
v0.0.0-...-5f55900 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiErrorAlreadyExists

func ApiErrorAlreadyExists(w http.ResponseWriter)

ApiErrorAlreadyExists responds with a REST error of type "ALREADY_EXISTS". For use with "/api" endpoints.

func ApiErrorGeneral

func ApiErrorGeneral(w http.ResponseWriter)

ApiErrorGeneral responds with a REST error of type "ERROR". For use with "/api" endpoints.

func ApiErrorInvalidArgument

func ApiErrorInvalidArgument(w http.ResponseWriter)

ApiErrorInvalidArgument responds with a REST error of type "INVALID_ARGUMENT". For use with "/api" endpoints.

func ApiErrorNotAllowedInCurrentState

func ApiErrorNotAllowedInCurrentState(w http.ResponseWriter)

ApiErrorNotAllowedInCurrentState responds with a REST error of type "NOT_ALLOWED_IN_CURRENT_STATE". For use with "/api" endpoints.

func ApiErrorNotFound

func ApiErrorNotFound(w http.ResponseWriter)

ApiErrorNotFound responds with a REST error of type "NOT_FOUND". For use with "/api" endpoints.

func ApiErrorResourceInUse

func ApiErrorResourceInUse(w http.ResponseWriter)

ApiErrorResourceInUse responds with a REST error of type "RESOURCE_IN_USE". For use with "/api" endpoints.

func ApiErrorUnauthorized

func ApiErrorUnauthorized(w http.ResponseWriter)

ApiErrorUnauthorized responds with a REST error of type "UNAUTHORIZED". For use with "/api" endpoints.

func ApiErrorUnsupported

func ApiErrorUnsupported(w http.ResponseWriter)

ApiErrorUnsupported responds with a REST error of type "UNSUPPORTED". For use with "/api" endpoints.

func BadRequest

func BadRequest(w http.ResponseWriter, kind string)

BadRequest responds with http.StatusBadRequest and json encoded vAPI error of type kind. For use with "/rest" endpoints where the response is a "value" wrapped structure.

func Decode

func Decode(r *http.Request, w http.ResponseWriter, val interface{}) bool

Decode the request Body into val. Returns true on success, otherwise false and sends the http.StatusBadRequest response.

func New

func New(u *url.URL, r *simulator.Registry) ([]string, http.Handler)

New creates a vAPI simulator.

func OK

func OK(w http.ResponseWriter, val ...interface{})

OK responds with http.StatusOK and encodes val, if specified, to JSON For use with "/rest" endpoints where the response is a "value" wrapped structure.

func RunTask

func RunTask(u url.URL, spec types.CreateTask, f func(context.Context, *vim25.Client) error) string

RunTask creates a Task with the given spec and sets the task state based on error returned by f.

func StatusOK

func StatusOK(w http.ResponseWriter, val ...interface{})

StatusOK responds with http.StatusOK and encodes val, if specified, to JSON For use with "/api" endpoints.

func WithClient

func WithClient(u url.URL, f func(context.Context, *vim25.Client) error) error

WithClient creates invokes f with an authenticated vim25.Client.

Types

This section is empty.

Jump to

Keyboard shortcuts

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