apiClient

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

clientHelpers.go For utility/helper functions to support from the main package

request.go Provides functions to interact with the Jamf API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintRequestHeaders

func PrintRequestHeaders(req *http.Request)

Print request headers for troubleshooting

Types

type Authenticator

type Authenticator interface {
	Authenticate(c *Client) error
}

type BasicAuthConfig

type BasicAuthConfig struct {
	Username string
	Password string
}

func (BasicAuthConfig) Authenticate

func (b BasicAuthConfig) Authenticate(c *Client) error

type Client

type Client struct {
	HttpClient       *http.Client
	HttpRetryTimeout time.Duration
	ExtraHeader      map[string]string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg Config) (*Client, error)

func (*Client) DoRawRequest

func (c *Client) DoRawRequest(api string, params *url.Values) (string, error)

DoRawRequest sends a GET request to the specified API endpoint and returns the raw string response. This function is specialized for handling raw string responses like extracting certificate public keys.

func (*Client) DoRequest

func (c *Client) DoRequest(method, api string, reqbody interface{}, params *url.Values, out interface{}) error

DoRequest - A method to send a request to the jamf api

func (*Client) DoRequestDebug

func (c *Client) DoRequestDebug(method, api string, reqbody interface{}, params *url.Values, out interface{}) error

DoRequestDebug provides complete debugging information during the request-response cycle. It uses createRequestDebug to create and log the request, then handles the HTTP call and response logging any necessary debugging information.

type Config

type Config struct {
	AuthMethod       Authenticator
	URL              string
	HTTPClient       *http.Client
	HttpRetryTimeout time.Duration
	ExtraHeader      map[string]string
	RefreshBuffer    time.Duration
}

type Error

type Error interface {
	Error() string
	StatusCode() int
	URI() string
	Body() string
}

type OAuthConfig

type OAuthConfig struct {
	ClientID     string
	ClientSecret string
}

func (OAuthConfig) Authenticate

func (o OAuthConfig) Authenticate(c *Client) error

type StatusCodeCategory

type StatusCodeCategory int
const (
	Success StatusCodeCategory = iota
	ClientError
	ServerError
	Unknown

	ClassicAPI = "/JSSResource"
	JamfProAPI = "/api"
)

Jump to

Keyboard shortcuts

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