Meraki Dashboard
wingpy.cisco.merakidashboard.CiscoMerakiDashboard
¶
CiscoMerakiDashboard(
*,
token: str | None = None,
org_name: str | None = None,
network_name: str | None = None,
verify: SSLContext | bool = True,
timeout: int = 10,
retries: int = 10
)
Bases: RestApiBaseClass
Interact with the Cisco Meraki Dashboard API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
str | None
|
Bearer token for API authentication. Overrides the environment variable |
None
|
org_name
|
str | None
|
Default organization name. Overrides the environment variable |
None
|
verify
|
bool | SSLContext
|
Boolean values will enable or disable the default SSL verification. Use an ssl.SSLContext to specify custom Certificate Authority. |
True
|
timeout
|
int
|
Number of seconds to wait for HTTP responses before raising httpx.TimeoutException exception. |
10
|
retries
|
int
|
Number of failed HTTP attempts allowed before raising httpx.HTTPStatusError exception. |
3
|
Examples:
from wingpy import CiscoMerakiDashboard
hyperfabric = CiscoMerakiDashboard(
token=" ",
)
hyperfabric.get("/devices")
Warnings
Not all requests to Meraki Dashboard are suitable for concurrency.
Examples include DELETE /networks/{networkId}
and
POST /organizations/{organizationId}/networks/combine
.
For those endpoints, it is recommended to use single-treading for maximum performance.
Source code in src/wingpy/cisco/merakidashboard.py
get
¶
get(
path: str,
*,
params: dict[str, str | list[str]] | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
Send an HTTP GET
request to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
params
|
dict[str, str | list[str]] | None
|
URL query parameters to include in the request. will be added as Some Meraki Dashboard API endpoints have query parameters where the value data type is "array of strings",
ie. In those cases, the Meraki Dashboard API server expects the query parameter name to end with Example: |
None
|
path_params
|
dict | None
|
Replace placeholders like Will be combined with |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with |
None
|
timeout
|
int | None
|
Override the standard timeout timer |
None
|
Returns:
Type | Description |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/merakidashboard.py
get_all
¶
get_all(
path: str,
*,
params: dict[str, str | list[str]] | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None,
page_size: int | None = None
) -> list
Retrieves all pages of data from a JSON endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
params
|
dict[str, str | list[str]] | None
|
URL query parameters to include in the request. will be added as Some Meraki Dashboard API endpoints have query parameters where the value data type is "array of strings",
ie. In those cases, the Meraki Dashboard API server expects the query parameter name to end with Example: |
None
|
path_params
|
dict | None
|
Replace placeholders like Will be combined with |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with |
None
|
timeout
|
int | None
|
Override the standard timeout timer |
None
|
page_size
|
int | None
|
Set a specific page size. Default value varies on the server side per API endpoint. |
None
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries, similar to the endpoint-specific key in the JSON responses. |
Source code in src/wingpy/cisco/merakidashboard.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
post
¶
post(
path: str,
*,
data: str | dict | list | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
Send an HTTP POST
request to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
data
|
str | dict | list | None
|
Request payload as JSON string or Python list/dict object. |
required |
path_params
|
dict | None
|
Replace placeholders like Will be combined with |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with |
None
|
timeout
|
int | None
|
Override the standard timeout timer |
None
|
Returns:
Type | Description |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/merakidashboard.py
put
¶
put(
path: str,
*,
data: str | dict | list,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
Send an HTTP PUT
request to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
data
|
str | dict | list
|
Request payload as JSON string or Python list/dict object. |
required |
path_params
|
dict | None
|
Replace placeholders like Will be combined with |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with |
None
|
timeout
|
int | None
|
Override the standard timeout timer |
None
|
Returns:
Type | Description |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/merakidashboard.py
delete
¶
delete(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
Send an HTTP DELETE
request to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
path_params
|
dict | None
|
Replace placeholders like Will be combined with |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with |
None
|
timeout
|
int | None
|
Override the standard timeout timer |
None
|
Returns:
Type | Description |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/merakidashboard.py
authenticate
¶
Executes the API-specific authentication process and records timestamps for session tracking.
Notes
Authentication will automatically be carried out just-in-time.
Only call this method directly if you need to authenticate proactively, outside of normal request flow.
Source code in src/wingpy/base.py
tasks
instance-attribute
¶
Manages concurrent requests to the API server.
The number of concurrent requests is limited by the MAX_CONNECTIONS property:
- 1 connection is reserved for the main thread used for authentication and synchronous requests.
- The remaining connections are used for concurrent requests.
See Also
wingpy.scheduling.TaskRunner
Schedule and run asynchronous tasks in parallel.
timeout
instance-attribute
¶
The timeout in seconds for each request to the API server.
MAX_CONNECTIONS
class-attribute
instance-attribute
¶
The maximum number of concurrent connections opened to Meraki Dashboard.
1 connection will be used for general synchronous requests.
3 connections will be used for parallel asynchronous requests.
RETRY_RESPONSES
class-attribute
instance-attribute
¶
RETRY_RESPONSES = [
HttpResponsePattern(
status_codes=[400],
methods=["DELETE"],
content_patterns=[
compile(
'{"errors":\\["Unable to destroy network N_\\d+. This may be due to concurrent requests to delete or combine networks\\."\\]}'
)
],
)
]
The standard HTTP 429
status code indicates that the user has sent
too many requests in a given amount of time, and is being rate limited.
For certain endpoints that require asynchronous background processing by
Cisco Meraki Dashboard a HTTP 400
will be returned instead.
These responses will be retried.
headers
instance-attribute
¶
A dictionary of HTTP headers to be sent with each request.
These headers will be merged with any headers
dict passed to an individual request.
path_params
instance-attribute
¶
A dictionary of path parameters to be used in the API path of each request.
These parameters will be merged with any path_params
dict passed to the request.