snowgo

package module
v0.1.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 5 Imported by: 1

README

snow-go

Go Reference Go Report Card Taylor Swift Volkswagen License

snow-go is a Go client library for the ServiceNow REST API.

License

MIT

Documentation

Index

Constants

View Source
const (
	// DefaultSuffix is the default ServiceNow REST API URL suffix
	DefaultSuffix = ".service-now.com/api"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

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

BasicAuth implements the SecurityProvider interface for basic authentication.

func NewBasicAuth

func NewBasicAuth(username, password string) (*BasicAuth, error)

NewBasicAuth returns a new BasicAuth security provider.

func (*BasicAuth) Intercept

func (s *BasicAuth) Intercept(ctx context.Context, req *http.Request) error

Intercept will attach an Authorization header to the request and ensures that

type Client

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

Client is an opaque type that holds the client configuration

func New

func New(server string, opts ...Opt) *Client

New returns a new ServiceNow client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req Request, resp Response) error

Do sends an HTTP request and returns an HTTP response

type Error

type Error struct {
	// Exception is the exception message
	Exception Exception `json:"error"`
	// Status is the HTTP status code
	Status string `json:"status"`
}

Error represents an error response from the ServiceNow REST API

func (*Error) Error

func (e *Error) Error() string

Error returns the error message

type Exception

type Exception struct {
	// Detail is the exception detail message
	Detail string `json:"detail"`
	// Message is the exception message
	Message string `json:"message"`
}

Exception represents an exception message from the ServiceNow REST API

type Opt

type Opt func(*Client)

Opt is a functional option type for configuring the client

func WithHTTPClient

func WithHTTPClient(http *http.Client) Opt

WithHTTPClient sets the HTTP client to use

func WithRequestEditorFn

func WithRequestEditorFn(fn ...RequestEditorFn) Opt

WithRequestEditorFn sets the request editor function to use

type Request

type Request interface {
	Marshal() (*http.Request, error)
}

Request is an interface for ServiceNow REST API requests

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is a function that can be used to modify an HTTP request

type Response

type Response interface {
	Unmarshal(*http.Response) error
}

Response is an interface for ServiceNow REST API responses

Directories

Path Synopsis
Package apis provides primitives to interact with the openapi HTTP API.
Package apis provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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