Documentation ¶
Index ¶
- func CheckRequest[Structure RequestStructure](httpRequest *http.Request, expectedRequestMethod string, structure *Structure) (virest.Error, bool)
- func HttpErrorCode(libvirtErrorNumber libvirt.ErrorNumber) int
- func JsonResponseBuilder[Response ResponseStructure](response Response, httpResponseWriter http.ResponseWriter, httpStatusCode int)
- func NewConnect(uri string) (virest.Connection, virest.Error, bool)
- func NewConnectReadOnly(uri string) (virest.Connection, virest.Error, bool)
- func NewConnectWithAuth(uri string, auth *libvirt.ConnectAuth, flags libvirt.ConnectFlags) (virest.Connection, virest.Error, bool)
- func NewConnectWithAuthDefault(uri string, flags libvirt.ConnectFlags) (virest.Connection, virest.Error, bool)
- func NoContentResponseBuilder(httpResponseWriter http.ResponseWriter)
- func StringToUint(stringNumber string) (uint, virest.Error, bool)
- func StringToUint32(stringNumber string) (uint32, virest.Error, bool)
- func StringToUint64(stringNumber string) (uint64, virest.Error, bool)
- type RequestStructure
- type ResponseStructure
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRequest ¶
func CheckRequest[Structure RequestStructure](httpRequest *http.Request, expectedRequestMethod string, structure *Structure) (virest.Error, bool)
Check the expected HTTP request method and convert the JSON request body to structure if not HTTP GET method. HTTP GET method must be use query parameter.
Notes for HTTP GET method:
- Query parameter and structure field will be compared in case sensitive.
- Every structure field data type must be string, so You must convert it to the right data type before You use it.
- Untested for array query argument (Please use this function with caution).
func HttpErrorCode ¶
func HttpErrorCode(libvirtErrorNumber libvirt.ErrorNumber) int
Convert the Libvirt Error Number to HTTP Status Code
func JsonResponseBuilder ¶
func JsonResponseBuilder[Response ResponseStructure](response Response, httpResponseWriter http.ResponseWriter, httpStatusCode int)
Create JSON response with HTTP header [Content-Type: application/json].
func NewConnect ¶
This function should be called first to get a connection to the Hypervisor and xen store.
If name is NULL, if the LIBVIRT_DEFAULT_URI environment variable is set, then it will be used. Otherwise if the client configuration file has the "uri_default" parameter set, then it will be used. Finally probing will be done to determine a suitable default driver to activate. This involves trying each hypervisor in turn until one successfully opens.
If connecting to an unprivileged hypervisor driver which requires the libvirtd daemon to be active, it will automatically be launched if not already running. This can be prevented by setting the environment variable LIBVIRT_AUTOSTART=0
URIs are documented at https://libvirt.org/uri.html
Close() should be used to release the resources after the connection is no longer needed.
func NewConnectReadOnly ¶
This function should be called first to get a restricted connection to the library functionalities. The set of APIs usable are then restricted on the available methods to control the domains.
See https://pkg.go.dev/github.com/Hari-Kiri/virest-storage-pool/modules/utils#NewConnect or https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen for notes about environment variables which can have an effect on opening drivers and freeing the connection resources
URIs are documented at https://libvirt.org/uri.html
func NewConnectWithAuth ¶
func NewConnectWithAuth(uri string, auth *libvirt.ConnectAuth, flags libvirt.ConnectFlags) (virest.Connection, virest.Error, bool)
This function should be called first to get a connection to the Hypervisor. If necessary, authentication will be performed fetching credentials via the callback
See https://pkg.go.dev/github.com/Hari-Kiri/virest-storage-pool/modules/utils#NewConnect or https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen for notes about environment variables which can have an effect on opening drivers and freeing the connection resources
URIs are documented at https://libvirt.org/uri.html
func NewConnectWithAuthDefault ¶
func NewConnectWithAuthDefault(uri string, flags libvirt.ConnectFlags) (virest.Connection, virest.Error, bool)
This function should be called first to get a connection to the Hypervisor. If necessary, authentication will be performed fetching credentials via the callback
See https://pkg.go.dev/github.com/Hari-Kiri/virest-storage-pool/modules/utils#NewConnect or https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen for notes about environment variables which can have an effect on opening drivers and freeing the connection resources
URIs are documented at https://libvirt.org/uri.html
func NoContentResponseBuilder ¶
func NoContentResponseBuilder(httpResponseWriter http.ResponseWriter)
Create http response with no content (HTTP code 204).
func StringToUint ¶ added in v0.1.22
Convert string to uint. The uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32.
func StringToUint32 ¶ added in v0.1.22
Convert string to uint. The uint32 is the set of all unsigned 32-bit integers. Range: 0 through 4294967295.
Types ¶
type RequestStructure ¶
type RequestStructure interface { findStoragePoolSources.Request | getUid.Request | getGid.Request | poolList.Request | poolInfo.Request | poolDetail.Request | poolDefine.Request | poolBuild.Request | poolCreate.Request | poolAutostart.Request | poolDestroy.Request | poolDelete.Request | poolUndefine.Request | poolRefresh.Request | poolCapabilities.Request | poolEvent.Request | volumeListAll.Request | volumeCreate.Request | volumeDelete.Request }
Defined generic type constraint for request model structure.
type ResponseStructure ¶
type ResponseStructure interface { authenticate.Response | findStoragePoolSources.Response | getUid.Response | getGid.Response | poolList.Response | poolInfo.Response | poolDetail.Response | poolDefine.Response | poolBuild.Response | poolCreate.Response | poolAutostart.Response | poolDestroy.Response | poolDelete.Response | poolUndefine.Response | poolRefresh.Response | poolCapabilities.Response | poolEvent.Response | storageVolumeAuthenticate.Response | volumeListAll.Response | volumeCreate.Response | volumeDelete.Response }
Defined generic type constraint for response model structure.