So, i have figureed out how to create a switchPortProfile ( and delete it ). However, now i'm trying to figure out how you apply this profile to a port... Which api provides that?
def switchPortProfile(api_key: str, request_type, action, PhysicalResourceId):
"""
Manage Network Level Switch port configurations. This is an early API
This does not attempt to verify the payload. That should be done earlier.
"""
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"Accept": "application/json"
}
network_id = action['Parameters']['networkId']
match request_type:
case "Create":
url = f"https://api.meraki.com/api/v1/networks/{network_id}/switch/ports/profiles"
response = requests.post(
url=url,
headers=headers,
json=action['Parameters']['policy']
)
response.raise_for_status() # Raise an exception for bad status codes
return {
'PhysicalResourceId': response['profileId'],
'Data': {
'accessPolicyNumber': response['accessPolicyNumber']
}
}
case "Update":
url = f"https://api.meraki.com/api/v1/networks/{network_id}/switch/ports/profiles/{PhysicalResourceId}"
response = requests.put(
url=url,
headers=headers,
json=action['Parameters']['policy']
)
response.raise_for_status() # Raise an exception for bad status codes
case "Delete":
url = f"https://api.meraki.com/api/v1/networks/{network_id}/switch/ports/profiles/{PhysicalResourceId}"
response = requests.delete(
url=url,
headers=headers
)
response.raise_for_status() # Raise an exception for bad status codes