diff --git a/meraki/__init__.py b/meraki/__init__.py index 7293162..b3eb2a6 100644 --- a/meraki/__init__.py +++ b/meraki/__init__.py @@ -43,7 +43,7 @@ ) from meraki.rest_session import * -__version__ = '2.0.1' +__version__ = '2.0.2' __api_version__ = '1.57.0' diff --git a/meraki/aio/api/appliance.py b/meraki/aio/api/appliance.py index ff13417..78a3b6c 100644 --- a/meraki/aio/api/appliance.py +++ b/meraki/aio/api/appliance.py @@ -3086,7 +3086,7 @@ def getOrganizationApplianceUplinksUsageByNetwork(self, organizationId: str, **k https://developer.cisco.com/meraki/api-v1/#!get-organization-appliance-uplinks-usage-by-network - organizationId (string): Organization ID - - t0 (string): The beginning of the timespan for the data. The maximum lookback period is 365 days from today. + - t0 (string): The beginning of the timespan for the data. The maximum lookback period is 30 days from today. - t1 (string): The end of the timespan for the data. t1 can be a maximum of 14 days after t0. - timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 14 days. The default is 1 day. """ diff --git a/meraki/aio/api/devices.py b/meraki/aio/api/devices.py index f712caa..4c1ec03 100644 --- a/meraki/aio/api/devices.py +++ b/meraki/aio/api/devices.py @@ -299,6 +299,52 @@ def getDeviceLiveToolsLedsBlink(self, serial: str, ledsBlinkId: str): + def createDeviceLiveToolsMacTable(self, serial: str, **kwargs): + """ + **Enqueue a job to request the MAC table from the device** + https://developer.cisco.com/meraki/api-v1/#!create-device-live-tools-mac-table + + - serial (string): Serial + - callback (object): Details for the callback. Please include either an httpServerId OR url and sharedSecret + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['devices', 'liveTools', 'macTable'], + 'operation': 'createDeviceLiveToolsMacTable' + } + serial = urllib.parse.quote(str(serial), safe='') + resource = f'/devices/{serial}/liveTools/macTable' + + body_params = ['callback', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def getDeviceLiveToolsMacTable(self, serial: str, macTableId: str): + """ + **Return a MAC table live tool job.** + https://developer.cisco.com/meraki/api-v1/#!get-device-live-tools-mac-table + + - serial (string): Serial + - macTableId (string): Mac table ID + """ + + metadata = { + 'tags': ['devices', 'liveTools', 'macTable'], + 'operation': 'getDeviceLiveToolsMacTable' + } + serial = urllib.parse.quote(str(serial), safe='') + macTableId = urllib.parse.quote(str(macTableId), safe='') + resource = f'/devices/{serial}/liveTools/macTable/{macTableId}' + + return self._session.get(metadata, resource) + + + def createDeviceLiveToolsPing(self, serial: str, target: str, **kwargs): """ **Enqueue a job to ping a target host from the device** diff --git a/meraki/aio/api/organizations.py b/meraki/aio/api/organizations.py index dcbeeae..dd53bbc 100644 --- a/meraki/aio/api/organizations.py +++ b/meraki/aio/api/organizations.py @@ -2114,6 +2114,327 @@ def getOrganizationDevicesOverviewByModel(self, organizationId: str, **kwargs): + def getOrganizationDevicesPacketCaptureCaptures(self, organizationId: str, total_pages=1, direction='next', **kwargs): + """ + **List Packet Captures** + https://developer.cisco.com/meraki/api-v1/#!get-organization-devices-packet-capture-captures + + - organizationId (string): Organization ID + - total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages + - direction (string): direction to paginate, either "next" (default) or "prev" page + - captureIds (array): Return the packet captures of the specified capture ids + - networkIds (array): Return the packet captures of the specified network(s) + - serials (array): Return the packet captures of the specified device(s) + - process (array): Return the packet captures of the specified process + - captureStatus (array): Return the packet captures of the specified capture status + - name (array): Return the packet captures matching the specified name + - clientMac (array): Return the packet captures matching the specified client macs + - notes (string): Return the packet captures matching the specified notes + - deviceName (string): Return the packet captures matching the specified device name + - adminName (string): Return the packet captures matching the admin name + - perPage (integer): The number of entries per page returned. Acceptable range is 3 - 100. Default is 10. + - startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it. + - endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it. + - sortOrder (string): Sorted order of entries. Order options are 'ascending' and 'descending'. Default is 'descending'. + """ + + kwargs.update(locals()) + + if 'sortOrder' in kwargs: + options = ['ascending', 'descending'] + assert kwargs['sortOrder'] in options, f'''"sortOrder" cannot be "{kwargs['sortOrder']}", & must be set to one of: {options}''' + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'getOrganizationDevicesPacketCaptureCaptures' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures' + + query_params = ['captureIds', 'networkIds', 'serials', 'process', 'captureStatus', 'name', 'clientMac', 'notes', 'deviceName', 'adminName', 'perPage', 'startingAfter', 'endingBefore', 'sortOrder', ] + params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params} + + array_params = ['captureIds', 'networkIds', 'serials', 'process', 'captureStatus', 'name', 'clientMac', ] + for k, v in kwargs.items(): + if k.strip() in array_params: + params[f'{k.strip()}[]'] = kwargs[f'{k}'] + params.pop(k.strip()) + + return self._session.get_pages(metadata, resource, params, total_pages, direction) + + + + def createOrganizationDevicesPacketCaptureCapture(self, organizationId: str, serials: list, name: str, **kwargs): + """ + **Perform a packet capture on a device and store in Meraki Cloud** + https://developer.cisco.com/meraki/api-v1/#!create-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - serials (array): The serial(s) of the device(s) + - name (string): Name of packet capture file + - outputType (string): Output type of packet capture file. Possible values: text, pcap, cloudshark, or upload_to_cloud + - destination (string): Destination of packet capture file. Possible values: [upload_to_cloud] + - ports (string): Ports of packet capture file, comma-separated + - notes (string): Reason for taking the packet capture + - duration (integer): Duration in seconds of packet capture + - filterExpression (string): Filter expression for packet capture + - interface (string): Interface of the device + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'createOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures' + + body_params = ['serials', 'name', 'outputType', 'destination', 'ports', 'notes', 'duration', 'filterExpression', 'interface', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def bulkOrganizationDevicesPacketCaptureCapturesDelete(self, organizationId: str, captureIds: list): + """ + **BulkDelete packet captures from cloud** + https://developer.cisco.com/meraki/api-v1/#!bulk-organization-devices-packet-capture-captures-delete + + - organizationId (string): Organization ID + - captureIds (array): Delete the packet captures of the specified capture ids + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'bulkOrganizationDevicesPacketCaptureCapturesDelete' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/bulkDelete' + + body_params = ['captureIds', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def deleteOrganizationDevicesPacketCaptureCapture(self, organizationId: str, captureId: str): + """ + **Delete a single packet capture from cloud using captureId** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - captureId (string): Capture ID + """ + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'deleteOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}' + + return self._session.delete(metadata, resource) + + + + def generateOrganizationDevicesPacketCaptureCaptureDownloadUrl(self, organizationId: str, captureId: str): + """ + **Get presigned download URL for given packet capture id** + https://developer.cisco.com/meraki/api-v1/#!generate-organization-devices-packet-capture-capture-download-url + + - organizationId (string): Organization ID + - captureId (string): Capture ID + """ + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures', 'downloadUrl'], + 'operation': 'generateOrganizationDevicesPacketCaptureCaptureDownloadUrl' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}/downloadUrl/generate' + + return self._session.post(metadata, resource) + + + + def stopOrganizationDevicesPacketCaptureCapture(self, organizationId: str, captureId: str, serials: list): + """ + **Stop a specific packet capture (not supported for Catalyst devices)** + https://developer.cisco.com/meraki/api-v1/#!stop-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - captureId (string): Capture ID + - serials (array): The serial(s) of the device(s) to stop the capture on + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'stopOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}/stop' + + body_params = ['serials', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def getOrganizationDevicesPacketCaptureSchedules(self, organizationId: str, **kwargs): + """ + **List the Packet Capture Schedules** + https://developer.cisco.com/meraki/api-v1/#!get-organization-devices-packet-capture-schedules + + - organizationId (string): Organization ID + - scheduleIds (array): Return the packet captures schedules of the specified packet capture schedule ids + - networkIds (array): Return the scheduled packet captures of the specified network(s) + - deviceIds (array): Return the scheduled packet captures of the specified device(s) + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'getOrganizationDevicesPacketCaptureSchedules' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules' + + query_params = ['scheduleIds', 'networkIds', 'deviceIds', ] + params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params} + + array_params = ['scheduleIds', 'networkIds', 'deviceIds', ] + for k, v in kwargs.items(): + if k.strip() in array_params: + params[f'{k.strip()}[]'] = kwargs[f'{k}'] + params.pop(k.strip()) + + return self._session.get(metadata, resource, params) + + + + def createOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, devices: list, **kwargs): + """ + **Create a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!create-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'createOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def reorderOrganizationDevicesPacketCaptureSchedules(self, organizationId: str, order: list): + """ + **Bulk update priorities of pcap schedules** + https://developer.cisco.com/meraki/api-v1/#!reorder-organization-devices-packet-capture-schedules + + - organizationId (string): Organization ID + - order (array): Array of schedule IDs and their priorities to reorder. + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'reorderOrganizationDevicesPacketCaptureSchedules' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/reorder' + + body_params = ['order', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def updateOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str, devices: list, **kwargs): + """ + **Update a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!update-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Schedule ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'updateOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + scheduleId = urllib.parse.quote(str(scheduleId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.put(metadata, resource, payload) + + + + def deleteOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str): + """ + **Delete schedule from cloud** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Delete the capture schedules of the specified capture schedule id + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'deleteOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + return self._session.delete(metadata, resource) + + + def getOrganizationDevicesPowerModulesStatusesByDevice(self, organizationId: str, total_pages=1, direction='next', **kwargs): """ **List the most recent status information for power modules in rackmount MX and MS devices that support them** diff --git a/meraki/api/appliance.py b/meraki/api/appliance.py index d9f8b03..1438e17 100644 --- a/meraki/api/appliance.py +++ b/meraki/api/appliance.py @@ -3086,7 +3086,7 @@ def getOrganizationApplianceUplinksUsageByNetwork(self, organizationId: str, **k https://developer.cisco.com/meraki/api-v1/#!get-organization-appliance-uplinks-usage-by-network - organizationId (string): Organization ID - - t0 (string): The beginning of the timespan for the data. The maximum lookback period is 365 days from today. + - t0 (string): The beginning of the timespan for the data. The maximum lookback period is 30 days from today. - t1 (string): The end of the timespan for the data. t1 can be a maximum of 14 days after t0. - timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameters t0 and t1. The value must be in seconds and be less than or equal to 14 days. The default is 1 day. """ diff --git a/meraki/api/batch/organizations.py b/meraki/api/batch/organizations.py index 618815d..7834c6a 100644 --- a/meraki/api/batch/organizations.py +++ b/meraki/api/batch/organizations.py @@ -716,6 +716,195 @@ def bulkUpdateOrganizationDevicesDetails(self, organizationId: str, serials: lis + def bulkOrganizationDevicesPacketCaptureCapturesDelete(self, organizationId: str, captureIds: list): + """ + **BulkDelete packet captures from cloud** + https://developer.cisco.com/meraki/api-v1/#!bulk-organization-devices-packet-capture-captures-delete + + - organizationId (string): Organization ID + - captureIds (array): Delete the packet captures of the specified capture ids + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'bulkOrganizationDevicesPacketCaptureCapturesDelete' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/bulkDelete' + + body_params = ['captureIds', ] + action = { + "resource": resource, + "operation": "destroy", + } + return action + + + + + + + def deleteOrganizationDevicesPacketCaptureCapture(self, organizationId: str, captureId: str): + """ + **Delete a single packet capture from cloud using captureId** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - captureId (string): Capture ID + """ + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'deleteOrganizationDevicesPacketCaptureCapture' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}' + + action = { + "resource": resource, + "operation": "destroy", + } + return action + + + + + + + def createOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, devices: list, **kwargs): + """ + **Create a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!create-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'createOrganizationDevicesPacketCaptureSchedule' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + action = { + "resource": resource, + "operation": "create", + "body": payload + } + return action + + + + + + + def reorderOrganizationDevicesPacketCaptureSchedules(self, organizationId: str, order: list): + """ + **Bulk update priorities of pcap schedules** + https://developer.cisco.com/meraki/api-v1/#!reorder-organization-devices-packet-capture-schedules + + - organizationId (string): Organization ID + - order (array): Array of schedule IDs and their priorities to reorder. + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'reorderOrganizationDevicesPacketCaptureSchedules' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/reorder' + + body_params = ['order', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + action = { + "resource": resource, + "operation": "reorder", + "body": payload + } + return action + + + + + + + def updateOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str, devices: list, **kwargs): + """ + **Update a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!update-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Schedule ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'updateOrganizationDevicesPacketCaptureSchedule' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + action = { + "resource": resource, + "operation": "update", + "body": payload + } + return action + + + + + + + def deleteOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str): + """ + **Delete schedule from cloud** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Delete the capture schedules of the specified capture schedule id + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'deleteOrganizationDevicesPacketCaptureSchedule' + } + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + action = { + "resource": resource, + "operation": "destroy", + } + return action + + + + + + def updateOrganizationEarlyAccessFeaturesOptIn(self, organizationId: str, optInId: str, **kwargs): """ **Update an early access feature opt-in for an organization** diff --git a/meraki/api/devices.py b/meraki/api/devices.py index a632ec4..4118887 100644 --- a/meraki/api/devices.py +++ b/meraki/api/devices.py @@ -299,6 +299,52 @@ def getDeviceLiveToolsLedsBlink(self, serial: str, ledsBlinkId: str): + def createDeviceLiveToolsMacTable(self, serial: str, **kwargs): + """ + **Enqueue a job to request the MAC table from the device** + https://developer.cisco.com/meraki/api-v1/#!create-device-live-tools-mac-table + + - serial (string): Serial + - callback (object): Details for the callback. Please include either an httpServerId OR url and sharedSecret + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['devices', 'liveTools', 'macTable'], + 'operation': 'createDeviceLiveToolsMacTable' + } + serial = urllib.parse.quote(str(serial), safe='') + resource = f'/devices/{serial}/liveTools/macTable' + + body_params = ['callback', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def getDeviceLiveToolsMacTable(self, serial: str, macTableId: str): + """ + **Return a MAC table live tool job.** + https://developer.cisco.com/meraki/api-v1/#!get-device-live-tools-mac-table + + - serial (string): Serial + - macTableId (string): Mac table ID + """ + + metadata = { + 'tags': ['devices', 'liveTools', 'macTable'], + 'operation': 'getDeviceLiveToolsMacTable' + } + serial = urllib.parse.quote(str(serial), safe='') + macTableId = urllib.parse.quote(str(macTableId), safe='') + resource = f'/devices/{serial}/liveTools/macTable/{macTableId}' + + return self._session.get(metadata, resource) + + + def createDeviceLiveToolsPing(self, serial: str, target: str, **kwargs): """ **Enqueue a job to ping a target host from the device** diff --git a/meraki/api/organizations.py b/meraki/api/organizations.py index b8a5453..17ea9c4 100644 --- a/meraki/api/organizations.py +++ b/meraki/api/organizations.py @@ -2114,6 +2114,327 @@ def getOrganizationDevicesOverviewByModel(self, organizationId: str, **kwargs): + def getOrganizationDevicesPacketCaptureCaptures(self, organizationId: str, total_pages=1, direction='next', **kwargs): + """ + **List Packet Captures** + https://developer.cisco.com/meraki/api-v1/#!get-organization-devices-packet-capture-captures + + - organizationId (string): Organization ID + - total_pages (integer or string): use with perPage to get total results up to total_pages*perPage; -1 or "all" for all pages + - direction (string): direction to paginate, either "next" (default) or "prev" page + - captureIds (array): Return the packet captures of the specified capture ids + - networkIds (array): Return the packet captures of the specified network(s) + - serials (array): Return the packet captures of the specified device(s) + - process (array): Return the packet captures of the specified process + - captureStatus (array): Return the packet captures of the specified capture status + - name (array): Return the packet captures matching the specified name + - clientMac (array): Return the packet captures matching the specified client macs + - notes (string): Return the packet captures matching the specified notes + - deviceName (string): Return the packet captures matching the specified device name + - adminName (string): Return the packet captures matching the admin name + - perPage (integer): The number of entries per page returned. Acceptable range is 3 - 100. Default is 10. + - startingAfter (string): A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it. + - endingBefore (string): A token used by the server to indicate the end of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it. + - sortOrder (string): Sorted order of entries. Order options are 'ascending' and 'descending'. Default is 'descending'. + """ + + kwargs.update(locals()) + + if 'sortOrder' in kwargs: + options = ['ascending', 'descending'] + assert kwargs['sortOrder'] in options, f'''"sortOrder" cannot be "{kwargs['sortOrder']}", & must be set to one of: {options}''' + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'getOrganizationDevicesPacketCaptureCaptures' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures' + + query_params = ['captureIds', 'networkIds', 'serials', 'process', 'captureStatus', 'name', 'clientMac', 'notes', 'deviceName', 'adminName', 'perPage', 'startingAfter', 'endingBefore', 'sortOrder', ] + params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params} + + array_params = ['captureIds', 'networkIds', 'serials', 'process', 'captureStatus', 'name', 'clientMac', ] + for k, v in kwargs.items(): + if k.strip() in array_params: + params[f'{k.strip()}[]'] = kwargs[f'{k}'] + params.pop(k.strip()) + + return self._session.get_pages(metadata, resource, params, total_pages, direction) + + + + def createOrganizationDevicesPacketCaptureCapture(self, organizationId: str, serials: list, name: str, **kwargs): + """ + **Perform a packet capture on a device and store in Meraki Cloud** + https://developer.cisco.com/meraki/api-v1/#!create-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - serials (array): The serial(s) of the device(s) + - name (string): Name of packet capture file + - outputType (string): Output type of packet capture file. Possible values: text, pcap, cloudshark, or upload_to_cloud + - destination (string): Destination of packet capture file. Possible values: [upload_to_cloud] + - ports (string): Ports of packet capture file, comma-separated + - notes (string): Reason for taking the packet capture + - duration (integer): Duration in seconds of packet capture + - filterExpression (string): Filter expression for packet capture + - interface (string): Interface of the device + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'createOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures' + + body_params = ['serials', 'name', 'outputType', 'destination', 'ports', 'notes', 'duration', 'filterExpression', 'interface', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def bulkOrganizationDevicesPacketCaptureCapturesDelete(self, organizationId: str, captureIds: list): + """ + **BulkDelete packet captures from cloud** + https://developer.cisco.com/meraki/api-v1/#!bulk-organization-devices-packet-capture-captures-delete + + - organizationId (string): Organization ID + - captureIds (array): Delete the packet captures of the specified capture ids + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'bulkOrganizationDevicesPacketCaptureCapturesDelete' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/bulkDelete' + + body_params = ['captureIds', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def deleteOrganizationDevicesPacketCaptureCapture(self, organizationId: str, captureId: str): + """ + **Delete a single packet capture from cloud using captureId** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - captureId (string): Capture ID + """ + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'deleteOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}' + + return self._session.delete(metadata, resource) + + + + def generateOrganizationDevicesPacketCaptureCaptureDownloadUrl(self, organizationId: str, captureId: str): + """ + **Get presigned download URL for given packet capture id** + https://developer.cisco.com/meraki/api-v1/#!generate-organization-devices-packet-capture-capture-download-url + + - organizationId (string): Organization ID + - captureId (string): Capture ID + """ + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures', 'downloadUrl'], + 'operation': 'generateOrganizationDevicesPacketCaptureCaptureDownloadUrl' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}/downloadUrl/generate' + + return self._session.post(metadata, resource) + + + + def stopOrganizationDevicesPacketCaptureCapture(self, organizationId: str, captureId: str, serials: list): + """ + **Stop a specific packet capture (not supported for Catalyst devices)** + https://developer.cisco.com/meraki/api-v1/#!stop-organization-devices-packet-capture-capture + + - organizationId (string): Organization ID + - captureId (string): Capture ID + - serials (array): The serial(s) of the device(s) to stop the capture on + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'captures'], + 'operation': 'stopOrganizationDevicesPacketCaptureCapture' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + captureId = urllib.parse.quote(str(captureId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/captures/{captureId}/stop' + + body_params = ['serials', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def getOrganizationDevicesPacketCaptureSchedules(self, organizationId: str, **kwargs): + """ + **List the Packet Capture Schedules** + https://developer.cisco.com/meraki/api-v1/#!get-organization-devices-packet-capture-schedules + + - organizationId (string): Organization ID + - scheduleIds (array): Return the packet captures schedules of the specified packet capture schedule ids + - networkIds (array): Return the scheduled packet captures of the specified network(s) + - deviceIds (array): Return the scheduled packet captures of the specified device(s) + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'getOrganizationDevicesPacketCaptureSchedules' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules' + + query_params = ['scheduleIds', 'networkIds', 'deviceIds', ] + params = {k.strip(): v for k, v in kwargs.items() if k.strip() in query_params} + + array_params = ['scheduleIds', 'networkIds', 'deviceIds', ] + for k, v in kwargs.items(): + if k.strip() in array_params: + params[f'{k.strip()}[]'] = kwargs[f'{k}'] + params.pop(k.strip()) + + return self._session.get(metadata, resource, params) + + + + def createOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, devices: list, **kwargs): + """ + **Create a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!create-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'createOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def reorderOrganizationDevicesPacketCaptureSchedules(self, organizationId: str, order: list): + """ + **Bulk update priorities of pcap schedules** + https://developer.cisco.com/meraki/api-v1/#!reorder-organization-devices-packet-capture-schedules + + - organizationId (string): Organization ID + - order (array): Array of schedule IDs and their priorities to reorder. + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'reorderOrganizationDevicesPacketCaptureSchedules' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/reorder' + + body_params = ['order', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.post(metadata, resource, payload) + + + + def updateOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str, devices: list, **kwargs): + """ + **Update a schedule for packet capture** + https://developer.cisco.com/meraki/api-v1/#!update-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Schedule ID + - devices (array): device details + - name (string): Name of the packet capture file + - notes (string): Reason for capture + - duration (integer): Duration of the capture in seconds + - filterExpression (string): Filter expression for the capture + - enabled (boolean): Enable or disable the schedule + - schedule (object): Schedule details + """ + + kwargs.update(locals()) + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'updateOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + scheduleId = urllib.parse.quote(str(scheduleId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + body_params = ['devices', 'name', 'notes', 'duration', 'filterExpression', 'enabled', 'schedule', ] + payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params} + + return self._session.put(metadata, resource, payload) + + + + def deleteOrganizationDevicesPacketCaptureSchedule(self, organizationId: str, scheduleId: str): + """ + **Delete schedule from cloud** + https://developer.cisco.com/meraki/api-v1/#!delete-organization-devices-packet-capture-schedule + + - organizationId (string): Organization ID + - scheduleId (string): Delete the capture schedules of the specified capture schedule id + """ + + kwargs = locals() + + metadata = { + 'tags': ['organizations', 'configure', 'devices', 'packetCapture', 'schedules'], + 'operation': 'deleteOrganizationDevicesPacketCaptureSchedule' + } + organizationId = urllib.parse.quote(str(organizationId), safe='') + resource = f'/organizations/{organizationId}/devices/packetCapture/schedules/{scheduleId}' + + return self._session.delete(metadata, resource) + + + def getOrganizationDevicesPowerModulesStatusesByDevice(self, organizationId: str, total_pages=1, direction='next', **kwargs): """ **List the most recent status information for power modules in rackmount MX and MS devices that support them** diff --git a/pyproject.toml b/pyproject.toml index d05ddee..9f7cbbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "meraki" -version = "2.0.1" +version = "2.0.2" description = "Meraki library for Python" authors = [ {name = "Cisco Meraki",email = "api-feedback@meraki.net"}