Documentation ¶
Overview ¶
Package meraki is a Cisco Meraki REST client library for Go.
Index ¶
- Constants
- func BackoffDelayFactor(x float64) func(*Client)
- func BackoffMaxDelay(x int) func(*Client)
- func BackoffMinDelay(x int) func(*Client)
- func BaseUrl(x string) func(*Client)
- func MaxRetries(x int) func(*Client)
- func NoLogPayload(req *Req)
- func RequestPerSecond(x int) func(*Client)
- func RequestTimeout(x time.Duration) func(*Client)
- func UserAgent(x string) func(*Client)
- type Body
- type Client
- func (client *Client) Backoff(attempts int) bool
- func (client *Client) Delete(path string, mods ...func(*Req)) (Res, error)
- func (client *Client) Do(req Req) (Res, error)
- func (client *Client) Get(path string, mods ...func(*Req)) (Res, error)
- func (client Client) NewReq(method, uri string, body io.Reader, mods ...func(*Req)) Req
- func (client *Client) Post(path, data string, mods ...func(*Req)) (Res, error)
- func (client *Client) Put(path, data string, mods ...func(*Req)) (Res, error)
- type Req
- type Res
Constants ¶
const DefaultBackoffDelayFactor float64 = 3
const DefaultBackoffMaxDelay int = 60
const DefaultBackoffMinDelay int = 2
const DefaultMaxRetries int = 3
Variables ¶
This section is empty.
Functions ¶
func BackoffDelayFactor ¶
BackoffDelayFactor modifies the backoff delay factor from the default of 3.
func BackoffMaxDelay ¶
BackoffMaxDelay modifies the maximum delay between two retries from the default of 60.
func BackoffMinDelay ¶
BackoffMinDelay modifies the minimum delay between two retries from the default of 2.
func BaseUrl ¶
BaseUrl modifies the API base URL. Default value is 'https://api.meraki.com/api/v1'.
func MaxRetries ¶
MaxRetries modifies the maximum number of retries from the default of 3.
func RequestPerSecond ¶
RequestPerSecond modifies the maximum number of requests per second. Default value is 10.
func RequestTimeout ¶
RequestTimeout modifies the HTTP request timeout from the default of 60 seconds.
Types ¶
type Body ¶
type Body struct {
Str string
}
Body wraps SJSON for building JSON body strings. Usage example:
Body{}.Set("name", "ABC").Str
type Client ¶
type Client struct { // HttpClient is the *http.Client used for API requests HttpClient *http.Client // BaseUrl is the Meraki Dashboard Base API Url, default is https://api.meraki.com/api/v1 BaseUrl string // ApiToken is the current API token ApiToken string // UserAgent is the HTTP User-Agent string UserAgent string // Maximum number of requests per second RequestPerSecond int // Maximum number of retries MaxRetries int // Minimum delay between two retries BackoffMinDelay int // Maximum delay between two retries BackoffMaxDelay int // Backoff delay factor BackoffDelayFactor float64 // Rate limiter bucket RateLimiterBucket *ratelimit.Bucket // contains filtered or unexported fields }
Client is an HTTP Meraki client. Use meraki.NewClient to initiate a client. This will ensure proper cookie handling and processing of modifiers.
Requests are protected from concurrent writing (concurrent DELETE/POST/PUT), across all API paths. Any GET requests, or requests from different clients are not protected against concurrent writing.
func NewClient ¶
NewClient creates a new Meraki HTTP client. Pass modifiers in to modify the behavior of the client, e.g.
client, _ := NewClient("abc123", RequestTimeout(120))
func (*Client) Do ¶
Do makes a request. Requests for Do are built ouside of the client, e.g.
req := client.NewReq("GET", "/organizations", nil) res, _ := client.Do(req)
func (*Client) Get ¶
Get makes a GET request and returns a GJSON result. It handles pagination transparently. Results will be the raw data structure as returned by Meraki API