Skip to content

Commit e2e3107

Browse files
author
Shiyue Cheng
committed
updated w/ release 1.2.0
1 parent 31f44e3 commit e2e3107

5 files changed

Lines changed: 365 additions & 1 deletion

File tree

meraki/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
SUPPRESS_LOGGING, SIMULATE_API_CALLS, BE_GEO_ID, MERAKI_PYTHON_SDK_CALLER
2121
)
2222

23-
__version__ = '1.1.0b4'
23+
__version__ = '1.2.0'
2424

2525
class DashboardAPI(object):
2626
"""

meraki/aio/api/organizations.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,55 @@ def updateOrganizationLicense(self, organizationId: str, licenseId: str, **kwarg
993993

994994
return self._session.put(metadata, resource, payload)
995995

996+
def getOrganizationLoginSecurity(self, organizationId: str):
997+
"""
998+
**Returns the login security settings for an organization.**
999+
https://developer.cisco.com/meraki/api-v1/#!get-organization-login-security
1000+
1001+
- organizationId (string): (required)
1002+
"""
1003+
1004+
metadata = {
1005+
'tags': ['organizations', 'configure', 'loginSecurity'],
1006+
'operation': 'getOrganizationLoginSecurity'
1007+
}
1008+
resource = f'/organizations/{organizationId}/loginSecurity'
1009+
1010+
return self._session.get(metadata, resource)
1011+
1012+
def updateOrganizationLoginSecurity(self, organizationId: str, **kwargs):
1013+
"""
1014+
**Update the login security settings for an organization**
1015+
https://developer.cisco.com/meraki/api-v1/#!update-organization-login-security
1016+
1017+
- organizationId (string): (required)
1018+
- enforcePasswordExpiration (boolean): Boolean indicating whether users are forced to change their password every X number of days.
1019+
- passwordExpirationDays (integer): Number of days after which users will be forced to change their password.
1020+
- enforceDifferentPasswords (boolean): Boolean indicating whether users, when setting a new password, are forced to choose a new password that is different from any past passwords.
1021+
- numDifferentPasswords (integer): Number of recent passwords that new password must be distinct from.
1022+
- enforceStrongPasswords (boolean): Boolean indicating whether users will be forced to choose strong passwords for their accounts. Strong passwords are at least 8 characters that contain 3 of the following: number, uppercase letter, lowercase letter, and symbol
1023+
- enforceAccountLockout (boolean): Boolean indicating whether users' Dashboard accounts will be locked out after a specified number of consecutive failed login attempts.
1024+
- accountLockoutAttempts (integer): Number of consecutive failed login attempts after which users' accounts will be locked.
1025+
- enforceIdleTimeout (boolean): Boolean indicating whether users will be logged out after being idle for the specified number of minutes.
1026+
- idleTimeoutMinutes (integer): Number of minutes users can remain idle before being logged out of their accounts.
1027+
- enforceTwoFactorAuth (boolean): Boolean indicating whether users in this organization will be required to use an extra verification code when logging in to Dashboard. This code will be sent to their mobile phone via SMS, or can be generated by the Google Authenticator application.
1028+
- enforceLoginIpRanges (boolean): Boolean indicating whether organization will restrict access to Dashboard (including the API) from certain IP addresses.
1029+
- loginIpRanges (array): List of acceptable IP ranges. Entries can be single IP addresses, IP address ranges, and CIDR subnets.
1030+
"""
1031+
1032+
kwargs.update(locals())
1033+
1034+
metadata = {
1035+
'tags': ['organizations', 'configure', 'loginSecurity'],
1036+
'operation': 'updateOrganizationLoginSecurity'
1037+
}
1038+
resource = f'/organizations/{organizationId}/loginSecurity'
1039+
1040+
body_params = ['enforcePasswordExpiration', 'passwordExpirationDays', 'enforceDifferentPasswords', 'numDifferentPasswords', 'enforceStrongPasswords', 'enforceAccountLockout', 'accountLockoutAttempts', 'enforceIdleTimeout', 'idleTimeoutMinutes', 'enforceTwoFactorAuth', 'enforceLoginIpRanges', 'loginIpRanges', ]
1041+
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
1042+
1043+
return self._session.put(metadata, resource, payload)
1044+
9961045
def getOrganizationNetworks(self, organizationId: str, total_pages=1, direction='next', **kwargs):
9971046
"""
9981047
**List the networks that the user has privileges on in an organization**

meraki/aio/api/switch.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,139 @@ def updateNetworkSwitchAccessControlLists(self, networkId: str, rules: list):
514514

515515
return self._session.put(metadata, resource, payload)
516516

517+
def getNetworkSwitchAccessPolicies(self, networkId: str):
518+
"""
519+
**List the access policies for a switch network**
520+
https://developer.cisco.com/meraki/api-v1/#!get-network-switch-access-policies
521+
522+
- networkId (string): (required)
523+
"""
524+
525+
metadata = {
526+
'tags': ['switch', 'configure', 'accessPolicies'],
527+
'operation': 'getNetworkSwitchAccessPolicies'
528+
}
529+
resource = f'/networks/{networkId}/switch/accessPolicies'
530+
531+
return self._session.get(metadata, resource)
532+
533+
def createNetworkSwitchAccessPolicy(self, networkId: str, name: str, radiusServers: list, radiusTestingEnabled: bool, radiusCoaSupportEnabled: bool, radiusAccountingEnabled: bool, hostMode: str, urlRedirectWalledGardenEnabled: bool, **kwargs):
534+
"""
535+
**Create an access policy for a switch network**
536+
https://developer.cisco.com/meraki/api-v1/#!create-network-switch-access-policy
537+
538+
- networkId (string): (required)
539+
- name (string): Name of the access policy
540+
- radiusServers (array): List of RADIUS servers to require connecting devices to authenticate against before granting network access
541+
- radiusTestingEnabled (boolean): If enabled, Meraki devices will periodically send access-request messages to these RADIUS servers
542+
- radiusCoaSupportEnabled (boolean): Change of authentication for RADIUS re-authentication and disconnection
543+
- radiusAccountingEnabled (boolean): Enable to send start, interim-update and stop messages to a configured RADIUS accounting server for tracking connected clients
544+
- hostMode (string): Choose the Host Mode for the access policy.
545+
- urlRedirectWalledGardenEnabled (boolean): Enable to restrict access for clients to a specific set of IP addresses or hostnames prior to authentication
546+
- radiusAccountingServers (array): List of RADIUS accounting servers to require connecting devices to authenticate against before granting network access
547+
- accessPolicyType (string): Access Type of the policy. Automatically 'Hybrid authentication' when hostMode is 'Multi-Domain'.
548+
- increaseAccessSpeed (boolean): Enabling this option will make switches execute 802.1X and MAC-bypass authentication simultaneously so that clients authenticate faster. Only required when accessPolicyType is 'Hybrid Authentication.
549+
- guestVlanId (integer): ID for the guest VLAN allow unauthorized devices access to limited network resources
550+
- voiceVlanClients (boolean): CDP/LLDP capable voice clients will be able to use this VLAN. Automatically true when hostMode is 'Multi-Domain'.
551+
- urlRedirectWalledGardenRanges (array): IP address ranges, in CIDR notation, to restrict access for clients to a specific set of IP addresses or hostnames prior to authentication
552+
"""
553+
554+
kwargs.update(locals())
555+
556+
if 'hostMode' in kwargs:
557+
options = ['Single-Host', 'Multi-Domain', 'Multi-Host', 'Multi-Auth']
558+
assert kwargs['hostMode'] in options, f'''"hostMode" cannot be "{kwargs['hostMode']}", & must be set to one of: {options}'''
559+
if 'accessPolicyType' in kwargs:
560+
options = ['802.1x', 'MAC authentication bypass', 'Hybrid authentication']
561+
assert kwargs['accessPolicyType'] in options, f'''"accessPolicyType" cannot be "{kwargs['accessPolicyType']}", & must be set to one of: {options}'''
562+
563+
metadata = {
564+
'tags': ['switch', 'configure', 'accessPolicies'],
565+
'operation': 'createNetworkSwitchAccessPolicy'
566+
}
567+
resource = f'/networks/{networkId}/switch/accessPolicies'
568+
569+
body_params = ['name', 'radiusServers', 'radiusTestingEnabled', 'radiusCoaSupportEnabled', 'radiusAccountingEnabled', 'radiusAccountingServers', 'hostMode', 'accessPolicyType', 'increaseAccessSpeed', 'guestVlanId', 'voiceVlanClients', 'urlRedirectWalledGardenEnabled', 'urlRedirectWalledGardenRanges', ]
570+
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
571+
572+
return self._session.post(metadata, resource, payload)
573+
574+
def getNetworkSwitchAccessPolicy(self, networkId: str, accessPolicyNumber: str):
575+
"""
576+
**Return a specific access policy for a switch network**
577+
https://developer.cisco.com/meraki/api-v1/#!get-network-switch-access-policy
578+
579+
- networkId (string): (required)
580+
- accessPolicyNumber (string): (required)
581+
"""
582+
583+
metadata = {
584+
'tags': ['switch', 'configure', 'accessPolicies'],
585+
'operation': 'getNetworkSwitchAccessPolicy'
586+
}
587+
resource = f'/networks/{networkId}/switch/accessPolicies/{accessPolicyNumber}'
588+
589+
return self._session.get(metadata, resource)
590+
591+
def updateNetworkSwitchAccessPolicy(self, networkId: str, accessPolicyNumber: str, **kwargs):
592+
"""
593+
**Update an access policy for a switch network**
594+
https://developer.cisco.com/meraki/api-v1/#!update-network-switch-access-policy
595+
596+
- networkId (string): (required)
597+
- accessPolicyNumber (string): (required)
598+
- name (string): Name of the access policy
599+
- radiusServers (array): List of RADIUS servers to require connecting devices to authenticate against before granting network access
600+
- radiusTestingEnabled (boolean): If enabled, Meraki devices will periodically send access-request messages to these RADIUS servers
601+
- radiusCoaSupportEnabled (boolean): Change of authentication for RADIUS re-authentication and disconnection
602+
- radiusAccountingEnabled (boolean): Enable to send start, interim-update and stop messages to a configured RADIUS accounting server for tracking connected clients
603+
- radiusAccountingServers (array): List of RADIUS accounting servers to require connecting devices to authenticate against before granting network access
604+
- hostMode (string): Choose the Host Mode for the access policy.
605+
- accessPolicyType (string): Access Type of the policy. Automatically 'Hybrid authentication' when hostMode is 'Multi-Domain'.
606+
- increaseAccessSpeed (boolean): Enabling this option will make switches execute 802.1X and MAC-bypass authentication simultaneously so that clients authenticate faster. Only required when accessPolicyType is 'Hybrid Authentication.
607+
- guestVlanId (integer): ID for the guest VLAN allow unauthorized devices access to limited network resources
608+
- voiceVlanClients (boolean): CDP/LLDP capable voice clients will be able to use this VLAN. Automatically true when hostMode is 'Multi-Domain'.
609+
- urlRedirectWalledGardenEnabled (boolean): Enable to restrict access for clients to a specific set of IP addresses or hostnames prior to authentication
610+
- urlRedirectWalledGardenRanges (array): IP address ranges, in CIDR notation, to restrict access for clients to a specific set of IP addresses or hostnames prior to authentication
611+
"""
612+
613+
kwargs.update(locals())
614+
615+
if 'hostMode' in kwargs:
616+
options = ['Single-Host', 'Multi-Domain', 'Multi-Host', 'Multi-Auth']
617+
assert kwargs['hostMode'] in options, f'''"hostMode" cannot be "{kwargs['hostMode']}", & must be set to one of: {options}'''
618+
if 'accessPolicyType' in kwargs:
619+
options = ['802.1x', 'MAC authentication bypass', 'Hybrid authentication']
620+
assert kwargs['accessPolicyType'] in options, f'''"accessPolicyType" cannot be "{kwargs['accessPolicyType']}", & must be set to one of: {options}'''
621+
622+
metadata = {
623+
'tags': ['switch', 'configure', 'accessPolicies'],
624+
'operation': 'updateNetworkSwitchAccessPolicy'
625+
}
626+
resource = f'/networks/{networkId}/switch/accessPolicies/{accessPolicyNumber}'
627+
628+
body_params = ['name', 'radiusServers', 'radiusTestingEnabled', 'radiusCoaSupportEnabled', 'radiusAccountingEnabled', 'radiusAccountingServers', 'hostMode', 'accessPolicyType', 'increaseAccessSpeed', 'guestVlanId', 'voiceVlanClients', 'urlRedirectWalledGardenEnabled', 'urlRedirectWalledGardenRanges', ]
629+
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
630+
631+
return self._session.put(metadata, resource, payload)
632+
633+
def deleteNetworkSwitchAccessPolicy(self, networkId: str, accessPolicyNumber: str):
634+
"""
635+
**Delete an access policy for a switch network**
636+
https://developer.cisco.com/meraki/api-v1/#!delete-network-switch-access-policy
637+
638+
- networkId (string): (required)
639+
- accessPolicyNumber (string): (required)
640+
"""
641+
642+
metadata = {
643+
'tags': ['switch', 'configure', 'accessPolicies'],
644+
'operation': 'deleteNetworkSwitchAccessPolicy'
645+
}
646+
resource = f'/networks/{networkId}/switch/accessPolicies/{accessPolicyNumber}'
647+
648+
return self._session.delete(metadata, resource)
649+
517650
def getNetworkSwitchDhcpServerPolicy(self, networkId: str):
518651
"""
519652
**Return the DHCP server policy**

meraki/api/organizations.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,55 @@ def updateOrganizationLicense(self, organizationId: str, licenseId: str, **kwarg
993993

994994
return self._session.put(metadata, resource, payload)
995995

996+
def getOrganizationLoginSecurity(self, organizationId: str):
997+
"""
998+
**Returns the login security settings for an organization.**
999+
https://developer.cisco.com/meraki/api-v1/#!get-organization-login-security
1000+
1001+
- organizationId (string): (required)
1002+
"""
1003+
1004+
metadata = {
1005+
'tags': ['organizations', 'configure', 'loginSecurity'],
1006+
'operation': 'getOrganizationLoginSecurity'
1007+
}
1008+
resource = f'/organizations/{organizationId}/loginSecurity'
1009+
1010+
return self._session.get(metadata, resource)
1011+
1012+
def updateOrganizationLoginSecurity(self, organizationId: str, **kwargs):
1013+
"""
1014+
**Update the login security settings for an organization**
1015+
https://developer.cisco.com/meraki/api-v1/#!update-organization-login-security
1016+
1017+
- organizationId (string): (required)
1018+
- enforcePasswordExpiration (boolean): Boolean indicating whether users are forced to change their password every X number of days.
1019+
- passwordExpirationDays (integer): Number of days after which users will be forced to change their password.
1020+
- enforceDifferentPasswords (boolean): Boolean indicating whether users, when setting a new password, are forced to choose a new password that is different from any past passwords.
1021+
- numDifferentPasswords (integer): Number of recent passwords that new password must be distinct from.
1022+
- enforceStrongPasswords (boolean): Boolean indicating whether users will be forced to choose strong passwords for their accounts. Strong passwords are at least 8 characters that contain 3 of the following: number, uppercase letter, lowercase letter, and symbol
1023+
- enforceAccountLockout (boolean): Boolean indicating whether users' Dashboard accounts will be locked out after a specified number of consecutive failed login attempts.
1024+
- accountLockoutAttempts (integer): Number of consecutive failed login attempts after which users' accounts will be locked.
1025+
- enforceIdleTimeout (boolean): Boolean indicating whether users will be logged out after being idle for the specified number of minutes.
1026+
- idleTimeoutMinutes (integer): Number of minutes users can remain idle before being logged out of their accounts.
1027+
- enforceTwoFactorAuth (boolean): Boolean indicating whether users in this organization will be required to use an extra verification code when logging in to Dashboard. This code will be sent to their mobile phone via SMS, or can be generated by the Google Authenticator application.
1028+
- enforceLoginIpRanges (boolean): Boolean indicating whether organization will restrict access to Dashboard (including the API) from certain IP addresses.
1029+
- loginIpRanges (array): List of acceptable IP ranges. Entries can be single IP addresses, IP address ranges, and CIDR subnets.
1030+
"""
1031+
1032+
kwargs.update(locals())
1033+
1034+
metadata = {
1035+
'tags': ['organizations', 'configure', 'loginSecurity'],
1036+
'operation': 'updateOrganizationLoginSecurity'
1037+
}
1038+
resource = f'/organizations/{organizationId}/loginSecurity'
1039+
1040+
body_params = ['enforcePasswordExpiration', 'passwordExpirationDays', 'enforceDifferentPasswords', 'numDifferentPasswords', 'enforceStrongPasswords', 'enforceAccountLockout', 'accountLockoutAttempts', 'enforceIdleTimeout', 'idleTimeoutMinutes', 'enforceTwoFactorAuth', 'enforceLoginIpRanges', 'loginIpRanges', ]
1041+
payload = {k.strip(): v for k, v in kwargs.items() if k.strip() in body_params}
1042+
1043+
return self._session.put(metadata, resource, payload)
1044+
9961045
def getOrganizationNetworks(self, organizationId: str, total_pages=1, direction='next', **kwargs):
9971046
"""
9981047
**List the networks that the user has privileges on in an organization**

0 commit comments

Comments
 (0)