Metadata-Version: 2.4
Name: aciClient
Version: 1.8
Summary: ACI communication helper class
Author-email: Netcloud AG <nc_dev@netcloud.ch>
License: MIT
Project-URL: Homepage, https://github.com/netcloud/aciClient
Project-URL: Repository, https://github.com/netcloud/aciClient
Project-URL: Issues, https://github.com/netcloud/aciClient/issues
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: pyOpenSSL<27,>=26.0.0
Requires-Dist: requests[socks]<3,>=2.33.1
Dynamic: license-file

# aciClient

![PyPi](https://img.shields.io/pypi/v/aciClient)

A python wrapper to the Cisco ACI REST-API.

## Python Version

We support Python 3.10 and up.

## Installation
With `pip`:

```bash
pip install aciClient
```

With `uv`:

```bash
uv add aciClient
```

## Installation for Developing
```bash
git clone https://github.com/netcloud/aciClient.git
uv sync --group dev
```

## Usage

### Initialisation

### Username/password
```python
import aciClient
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

proxies = {
    'http': 'socks5://127.0.0.1:1080',
    'https': 'socks5://127.0.0.1:1080'
}

aciclient = aciClient.ACI(apic_hostname, apic_username, apic_password, refresh=False, proxies=proxies)
try:
    aciclient.login()
    
    aciclient.getJson(uri)
    aciclient.postJson(config)
    aciclient.deleteMo(dn)
    
    aciclient.logout()
except Exception as e:
    logger.exception("Stack Trace")
```

For automatic authentication token refresh you can set variable ```refresh``` to True

```python
aciclient = aciClient.ACI(apic_hostname, apic_username, apic_password, refresh=True)    
```


### Certificate/signature
```python
import aciClient
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

aciclient = aciClient.ACICert(apic_hostname, path_to_privatekey_file, certificate_dn)

try:
    aciclient.getJson(uri)
    aciclient.postJson(config)
    aciclient.deleteMo(dn)
except Exception as e:
    logger.exception("Stack Trace")
```

## Examples

### get config
```python
tenants = aciclient.getJson('class/fvTenant.json?order-by=fvTenant.dn|asc')

for mo in tenants:
    print(f'tenant DN: {mo["fvTenant"]["attributes"]["dn"]}')
```

### post config
```python
config = {
 "fvTenant": {
  "attributes": {
   "dn": "uni/tn-XYZ"
  }
 }
}

aciclient.postJson(config)
```

### delete MOs
```python
aciclient.deleteMo('uni/tn-XYZ')
```

### create snapshot
You can specify a tenant in variable ```target_dn``` or not provide any to do a fabric-wide snapshot.
```python
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

## Contributing

Please read [CONTRIBUTING.md](https://github.com/netcloud/aciClient/blob/master/CONTRIBUTING.md) for details on our code 
of conduct, and the process for submitting pull requests to this project.

## Authors

* **Marcel Zehnder** - *Initial work*
* **Andreas Graber** - *Migration to open source*
* **Richard Strnad** - *Paginagtion for large requests, various small stuff*
* **Dario Kaelin** - *Added snapshot creation*

## License

This project is licensed under MIT - see the [LICENSE.md](https://github.com/netcloud/aciClient/blob/master/LICENSE.md) file for details. 
