File: nodebalancer_types.go

package info (click to toggle)
golang-github-linode-linodego 1.47.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 10,032 kB
  • sloc: makefile: 95; sh: 52; python: 24
file content (45 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download
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
40
41
42
43
44
45
package linodego

import (
	"context"
)

// NodeBalancerType represents a single valid NodeBalancer type.
type NodeBalancerType struct {
	baseType[NodeBalancerTypePrice, NodeBalancerTypeRegionPrice]
}

// NodeBalancerTypePrice represents the base hourly and monthly prices
// for a NodeBalancer type entry.
type NodeBalancerTypePrice struct {
	baseTypePrice
}

// NodeBalancerTypeRegionPrice represents the regional hourly and monthly prices
// for a NodeBalancer type entry.
type NodeBalancerTypeRegionPrice struct {
	baseTypeRegionPrice
}

// ListNodeBalancerTypes lists NodeBalancer types. This endpoint is cached by default.
func (c *Client) ListNodeBalancerTypes(ctx context.Context, opts *ListOptions) ([]NodeBalancerType, error) {
	e := "nodebalancers/types"

	endpoint, err := generateListCacheURL(e, opts)
	if err != nil {
		return nil, err
	}

	if result := c.getCachedResponse(endpoint); result != nil {
		return result.([]NodeBalancerType), nil
	}

	response, err := getPaginatedResults[NodeBalancerType](ctx, c, e, opts)
	if err != nil {
		return nil, err
	}

	c.addCachedResponse(endpoint, response, &cacheExpiryTime)

	return response, nil
}