Skip to content
Merged
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
12 changes: 12 additions & 0 deletions docs/_templates/sdk_template_reference.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ The following Jinja2 filters from <a href="https://netutils.readthedocs.io">Netu
| {{ filter.name }} | {% if filter.trusted %}✅{% else %}❌{% endif %} |
{% endfor %}
<!-- vale on -->

## Known issues

### Unable to combine the map and sort filters (https://github.com/pallets/jinja/issues/2081)

When using the `map` filter with the `sort` filter, you may encounter the following error:

```python
TypeError: 'async_generator' object is not iterable
```

**As a workaround you can use the `list` filter between `map` and `sort` filter.**
12 changes: 6 additions & 6 deletions docs/docs/python-sdk/guides/create_update_delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ nodes:

A node can be created using the `create` method. The `create` method will first construct a `InfrahubNode` object in memory. This `InfrahubNode` object will then need to be saved into Infrahub using the `save` method.

The attributes and relationships of the `InfrahubNode` you want to create can be passed as arguments to the `create` method, or you can pass then using a dictionary.
The attributes and relationships of the `InfrahubNode` you want to create can be passed as arguments to the `create` method, or you can pass them using a dictionary.

<Tabs groupId="async-sync">
<TabItem value="Async" default>
Expand Down Expand Up @@ -138,7 +138,7 @@ The attributes and relationships of the `InfrahubNode` you want to create can be
<TabItem value="Async" default>

```python
interfaces = await client.get(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
interfaces = await client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
device = await client.create(kind="TestDevice", name="atl1-edge1", interfaces=interfaces)
await device.save()
```
Expand All @@ -147,7 +147,7 @@ The attributes and relationships of the `InfrahubNode` you want to create can be
<TabItem value="Sync" default>

```python
interfaces = client.get(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
interfaces = client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
device = client.create(kind="TestDevice", name="atl1-edge1", interfaces=interfaces)
device.save()
```
Expand Down Expand Up @@ -222,7 +222,7 @@ Adding a single relation:
<TabItem value="Sync" default>

```python
interface = client.get(kind="TestInterface", name__values="Ethernet1")
interface = client.get(kind="TestInterface", name__value="Ethernet1")
device = client.get(kind="TestDevice", name__value="atl1-edge1")
device.interfaces.add(interface)
device.save()
Expand All @@ -236,7 +236,7 @@ Adding multiple relations:
<TabItem value="Async" default>

```python
interfaces = await client.filters(kind="TestInterface", name__value=["Ethernet1", "Ethernet2"])
interfaces = await client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
device = await client.get(kind="TestDevice", name__value="atl1-edge1")
device.interfaces.extend(interfaces)
await device.save()
Expand All @@ -246,7 +246,7 @@ Adding multiple relations:
<TabItem value="Sync" default>

```python
interfaces = client.filters(kind="TestInterface", name__value=["Ethernet1", "Ethernet2"])
interfaces = client.filters(kind="TestInterface", name__values=["Ethernet1", "Ethernet2"])
device = client.get(kind="TestDevice", name__value="atl1-edge1")
device.interfaces.extend(interfaces)
device.save()
Expand Down
14 changes: 13 additions & 1 deletion docs/docs/python-sdk/reference/templating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,16 @@ The following Jinja2 filters from <a href="https://netutils.readthedocs.io">Netu
| vlanconfig_to_list | ✅ |
| vlanlist_to_config | ✅ |
| wildcardmask_to_netmask | ✅ |
<!-- vale on -->
<!-- vale on -->

## Known issues

### Unable to combine the map and sort filters (https://github.com/pallets/jinja/issues/2081)

When using the `map` filter with the `sort` filter, you may encounter the following error:

```python
TypeError: 'async_generator' object is not iterable
```

**As a workaround you can use the `list` filter between `map` and `sort` filter.**