0.0.95 • Published 7 months ago

@boundlessdigital/meraki-sdk v0.0.95

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Boundless Meraki SDK for Node.js or Browser

This package allows you to interact with the Meraki Dashboard API from a Javascript application (Node or Browser).

If using it from a browser, you must point the host to an API Gateway that supports CORS, such as the Boundless API Gateway.

Uses Axios client behind.

Installation

Depending on which package manager you use, install this package by running the following:

  • Yarn: yarn add @boundlessdigital/meraki-sdk
  • NPM: npm install --save @boundlessdigital/meraki-sdk

Once installed, you can use it in your application by instantiating the client, configuring your API Key, and then calling the API methods on the client directly.

Client Usage

To create a client instance, use:

import { Client } from '@boundlessdigital/meraki-sdk';
const client = new Client({ /* options */ });

Available client options

KeyTypeDefault ValueDescription
api_keystringEnv variable for api_key_env_var keyMeraki API Key to authenticate requests. Can be explicitly specified or autodetected from environment
api_key_env_varstring"MERAKI_DASHBOARD_API_KEY"Environment variable name to seach for API Key when api_key option is not provided
base_urlstring"https://api.meraki.com"Backend endpoint where requests will be sent to. Can be changed to point to the API Gateway or CloudFront
base_pathstring"/api/v1"API base path. Can be changed to confugure custom API Gateway or CloudFront routes
user_agentstring"Boundless/1.0 Boundless"HTTP User Agent used for requests
timeoutnumber60000HTTP timeout in milliseconds
request_mode"dispatch" \| "preview" \| "batch""dispatch"Current request mode of a client. Learn more on that below
retry_on_errorbooleantrueTries to repeat the request on error if true. HTTP errors will not trigger this by default
retry_on_statusesnumber[][429, 503]HTTP response statuses that should be considered as errors ans trigger a retry mechanism
maximum_retriesnumber5Maximum amount of retries before the request rejection (when retry_on_error is true)
proxystringnullIs not used now
retry_on_rate_limitbooleanfalseIs not used now
output_logbooleanfalseIs not used now
print_to_consolebooleanfalseIs not used now
action_batch_retry_wait_timenumber0Is not used now

Request Modes

There are three available request modes: dispatch, preview, and batch.

The default mode is dispatch, which immediately dispatches requests to the Meraki endpoint (as any common API client does).

However, the client makes it possible to use the Meraki Action Batch feature by preparing and executing the batches once the work has been batched; the preview and batch modes control that process.

The preview mode does nothing but return the action body that can then be added to the batch actions array. This is useful to manage actions and batches or for debugging purposes.

The batch mode prepares and adds the action body to the current batch actions list.

The following methods can be used to change the request mode: client.set_request_mode(/* mode */), client.set_dispatch_mode(), client.set_preview_mode(), client.set_batch_mode().

Actions Batches, Types Safety

There is a limited amount of Meraki API methods that support Action Batches. All the GET methods are not supported by default, but the complete list can be found using import { batchable_actions } from '@boundlessdigital/meraki-sdk'.

TBD (not implemented yet)

API Spec and Resources

Besides the Client implementation, there are a raw API spec and a few pre-processed resources to help build request bodies, work with Action Batches, etc. It can be accessed by

import {
    spec,
    schemas,
    endpoints,
    operations,
    batchable_actions,
    unbatchable_actions,
    operations_builder,
} from '@boundlessdigital/meraki-sdk'

The available resources are:

  • spec - a complete raw OpenAPI Definition of the Meraki API
  • schemas - pre-processed OpenAPI Definition, a dictionary of all the data types used in the Meraki API
  • endpoints - pre-processed OpenAPI Definition, a complete list of HTTP endpoints with their definitions as an array
  • operations - pre-processed OpenAPI Definition to help find operation definition by its ID (operation ID is the dictionary key, operation body is the value)
  • batchable_actions - a dictionary of all the API operations that support Action Batches. OpenAPI Operation ID is the dictionary key here.
  • unbatchable_actions - a list of the API operations that are supposed to support Action Batches but actually do not (because of bad Meraki API design or other reasons)
  • operations_builder - a dictionary of available API resources (in a form they are presented in the Client autogenerated code), where each resource contains available operations over it (like read, create, update, delete etc.)
0.0.62

10 months ago

0.0.85

8 months ago

0.0.63

10 months ago

0.0.86

8 months ago

0.0.64

10 months ago

0.0.87

8 months ago

0.0.88

8 months ago

0.0.66

10 months ago

0.0.89

8 months ago

0.0.67

10 months ago

0.0.69

10 months ago

0.0.80

8 months ago

0.0.81

8 months ago

0.0.82

8 months ago

0.0.60

10 months ago

0.0.83

8 months ago

0.0.61

10 months ago

0.0.95

7 months ago

0.0.73

10 months ago

0.0.74

10 months ago

0.0.75

10 months ago

0.0.53

10 months ago

0.0.54

10 months ago

0.0.77

9 months ago

0.0.55

10 months ago

0.0.78

9 months ago

0.0.56

10 months ago

0.0.79

8 months ago

0.0.57

10 months ago

0.0.58

10 months ago

0.0.91

7 months ago

0.0.92

7 months ago

0.0.70

10 months ago

0.0.93

7 months ago

0.0.71

10 months ago

0.0.94

7 months ago

0.0.72

10 months ago

0.0.51

11 months ago

0.0.52

10 months ago

0.0.3

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago