odata

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: BSL-1.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction uint8
const (
	Ascending Direction = iota
	Descending
)

type Order

type Order map[string]Direction

func (*Order) String

func (o *Order) String() string

type Query

type Query[V any] struct {
	// contains filtered or unexported fields
}

Query is a builder type for an OData query

func NewQuery

func NewQuery[V any](client RequestProvider, url string) *Query[V]

NewQuery creates a new OData query for a specific URL that will be resolved with the provided RequestProvider

func (*Query[V]) Count

func (o *Query[V]) Count() *Query[V]

Count requests a count to be added to the OData response

func (*Query[V]) Expand

func (o *Query[V]) Expand(keys ...string) *Query[V]

Expand selects which fields should be expanded

func (*Query[V]) Filter

func (o *Query[V]) Filter(filter string) *Query[V]

Filter sets a filter expression used to filter results

func (*Query[V]) Get

func (o *Query[V]) Get() (*V, error)

Get performs a simple get on an OData API returning a single item

func (*Query[V]) GetAll

func (o *Query[V]) GetAll() ([]V, error)

GetAll performs an OData request for a set of items, iterating through all pages and collecting the results

func (*Query[V]) OrderBy

func (o *Query[V]) OrderBy(key string, direction ...Direction) *Query[V]

OrderBy defines the key and direction to order the results by

func (*Query[V]) PathParam

func (o *Query[V]) PathParam(key, value string) *Query[V]

PathParam sets a path parameter for the OData query

func (*Query[V]) Search

func (o *Query[V]) Search(query string) *Query[V]

Search performs a search

func (*Query[V]) Select

func (o *Query[V]) Select(keys ...string) *Query[V]

Select defines the keys to request

func (*Query[V]) Skip

func (o *Query[V]) Skip(num uint64) *Query[V]

Skip sets how many results should be skipped

func (*Query[V]) Top

func (o *Query[V]) Top(num uint64) *Query[V]

Top limits the number of results

type RequestError

type RequestError struct {
	Status     int
	StatusText string
	Body       string
}

func (*RequestError) Error

func (r *RequestError) Error() string

type RequestProvider

type RequestProvider interface {
	NewRequest() (*resty.Request, error)
}

RequestProviders generate Resty requests that already contain a base URL and the necessary authentication information for the OData API

type Respose

type Respose[V any] struct {
	Context string `json:"@odata.context"`
	Count   uint64 `json:"@odata.count"`
	Next    string `json:"@odata.nextLink"`
	Value   []V    `json:"value"`
}

func (*Respose[V]) Collect

func (o *Respose[V]) Collect(c RequestProvider) error

Collect iterates through pages of OData results and collects them into the original result

func (*Respose[V]) Result

func (o *Respose[V]) Result() []V

Result returns the data contained in the OData response

Jump to

Keyboard shortcuts

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