package simulator

import "github.com/vmware/govmomi/vapi/simulator"

Index

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 any) 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 ...any)

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 ...any)

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.

Source Files

simulator.go

Version
v0.51.0 (latest)
Published
May 23, 2025
Platform
linux/amd64
Imports
49 packages
Last checked
2 weeks ago

Tools for package owners.