Commit 1926aa2a authored by Dominik Rimpf's avatar Dominik Rimpf
Browse files

DOC: Upd readme

parent e48924d2
Pipeline #112570 passed with stage
in 22 seconds
......@@ -5,3 +5,52 @@
### Self-Built
`env NETDB_AUTH=<your API token> pip install git+https://git.scc.kit.edu/scc-net/net-suite/netdb-client-lib.git@master`
## Usage
### Init
```python
>>> import netdb_client
>>> import netdb_client.util
>>> token = <your token>
>>> api = netdb_client.APISession(base_url=netdb_client.util.default_server, version=netdb_client.util.default_api_version, token=token)
```
Helper function for argument parsing in scripts (implemented with `argparse`):
```python
>>> import netdb_client.util
>>> parser = netdb_client.util.ArgumentParser(description='Beispielbeschreibung für Skript.')
>>> args = parser.parse_args()
```
## Examples
More examples can be found in the [wiki aricle](https://git.scc.kit.edu/scc-net/net-suite/netdb-client-lib/-/wikis/examples)
### Basic queries
List all BCDs:
```python
>>> import netdb_client.nd
>>> netdb_client.nd.Bcd.list(api_session=api)
[Bcd(name='scc-net-web-1', categ='USER', is_own=True, log_pk=13270200, seclvl=0, vlan_count=1, description='[scc-net-web/1]: Webserver von SCC-NET / [ipv6-scc-net-web/1]: Webserver von SCC-NET *** ehemalige Bereichsinfo ***: [scc-net-web/1]: Webserver von SCC-NET / [ipv6-scc-net-web/1]: Webserver von SCC-NET', dhcp_enabled=False, subnet_count=2, ou_short_name='SCC-NET', dhcp_ttl_value=600, admin_description=None, dhcp_accept_new_leases=False, dhcp_leasetime_dyn_days=0, dhcp_leasetime_dyn_hours=2, dhcp_leasetime_dyn_minutes=0, dhcp_leasetime_static_days=0, dhcp_leasetime_static_hours=6, dhcp_offer_rsv_time_minutes=0, dhcp_offer_rsv_time_seconds=30, dhcp_leasetime_static_minutes=0, dhcp_accept_requested_hostname=True)]
```
List all CNAME-Records for given BCD:
```python
>>> import netdb_client.dns
>>> netdb_client.dns.Record.list(api_session=api, type_old="CNAME", bcd_list_old=["scc-net-web-1"])
[..., Record(ttl=None, data='net-web09.scc.kit.edu.', fqdn='netvs-devel.scc.kit.edu.', type='CNAME', zone='kit.edu.', is_own=True, fqdn_type='alias', host_is_nws=False, target_fqdn='net-web09.scc.kit.edu.', target_ipaddr=None, ttl_reset_date=None, fqdn_description=None, target_fqdn_type='host', ttl_zone_default=3600, target_data_unref=None, target_is_singleton=True, target_is_reverse_unique=False), ...]
```
### Advanced queries
List BCDs with their Subnets:
```python
>>> netdb_client.nd
>>> api.execute_ta([
netdb_client.nd.Bcd.list_ta(), # == {"name": "nd.bcd.list"}
{"name": "nd.ip_subnet.list", "join": {0: "api_fkey_nd_ip_subnet_bcd"}},
])
[[{'name': 'scc-net-web-1', ...}], [{'bcd': 'scc-net-web-1', ...}, ...]]
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment