core

package
v0.0.0-...-5f8180a Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 18 Imported by: 0

README

Core

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyURI                = internal.ErrEmptyURI
	ErrNilPathParameters       = internal.ErrNilPathParameters
	ErrNilQueryParamters       = internal.ErrNilQueryParamters
	ErrMissingBasePathParam    = internal.ErrMissingBasePathParam
	ErrMissingBasePathTemplate = internal.ErrMissingBasePathTemplate
	ErrInvalidHeaderType       = internal.ErrInvalidHeaderType
	ErrEmptyRawUrl             = internal.ErrEmptyRawURL //nolint:stylecheck
	ErrMissingSchema           = internal.ErrMissingSchema
	ErrNilResponse             = internal.ErrNilResponse
	ErrNilResponseBody         = internal.ErrNilResponseBody
	ErrNilSource               = internal.ErrNilSource

	// Page Iterator
	ErrNilClient          = internal.ErrNilClient
	ErrNilResult          = internal.ErrNilResult
	ErrWrongResponseType  = internal.ErrWrongResponseType
	ErrParsing            = internal.ErrParsing
	ErrNilCallback        = internal.ErrNilCallback
	ErrNilConstructorFunc = errors.New("constructorFunc can't be nil")
)

Functions

func FromJson

func FromJson[T any](response *http.Response, v *T) error

func IsPointer

func IsPointer(value interface{}) bool

func ParseResponse

func ParseResponse[T Response](response *http.Response, value *T) error

ParseResponse[T] parses the HTTP Response to the provided type

func SendGet2

func SendGet2(requestBuilder *RequestBuilder, config *RequestConfiguration) error

func SendPost2

func SendPost2(requestBuilder *RequestBuilder, config *RequestConfiguration) error

func ToQueryMap

func ToQueryMap(source interface{}) (map[string]string, error)

ToQueryMap converts a struct to query parameter map

Types

type ApiError

type ApiError struct {
	// Message is the human-readable error message.
	Message string
	// ResponseStatusCode is the HTTP response status code associated with the error.
	ResponseStatusCode int
}

ApiError represents an error that occurs during API requests.

func (*ApiError) Error

func (e *ApiError) Error() string

Error returns the error message as a string. If the message is empty, it returns a default error message.

type Client

type Client interface {
	Send(requestInfo IRequestInformation, errorMapping ErrorMapping) (*http.Response, error)
}

type Client2

type Client2 interface {
	Send(IRequestInformation, ErrorMapping) (*http.Response, error)
	SendWithContext(context.Context, IRequestInformation, ErrorMapping) (*http.Response, error)
	GetBaseURL() string
}

type CollectionResponse

type CollectionResponse[T any] interface {
	ToPage() PageResult[T]
	ParseHeaders(http.Header)
}

CollectionResponse[T] represents collection responses.

type Credential

type Credential interface {
	GetAuthentication() (string, error)
}

type ErrorMapping

type ErrorMapping map[string]string

ErrorMapping is a map that maps error codes to human-readable error messages.

func NewErrorMapping

func NewErrorMapping() ErrorMapping

NewErrorMapping creates a new instance of the ErrorMapping. It initializes an empty map to store error code to error message mappings.

func (ErrorMapping) Get

func (eM ErrorMapping) Get(code int) (string, bool)

Get retrieves the error message associated with the provided error code. It returns the error message along with a boolean indicating whether the error code was found. If the error code is not found, an empty string is returned along with `false`.

func (ErrorMapping) Len

func (eM ErrorMapping) Len() int

Len returns the number of error code to error message mappings in the ErrorMapping. It provides the total count of error mappings.

func (ErrorMapping) Set

func (eM ErrorMapping) Set(code, err string)

Set sets the error message for the specified error code. It associates the given error code with the provided error message in the mapping.

type Exception

type Exception struct {
	// Detail is a detailed description of the exception.
	Detail string
	// Message is a brief description of the exception.
	Message string
}

Exception represents an exception in the ServiceNow error response.

type Fragment

type Fragment struct {
	// Field represents the field on which the condition is applied.
	Field string
	// RelationalOperator represents the comparison operator for the condition.
	RelationalOperator RelationalOperator
	// Value represents the value to compare against.
	Value interface{}
	// LogicalOperator represents the operator connection to the next fragment
	LogicalOperator LogicalOperator
	// contains filtered or unexported fields
}

Fragment represents a query fragment with a field, operator, and value.

func NewFragment

func NewFragment(field string, operator RelationalOperator, value interface{}) *Fragment

NewFragment creates a new query fragment with the specified field, operator, and value.

func (*Fragment) Iterate

func (f *Fragment) Iterate(callback func(*Fragment) bool)

Iterate iterates over the fragments

func (*Fragment) SetNext

func (f *Fragment) SetNext(fragment *Fragment, operator LogicalOperator)

SetNext sets the next and Logical Operator value

func (*Fragment) String

func (f *Fragment) String() string

String returns a string representation of the query fragment in the format "field operator value".

type HttpMethod

type HttpMethod int //nolint:stylecheck

Represents the HTTP method used by a request.

const (
	// The HTTP GET method.
	GET HttpMethod = iota
	// The HTTP POST method.
	POST
	// The HTTP PATCH method.
	PATCH
	// The HTTP DELETE method.
	DELETE
	// The HTTP OPTIONS method.
	OPTIONS
	// The HTTP CONNECT method.
	CONNECT
	// The HTTP PUT method.
	PUT
	// The HTTP TRACE method.
	TRACE
	// The HTTP HEAD method.
	HEAD
)

func (HttpMethod) String

func (m HttpMethod) String() string

String returns the string representation of the HTTP method.

type IRequestInformation

type IRequestInformation interface {
	AddRequestOptions(options []RequestOption)
	SetStreamContent(content []byte)
	AddQueryParameters(source interface{}) error
	SetUri(url *url.URL)
	Url() (string, error)
	ToRequest() (*http.Request, error)
	ToRequestWithContext(ctx context.Context) (*http.Request, error)
	AddHeaders(rawHeaders interface{}) error
	GetRequestOptions() []RequestOption
	GetContent() []byte
	GetMethod() string
	GetHeaders() core.RequestHeader
}

type ItemResponse

type ItemResponse[T any] interface {
	ParseHeaders(http.Header)
}

ItemResponse[T] represents a single item responses.

type LogicalOperator

type LogicalOperator string

LogicalOperator ...

const (
	// And ...
	And LogicalOperator = "^"
	// Or ...
	Or LogicalOperator = "^OR"
)

type OrderBy

type OrderBy struct {
	Direction OrderDirection
	Field     string
}

OrderBy represents an order-by clause.

func NewOrderBy

func NewOrderBy() *OrderBy

NewOrderBy Creates new order by

func (*OrderBy) String

func (oB *OrderBy) String() string

String ...

type OrderDirection

type OrderDirection string

OrderDirection represents the order direction for sorting.

const (
	// Unset ...
	Unset OrderDirection = ""
	// Asc ...
	Asc OrderDirection = "^ORDERBY"
	// Desc ...
	Desc OrderDirection = "^ORDERBYDESC"
)

type PageIterator deprecated

type PageIterator[T any, C CollectionResponse[T]] struct {
	// contains filtered or unexported fields
}

Deprecated: deprecated in v1.5.0. Please use PageIterator2[T]. PageIterator

func NewPageIterator deprecated

func NewPageIterator[T any, C CollectionResponse[T]](currentPage CollectionResponse[T], client Client) (*PageIterator[T, C], error)

Deprecated: deprecated in v1.5.0. Please use NewPageIterator2[T]. NewPageIterator creates a new PageIterator instance.

func (*PageIterator[T, C]) Iterate

func (pI *PageIterator[T, C]) Iterate(callback func(pageItem *T) bool) error

Iterate iterates through pages and invokes the provided callback for each page item.

func (*PageIterator[T, C]) Last

func (pI *PageIterator[T, C]) Last() (PageResult[T], error)

Last fetches the last page of results.

func (*PageIterator[T, C]) Next

func (pI *PageIterator[T, C]) Next() (PageResult[T], error)

Next fetches the Next page of results.

type PageIterator2

type PageIterator2[T any] struct {
	// contains filtered or unexported fields
}

PageIterator2[T]

func NewPageIterator2

func NewPageIterator2[T any](currentPage CollectionResponse[T], client Client, constructorFunc Parsable[T]) (*PageIterator2[T], error)

NewPageIterator2[T] creates a new PageIterator instance.

func (*PageIterator2[T]) First

func (pI *PageIterator2[T]) First() (PageResult[T], error)

First fetches the first page of results.

func (*PageIterator2[T]) Iterate

func (pI *PageIterator2[T]) Iterate(callback func(pageItem *T) bool, reversed bool) error

Iterate iterates through pages and invokes the provided callback for each page item.

func (*PageIterator2[T]) Last

func (pI *PageIterator2[T]) Last() (PageResult[T], error)

Last fetches the last page of results.

func (*PageIterator2[T]) Next

func (pI *PageIterator2[T]) Next() (PageResult[T], error)

Next fetches the Next page of results.

func (*PageIterator2[T]) Previous

func (pI *PageIterator2[T]) Previous() (PageResult[T], error)

Previous fetches the previous page of results.

type PageResult

type PageResult[T any] struct {
	Result           []*T
	NextPageLink     string
	PreviousPageLink string
	FirstPageLink    string
	LastPageLink     string
}

PageResult represents a single page of results from a table.

type Parsable

type Parsable[T any] func(*http.Response) (CollectionResponse[T], error)

type Query

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

Query represents a ServiceNow query and its conditions.

func NewQuery

func NewQuery() *Query

NewQuery returns a new Query with no conditions.

func (*Query) AddBetween

func (q *Query) AddBetween(field string, start, end interface{}) *Query

AddBetween adds a between condition to the query.

func (*Query) AddContains

func (q *Query) AddContains(field string, value interface{}) *Query

AddContains adds a contains condition to the query.

func (*Query) AddEndsWith

func (q *Query) AddEndsWith(field string, value interface{}) *Query

AddEndsWith adds an ends-with condition to the query.

func (*Query) AddEqual

func (q *Query) AddEqual(field string, value interface{}) *Query

AddEqual adds an equality condition to the query.

func (*Query) AddFragment

func (q *Query) AddFragment(fragment *Fragment, operator LogicalOperator) *Query

AddFragment adds a fragment to the query.

func (*Query) AddGreaterThan

func (q *Query) AddGreaterThan(field string, value interface{}) *Query

AddGreaterThan adds a greater-than condition to the query.

func (*Query) AddIsDifferent

func (q *Query) AddIsDifferent(startField, endField string) *Query

AddIsDifferent adds a condition to check if two fields are different.

func (*Query) AddIsSame

func (q *Query) AddIsSame(startField, endField string) *Query

AddIsSame adds a condition to check if two fields are the same.

func (*Query) AddLessThan

func (q *Query) AddLessThan(field string, value interface{}) *Query

AddLessThan adds a less-than condition to the query.

func (*Query) AddNotContains

func (q *Query) AddNotContains(field string, value interface{}) *Query

AddNotContains adds a not-contains condition to the query.

func (*Query) AddNotEqual

func (q *Query) AddNotEqual(field string, value interface{}) *Query

AddNotEqual adds a not-equal condition to the query.

func (*Query) AddOrContains

func (q *Query) AddOrContains(field string, value interface{}) *Query

AddOrContains adds an "OR" contains condition to the query.

func (*Query) AddOrEqual

func (q *Query) AddOrEqual(field string, value interface{}) *Query

AddOrEqual adds an "OR" equality condition to the query.

func (*Query) AddOrGreaterThan

func (q *Query) AddOrGreaterThan(field string, value interface{}) *Query

AddOrGreaterThan adds an "OR" greater-than condition to the query.

func (*Query) AddOrLessThan

func (q *Query) AddOrLessThan(field string, value interface{}) *Query

AddOrLessThan adds an "OR" less-than condition to the query.

func (*Query) AddOrNotContains

func (q *Query) AddOrNotContains(field string, value interface{}) *Query

AddOrNotContains adds an "OR" not-contains condition to the query.

func (*Query) AddOrNotEqual

func (q *Query) AddOrNotEqual(field string, value interface{}) *Query

AddOrNotEqual adds an "OR" not-equal condition to the query.

func (*Query) AddOrQuery

func (q *Query) AddOrQuery(field string, operator RelationalOperator, value interface{}) *Query

AddOrQuery adds an "OR" query condition to the query.

func (*Query) AddOrderBy

func (q *Query) AddOrderBy(field string) *Query

AddOrderBy sets the order-by field in ascending order.

func (*Query) AddOrderByDesc

func (q *Query) AddOrderByDesc(field string) *Query

AddOrderByDesc sets the order-by field in descending order.

func (*Query) AddQuery

func (q *Query) AddQuery(field string, operator RelationalOperator, value interface{}) *Query

AddQuery adds a query condition to the query.

func (*Query) AddStartsWith

func (q *Query) AddStartsWith(field string, value interface{}) *Query

AddStartsWith adds a starts-with condition to the query.

func (*Query) Encoded

func (q *Query) Encoded() string

Encoded returns the encoded query as a string.

func (*Query) IsEmpty

func (q *Query) IsEmpty(field string) *Query

IsEmpty adds an "is empty" condition to the query.

func (*Query) String

func (q *Query) String() string

String returns the query as a string.

type RelationalOperator

type RelationalOperator string

RelationalOperator ...

const (
	// Null ...
	Null RelationalOperator = ""
	// Is ...
	Is RelationalOperator = "="
	// IsNot ...
	IsNot RelationalOperator = "!="
	// GreaterThan ...
	GreaterThan RelationalOperator = ">"
	// GreaterOrEqual ...
	GreaterOrEqual RelationalOperator = ">="
	// LessThan ...
	LessThan RelationalOperator = "<"
	// LessOrEqual ...
	LessOrEqual RelationalOperator = "<="
	// Contains ...
	Contains RelationalOperator = "CONTAINS"
	// NotContains ...
	NotContains RelationalOperator = "!CONTAINS"
	// StartsWith ...
	StartsWith RelationalOperator = "STARTSWITH"
	// EndsWith ...
	EndsWith RelationalOperator = "ENDSWITH"
	// Between ...
	Between RelationalOperator = "BETWEEN"
	// IsSame ...
	IsSame RelationalOperator = "SAMEAS"
	// IsDifferent ...
	IsDifferent RelationalOperator = "NSAMEAS"
	// IsEmpty ...
	IsEmpty RelationalOperator = "ISEMPTY"
)

type RequestBuilder deprecated

type RequestBuilder struct {
	// PathParameters is a map of path parameters used in the URL template.
	PathParameters map[string]string
	// Client is an instance of the HTTP client used to send requests.
	Client Client
	// UrlTemplate is the URL template for constructing the request URL.
	UrlTemplate string //nolint:stylecheck
}

Deprecated: deprecated since v{unreleased}. RequestBuilder represents a builder for constructing HTTP request information.

func NewRequestBuilder deprecated

func NewRequestBuilder(client Client, urlTemplate string, pathParameters map[string]string) *RequestBuilder

Deprecated: deprecated since v{unreleased}. NewRequestBuilder creates a new instance of the RequestBuilder associated with the given URL and Client. It accepts the URL and Client as parameters and returns a pointer to the created RequestBuilder.

func (*RequestBuilder) SendDelete deprecated

func (rB *RequestBuilder) SendDelete(params interface{}, errorMapping ErrorMapping) error

Deprecated: deprecated since v1.4.0. Please use SendDelete2

func (*RequestBuilder) SendDelete2

func (rB *RequestBuilder) SendDelete2(config *RequestConfiguration) error

func (*RequestBuilder) SendGet deprecated

func (rB *RequestBuilder) SendGet(params interface{}, errorMapping ErrorMapping, value Response) error

Deprecated: deprecated since v1.4.0. Please use SendGet2

func (*RequestBuilder) SendGet2

func (rB *RequestBuilder) SendGet2(config *RequestConfiguration) error

func (*RequestBuilder) SendPost deprecated

func (rB *RequestBuilder) SendPost(data map[string]string, params interface{}, errorMapping ErrorMapping, value Response) error

Deprecated: deprecated since v1.4.0. Please use SendPost3

func (*RequestBuilder) SendPost2 deprecated

func (rB *RequestBuilder) SendPost2(data interface{}, params interface{}, errorMapping ErrorMapping, value Response) error

Deprecated: deprecated since v1.4.0. Please use SendPost3

func (*RequestBuilder) SendPost3

func (rB *RequestBuilder) SendPost3(config *RequestConfiguration) error

func (*RequestBuilder) SendPut deprecated

func (rB *RequestBuilder) SendPut(data map[string]string, params interface{}, errorMapping ErrorMapping, value Response) error

Deprecated: deprecated since v1.4.0. Please use SendPut2

func (*RequestBuilder) SendPut2

func (rB *RequestBuilder) SendPut2(config *RequestConfiguration) error

func (*RequestBuilder) ToDeleteRequestInformation deprecated

func (rB *RequestBuilder) ToDeleteRequestInformation(params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToDeleteRequestInformation2` ToDeleteRequestInformation creates a new HTTP DELETE request's RequestInformation object. It sets the HTTP method to DELETE and includes the specified query parameters.

Parameters:

  • params: An interface representing query parameters for the DELETE request.

Returns:

  • *RequestInformation: A RequestInformation object representing the DELETE request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToDeleteRequestInformation2

func (rB *RequestBuilder) ToDeleteRequestInformation2(config *RequestConfiguration) (*RequestInformation, error)

func (*RequestBuilder) ToGetRequestInformation deprecated

func (rB *RequestBuilder) ToGetRequestInformation(params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToGetRequestInformation2` ToGetRequestInformation creates a new HTTP GET request's RequestInformation object. It sets the HTTP method to GET and includes the specified query parameters.

Parameters:

  • params: An interface representing query parameters for the GET request.

Returns:

  • *RequestInformation: A RequestInformation object representing the GET request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToGetRequestInformation2

func (rB *RequestBuilder) ToGetRequestInformation2(config *RequestConfiguration) (*RequestInformation, error)

func (*RequestBuilder) ToHeadRequestInformation

func (rB *RequestBuilder) ToHeadRequestInformation() (*RequestInformation, error)

ToHeadRequestInformation creates a new HTTP HEAD request's RequestInformation object. It sets the HTTP method to HEAD and includes no request data or query parameters.

Returns:

  • *RequestInformation: A RequestInformation object representing the HEAD request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToPostRequestInformation deprecated

func (rB *RequestBuilder) ToPostRequestInformation(data map[string]string, params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToPostRequestInformation2` ToPostRequestInformation creates a new HTTP POST request's RequestInformation object. It sets the HTTP method to POST and includes the specified data in the request body and query parameters.

Parameters:

  • data: A map[string]interface{} representing data to be included in the request body.
  • params: An interface representing query parameters for the POST request.

Returns:

  • *RequestInformation: A RequestInformation object representing the POST request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToPostRequestInformation2 deprecated

func (rB *RequestBuilder) ToPostRequestInformation2(data interface{}, params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToPostRequestInformation3` ToPostRequestInformation2 creates a new HTTP POST request's RequestInformation object. It sets the HTTP method to POST and includes the specified data in the request body and query parameters.

Parameters:

  • data: A map[string]interface{} representing data to be included in the request body.
  • params: An interface representing query parameters for the POST request.

Returns:

  • *RequestInformation: A RequestInformation object representing the POST request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToPostRequestInformation3

func (rB *RequestBuilder) ToPostRequestInformation3(config *RequestConfiguration) (*RequestInformation, error)

func (*RequestBuilder) ToPutRequestInformation deprecated

func (rB *RequestBuilder) ToPutRequestInformation(data map[string]string, params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToPutRequestInformation2` Put updates a table item using an HTTP PUT request. It takes a map of table entry data and optional query parameters to send in the request. The method returns a TableItemResponse representing the updated item or an error if the request fails.

Parameters:

  • tableEntry: A map containing the data to update the table item.
  • params: An optional pointer to TableItemRequestBuilderPutQueryParameters, which can be used to specify query parameters for the request.

Returns:

  • *TableItemResponse: A TableItemResponse containing the updated item data.
  • error: An error, if the request fails at any point, such as request information creation or JSON deserialization.

func (*RequestBuilder) ToPutRequestInformation2

func (rB *RequestBuilder) ToPutRequestInformation2(config *RequestConfiguration) (*RequestInformation, error)

func (*RequestBuilder) ToRequestInformation deprecated

func (rB *RequestBuilder) ToRequestInformation(method HttpMethod, data map[string]string, params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToRequestInformation2` ToRequestInformation creates a new HTTP request's RequestInformation object with the specified HTTP method, data in the request body, and query parameters.

Parameters:

  • method: The HTTP method for the request (e.g., "GET", "POST", "HEAD", "DELETE").
  • data: A map[string]interface{} representing data to be included in the request body.
  • params: An interface representing query parameters for the request.

Returns:

  • *RequestInformation: A RequestInformation object representing the HTTP request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToRequestInformation2 deprecated

func (rB *RequestBuilder) ToRequestInformation2(method HttpMethod, rawData interface{}, params interface{}) (*RequestInformation, error)

Deprecated: deprecated as of 1.4.0 please utilize `ToRequestInformation3` ToRequestInformation2 creates a new HTTP request's RequestInformation object with the specified HTTP method, data in the request body, and query parameters.

Parameters:

  • method: The HTTP method for the request (e.g., "GET", "POST", "HEAD", "DELETE").
  • data: A map[string]interface{} representing data to be included in the request body.
  • params: An interface representing query parameters for the request.

Returns:

  • *RequestInformation: A RequestInformation object representing the HTTP request.
  • error: An error if there was an issue creating the request information.

func (*RequestBuilder) ToRequestInformation3

func (rB *RequestBuilder) ToRequestInformation3(method HttpMethod, config *RequestConfiguration) (*RequestInformation, error)

type RequestConfiguration

type RequestConfiguration = core.RequestConfiguration

type RequestInformation

type RequestInformation struct {
	// The HTTP method of the request.
	Method HttpMethod
	// The Request Headers.
	Headers http.Header
	// The Request Body.
	Content []byte
	// contains filtered or unexported fields
}

RequestInformation represents an abstract HTTP request.

func NewRequestInformation

func NewRequestInformation() *RequestInformation

NewRequestInformation creates a new RequestInformation object with default values.

func (*RequestInformation) AddHeaders

func (rI *RequestInformation) AddHeaders(rawHeaders interface{}) error

func (*RequestInformation) AddQueryParameters

func (rI *RequestInformation) AddQueryParameters(source interface{}) error

AddQueryParameters adds the query parameters to the request by reading the properties from the provided object.

func (*RequestInformation) AddRequestOptions

func (rI *RequestInformation) AddRequestOptions(options []RequestOption)

AddRequestOptions adds an option to the request to be read by the middleware infrastructure.

func (*RequestInformation) GetContent

func (rI *RequestInformation) GetContent() []byte

func (*RequestInformation) GetHeaders

func (rI *RequestInformation) GetHeaders() core.RequestHeader

func (*RequestInformation) GetMethod

func (rI *RequestInformation) GetMethod() string

func (*RequestInformation) GetRequestOptions

func (rI *RequestInformation) GetRequestOptions() []RequestOption

GetRequestOptions returns the options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins.

func (*RequestInformation) SetStreamContent

func (rI *RequestInformation) SetStreamContent(content []byte)

SetStreamContent sets the request body to a binary stream.

func (*RequestInformation) SetUri

func (rI *RequestInformation) SetUri(url *url.URL)

func (*RequestInformation) ToRequest

func (rI *RequestInformation) ToRequest() (*http.Request, error)

ToRequest converts the RequestInformation object into an HTTP request.

func (*RequestInformation) ToRequestWithContext

func (rI *RequestInformation) ToRequestWithContext(ctx context.Context) (*http.Request, error)

ToRequestWithContext converts the RequestInformation object into an HTTP request with context.

func (*RequestInformation) Url

func (rI *RequestInformation) Url() (string, error)

type RequestOption

type RequestOption interface {
	// GetKey returns the key to store the current option under.
	GetKey() RequestOptionKey
}

Represents a request option.

type RequestOptionKey

type RequestOptionKey struct {
	// The unique key for the option.
	Key string
}

RequestOptionKey represents a key to store a request option under.

type Response

type Response interface {
	ParseHeaders(headers http.Header)
}

Response represents all possible responses

type ServiceNowError

type ServiceNowError struct {
	// Exception is the exception details in the error response.
	Exception Exception `json:"error"`
	// Status is the status of the error response.
	Status string
}

ServiceNowError represents an error response from the ServiceNow API.

func (*ServiceNowError) Error

func (e *ServiceNowError) Error() string

Error returns a formatted error message that includes both the exception message and detail.

type UrlInformation

type UrlInformation struct {
	// The Query Parameters of the request.
	QueryParameters map[string]string
	// The path parameters to use for the URL template when generating the URI.
	PathParameters map[string]string
	// The Url template for the current request.
	UrlTemplate string //nolint:stylecheck
}

UrlInformation represents an abstract Url.

func NewURLInformation

func NewURLInformation() *UrlInformation

NewURLInformation creates a new RequestUri object.

func NewUrlInformation deprecated

func NewUrlInformation() *UrlInformation

Deprecated: deprecated as of v1.4.0, use `NewURLInformation` instead.

NewUrlInformation creates a new RequestUri object.

func (*UrlInformation) AddQueryParameters

func (uI *UrlInformation) AddQueryParameters(source interface{}) error

AddQueryParameters adds the query parameters to the request by reading the properties from the provided object.

func (*UrlInformation) ToUrl

func (uI *UrlInformation) ToUrl() (*url.URL, error)

ToUrl retrieves the URI, either from the raw URL or the URL template.

Jump to

Keyboard shortcuts

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