File: incus_network_allocations.go

package info (click to toggle)
incus 6.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,788 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (39 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package incus

import (
	"github.com/lxc/incus/v6/shared/api"
)

// GetNetworkAllocations returns a list of Network allocations for a specific project.
func (r *ProtocolIncus) GetNetworkAllocations() ([]api.NetworkAllocations, error) {
	err := r.CheckExtension("network_allocations")
	if err != nil {
		return nil, err
	}

	// Fetch the raw value.
	netAllocations := []api.NetworkAllocations{}
	_, err = r.queryStruct("GET", "/network-allocations", nil, "", &netAllocations)
	if err != nil {
		return nil, err
	}

	return netAllocations, nil
}

// GetNetworkAllocationsAllProjects returns a list of Network allocations across all projects.
func (r *ProtocolIncus) GetNetworkAllocationsAllProjects() ([]api.NetworkAllocations, error) {
	err := r.CheckExtension("network_allocations")
	if err != nil {
		return nil, err
	}

	// Fetch the raw value.
	netAllocations := []api.NetworkAllocations{}
	_, err = r.queryStruct("GET", "/network-allocations?all-projects=true", nil, "", &netAllocations)
	if err != nil {
		return nil, err
	}

	return netAllocations, nil
}