api

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package api provides access to the platform API, in all forms supported by the config context (aka access profile)

Package api provides access to the platform API, in all forms supported by the config context (aka access profile)

Index

Constants

View Source
const RESOLVER_HOST = "observe-tenant-lookup-api"

Variables

This section is empty.

Functions

func HTTPGet

func HTTPGet(path string, out any, options *Options) error

HTTPGet performs a GET request with HTTP command and response - Accept and Content-Type headers are provided by the caller

func HTTPPost

func HTTPPost(path string, body []byte, out any, options *Options) error

HTTPPost performs a POST request with HTTP command and response - Accept and Content-Type headers are provided by the caller

func JSONDelete

func JSONDelete(path string, out any, options *Options) error

JSONDelete performs a DELETE request and parses the response as JSON

func JSONGet

func JSONGet(path string, out any, options *Options) error

JSONGet performs a GET request and parses the response as JSON

func JSONGetCollection

func JSONGetCollection(path string, out any, options *Options) error

JSONGetCollection performs a GET request and parses the response as JSON, handling pagination per https://www.rfc-editor.org/rfc/rfc5988, https://developer.cisco.com/api-guidelines/#rest-style/API.REST.STYLE.25 and https://developer.cisco.com/api-guidelines/#rest-style/API.REST.STYLE.24

func JSONPatch

func JSONPatch(path string, body any, out any, options *Options) error

JSONPatch performs a PATCH request and parses the response as JSON

func JSONPost

func JSONPost(path string, body any, out any, options *Options) error

JSONPost performs a POST request with JSON command and response

func JSONPut

func JSONPut(path string, body any, out any, options *Options) error

JSONPut performs a PUT request with JSON command and response

func JSONRequest

func JSONRequest(method string, path string, body any, out any, options *Options) error

JSONRequest performs an HTTP request and parses the response as JSON, allowing the http method to be specified

func Login

func Login() error

Login performs a login into the platform API and saves the provided access token. Login respects different access profile types (when supported) to provide the correct login mechanism for each.

Types

type Options

type Options struct {
	Headers         map[string]string
	ResponseHeaders map[string][]string // headers as returned by the call
}

type Problem added in v0.25.0

type Problem struct {
	Type       string `json:"type"`
	Title      string `json:"title"`
	Detail     string `json:"detail"`
	Status     int    `json:"status"`
	Extensions map[string]any
}

Problem type is a json object returned for content-type application/problem+json according to the RFC-7807

func (Problem) Error added in v0.25.0

func (p Problem) Error() string

func (*Problem) UnmarshalJSON added in v0.25.0

func (p *Problem) UnmarshalJSON(bs []byte) (err error)

Jump to

Keyboard shortcuts

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