Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
> * v1.00, 11.2020 -- Adjustments for OpenSource - Andreas Graber
> * v1.3, 06.2021 -- Snapshot creation added - Dario Kaelin
> * v1.5, 01.2023 -- Dependency Update
> * v1.6, 06.2024 -- Improvement for subscription - Dario Kaelin
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ You can specify a tenant in variable ```target_dn``` or not provide any to do a
aci.snapshot(description='test', target_dn='/uni/tn-test')
```

### Subscriptions
You can subscribe to an ACI object with websocket and get near-instant updates on-change.
To use the subscriptions you have to:
- Login to ACI
- Open websocket to ACI
- Subscribe to an ACI object via aciClient.subscribe
- Refresh subscription to an ACI object via aciClient.subscription_refresh
- Handle messages sent from ACI through websocket

You can find example code here: examples/subscription.py

## Testing

```
Expand Down
53 changes: 0 additions & 53 deletions aciClient/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,56 +252,3 @@ def snapshot(self, description="snapshot", target_dn="") -> bool:
else:
self.__logger.error(f'snapshot creation not succesfull: {response}')
return False

# ==============================================================================
# subscribe
# ==============================================================================
def subscribe(
self, subscription_dn: str, timeout: int = 60, query_parameters: list = []
) -> {}:
query_parameters.append("subscription=yes")
query_parameters.append(f"refresh-timeout={timeout}")

endpoint = f"{self.baseUrl}{str(subscription_dn)}?{'&'.join(query_parameters)}"
self.__logger.debug(f"Subscribe to: {endpoint}")

response = self.session.get(endpoint, verify=False)
if response.status_code == 200:
self.__logger.debug(f"Successful subscribed to APIC: {response.json()}")
return response.json()
elif response.status_code == 400:
resp_text = (
f"400: {response.json()['imdata'][0]['error']['attributes']['text']}"
)
self.__logger.error(f"Error 400 during get occured: {resp_text}")
return response.json()
else:
self.__logger.error(f"Error during get occured: {response.json()}")
response.raise_for_status()
return response.json()

# ==============================================================================
# subscription_refresh
# ==============================================================================
def subscription_refresh(self, subscription_id: str) -> {}:
query_parameters = [f"id={subscription_id}"]

endpoint = (
f"{self.baseUrl}/subscriptionRefresh.json?{'&'.join(query_parameters)}"
)
self.__logger.debug(f"Refresh subscription: {subscription_id}")

response = self.session.post(endpoint, verify=False)
if response.status_code == 200:
self.__logger.debug(f"Successful subscribed to APIC: {response.json()}")
return response.json()
elif response.status_code == 400:
resp_text = (
f"400: {response.json()['imdata'][0]['error']['attributes']['text']}"
)
self.__logger.error(f"Error 400 during get occured: {resp_text}")
return response.json()
else:
self.__logger.error(f"Error during get occured: {response.json()}")
response.raise_for_status()
return response.json()
68 changes: 0 additions & 68 deletions examples/subscription.py

This file was deleted.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
long_description = f.read()

setup(name='aciClient',
version='1.6',
version='1.5',
description='aci communication helper class',
url='http://www.netcloud.ch',
author='Netcloud AG',
author='mze',
author_email='nc_dev@netcloud.ch',
license='MIT',
packages=['aciClient'],
Expand Down