Documentation
¶
Overview ¶
Package graph holds what the Microsoft Graph client packages share: the base URL, escaped path construction, and @odata.nextLink pagination.
Index ¶
- Constants
- Variables
- func Extract[T any](response *ListResponse[T]) ([]T, string)
- func IsStatus(err error, statusCode int) bool
- func NextLinkOr(firstUrl string) func(nextLink string) string
- func ODataString(s string) string
- func PathSegments(path string) []string
- type ListResponse
- type PathBuilder
- func (b *PathBuilder) Escaped(s string) *PathBuilder
- func (b *PathBuilder) EscapedPath(path string) *PathBuilder
- func (b *PathBuilder) Literal(s string) *PathBuilder
- func (b *PathBuilder) Url(baseUrl *url.URL, query url.Values) string
- func (b *PathBuilder) UrlWithRawQuery(baseUrl *url.URL, rawQuery string) string
Constants ¶
const Domain = "graph.microsoft.com"
Variables ¶
var DefaultBaseUrl = &url.URL{Scheme: "https", Host: Domain}
Functions ¶
func Extract ¶
func Extract[T any](response *ListResponse[T]) ([]T, string)
Extract adapts ListResponse to rest.ListPaginated, the next link standing in for the page token.
func NextLinkOr ¶
NextLinkOr makes a rest.ListPaginated URL function: the first page is firstUrl, later pages the absolute @odata.nextLink of the previous one.
func ODataString ¶
ODataString escapes s for use inside a single-quoted OData string literal.
func PathSegments ¶
PathSegments splits a "/"-separated path into its non-empty segments.
Types ¶
type ListResponse ¶
type ListResponse[T any] struct { Value []T `json:"value,omitzero"` NextLink string `json:"@odata.nextLink,omitzero"` }
ListResponse is the envelope of a Graph collection.
type PathBuilder ¶
type PathBuilder struct {
// contains filtered or unexported fields
}
PathBuilder builds a URL path whose literal parts (Graph's ":" path addressing, OData function syntax) are kept verbatim while the parts taken from callers are escaped, keeping Path and RawPath in step.
func (*PathBuilder) Escaped ¶
func (b *PathBuilder) Escaped(s string) *PathBuilder
func (*PathBuilder) EscapedPath ¶
func (b *PathBuilder) EscapedPath(path string) *PathBuilder
EscapedPath escapes each "/"-separated segment of a drive-relative path, dropping empty segments so that leading, trailing and doubled slashes are harmless.
func (*PathBuilder) Literal ¶
func (b *PathBuilder) Literal(s string) *PathBuilder
func (*PathBuilder) UrlWithRawQuery ¶ added in v1.100.0
func (b *PathBuilder) UrlWithRawQuery(baseUrl *url.URL, rawQuery string) string
UrlWithRawQuery resolves the built path against baseUrl, with a query already encoded, which may write names as Url's url.Values would not ("$filter" rather than "%24filter").