rest

package
v2.0.0-...-1b98e1c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout should be > than ONTAP's default REST timeout, which is 15 seconds for GET requests
	DefaultTimeout = "30s"
	Message        = "message"
	Code           = "code"
	Target         = "target"
)
View Source
const URLMaxLimit = 8 * 1024

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "rest",
	Short: "ONTAP Rest Utility",
	Long:  "ONTAP Rest Utility - Explore available ONTAP REST APIs",
}

Functions

func FetchAll

func FetchAll(client *Client, href string, headers ...map[string]string) ([]gjson.Result, error)

FetchAll collects all records. If you want to limit the number of records returned, use FetchSome.

func FetchAllStream

func FetchAllStream(client *Client, href string, processBatch func([]gjson.Result) error, headers ...map[string]string) error

func FetchAnalytics

func FetchAnalytics(client *Client, href string) ([]gjson.Result, gjson.Result, error)

func FetchForCli

func FetchForCli(client *Client, href string, records *[]any, downloadAll bool, curls *[]string) error

FetchForCli used for CLI only

func FetchRestPerfDataStream

func FetchRestPerfDataStream(client *Client, href string, processBatch func([]PerfRecord) error, headers ...map[string]string) error

func FetchSome

func FetchSome(client *Client, href string, recordsWanted int, batchSize string) ([]gjson.Result, error)

FetchSome collects at most recordsWanted records, following pagination links as needed. Use batchSize to limit the number of records returned in a single response. If recordsWanted is -1, all records are collected.

func GetPollerAndAddr

func GetPollerAndAddr(pName string) (*conf.Poller, string, error)

func ReadOrDownloadSwagger

func ReadOrDownloadSwagger(pName string) (string, error)

Types

type Args

type Args struct {
	Item          string
	Poller        string
	API           string
	Endpoint      string
	Config        string
	SwaggerPath   string
	Fields        string
	Field         []string
	QueryField    string
	QueryValue    string
	DownloadAll   bool
	MaxRecords    string
	ForceDownload bool
	Verbose       bool
	Timeout       string
}

type Client

type Client struct {
	Logger *slog.Logger

	Timeout time.Duration

	Metadata *util.Metadata
	// contains filtered or unexported fields
}

func New

func New(poller *conf.Poller, timeout time.Duration, credentials *auth.Credentials) (*Client, error)

func (*Client) GetPlainRest

func (c *Client) GetPlainRest(request string, encodeURL bool, headers ...map[string]string) ([]byte, error)

GetPlainRest makes a REST request to the cluster and returns a json response as a []byte

func (*Client) GetRest

func (c *Client) GetRest(request string, headers ...map[string]string) ([]byte, error)

GetRest makes a REST request to the cluster and returns a json response as a []byte

func (*Client) Init

func (c *Client) Init(retries int, remote conf.Remote) error

func (*Client) Remote

func (c *Client) Remote() conf.Remote

func (*Client) TraceLogSet

func (c *Client) TraceLogSet(collectorName string, config *node.Node)

func (*Client) UpdateClusterInfo

func (c *Client) UpdateClusterInfo(retries int) error

type HrefBuilder

type HrefBuilder struct {
	// contains filtered or unexported fields
}

func NewHrefBuilder

func NewHrefBuilder() *HrefBuilder

func (*HrefBuilder) APIPath

func (b *HrefBuilder) APIPath(apiPath string) *HrefBuilder

func (*HrefBuilder) Build

func (b *HrefBuilder) Build() string

func (*HrefBuilder) CounterSchema

func (b *HrefBuilder) CounterSchema(counterSchema []string) *HrefBuilder

func (*HrefBuilder) Fields

func (b *HrefBuilder) Fields(fields []string) *HrefBuilder

func (*HrefBuilder) Filter

func (b *HrefBuilder) Filter(filter []string) *HrefBuilder

func (*HrefBuilder) HiddenFields

func (b *HrefBuilder) HiddenFields(hiddenFields []string) *HrefBuilder

func (*HrefBuilder) IsIgnoreUnknownFieldsEnabled

func (b *HrefBuilder) IsIgnoreUnknownFieldsEnabled(isIgnoreUnknownFieldsEnabled bool) *HrefBuilder

func (*HrefBuilder) MaxRecords

func (b *HrefBuilder) MaxRecords(maxRecords string) *HrefBuilder

func (*HrefBuilder) QueryFields

func (b *HrefBuilder) QueryFields(queryFields string) *HrefBuilder

func (*HrefBuilder) QueryValue

func (b *HrefBuilder) QueryValue(queryValue string) *HrefBuilder

func (*HrefBuilder) ReturnTimeout

func (b *HrefBuilder) ReturnTimeout(returnTimeout *int) *HrefBuilder

type Pagination

type Pagination struct {
	Records    []any `json:"records"`
	NumRecords int   `json:"num_records"`
	Links      *struct {
		Next struct {
			Href string `json:"href"`
		} `json:"next"`
	} `json:"_links,omitempty"`
}

type PerfRecord

type PerfRecord struct {
	Records   gjson.Result `json:"records"`
	Timestamp int64        `json:"time"`
}

type Results

type Results struct {
	Poller         string `json:"poller,omitempty"`
	Addr           string `json:"addr,omitempty"`
	API            string `json:"api,omitempty"`
	Version        string `json:"version,omitempty"`
	ClusterName    string `json:"cluster_name,omitempty"`
	Records        []any  `json:"records"`
	NumRecords     int    `json:"num_records"`
	PollDurationMs int64  `json:"poll_ms"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL