MCPcopy
hub / github.com/lxc/incus / queryStruct

Method queryStruct

client/incus.go:382–398  ·  view source on GitHub ↗

queryStruct sends a query to the Incus server, then converts the response metadata into the specified target struct. The function logs the retrieved data, returns the etag of the response, and handles any errors during this process.

(method string, path string, data any, ETag string, target any)

Source from the content-addressed store, hash-verified

380// queryStruct sends a query to the Incus server, then converts the response metadata into the specified target struct.
381// The function logs the retrieved data, returns the etag of the response, and handles any errors during this process.
382func (r *ProtocolIncus) queryStruct(method string, path string, data any, ETag string, target any) (string, error) {
383 resp, etag, err := r.query(method, path, data, ETag)
384 if err != nil {
385 return "", err
386 }
387
388 err = resp.MetadataAsStruct(&target)
389 if err != nil {
390 return "", err
391 }
392
393 // Log the data
394 logger.Debugf("Got response struct from Incus")
395 logger.Debugf("%s", logger.Pretty(target))
396
397 return etag, nil
398}
399
400// queryOperation sends a query to the Incus server and then converts the response metadata into an Operation object.
401// It sets up an early event listener, performs the query, processes the response, and manages the lifecycle of the event listener.

Callers 15

GetClusterMethod · 0.95
GetClusterMemberNamesMethod · 0.95
GetClusterMembersMethod · 0.95
GetClusterMemberMethod · 0.95
GetClusterMemberStateMethod · 0.95
GetClusterGroupsMethod · 0.95
GetClusterGroupNamesMethod · 0.95
GetClusterGroupMethod · 0.95
GetNetworkACLNamesMethod · 0.95
GetNetworkACLsMethod · 0.95

Calls 4

queryMethod · 0.95
DebugfFunction · 0.92
PrettyFunction · 0.92
MetadataAsStructMethod · 0.80

Tested by

no test coverage detected