diff --git a/CHANGELOG.md b/CHANGELOG.md index 421c6e1a..0723783f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## v1.0.2 - 2022-09-22 + +### Fixed + +- #87 NestedWritabeSerializer fix for schema generation on VarBinaryField +- #88 Docs fix +- #89 Ressolve ordering when viewing PolicyRules via a Policy view. + ## v1.0.1 - 2022-09-18 ### Fixed diff --git a/docs/capirca.md b/docs/capirca.md index f1759c1a..4bc41996 100644 --- a/docs/capirca.md +++ b/docs/capirca.md @@ -49,7 +49,7 @@ The process is to create a custom field, such as `ctd_pan-application`, this wil capirca_allow = ['ctd_pan-application', 'ctd_expiration'] ``` -> Note: This is pseudo-code and is technically the custom_field called `capirca_allow` that has the dat `['ctd_pan-application', 'ctd_expiration']` in this example. +> Note: This is pseudo-code and is technically the custom_field called `capirca_allow` that has the data `["ctd_pan-application", "ctd_expiration"]` in this example. As previously mentioned, there is only a small opinion that is applied from the translation between the model and Capirca. That being said, Capirca has an opinion on how rules and objects are deployed, and within this project there is no consideration for how that may not align with anyone's intention on how Capirca should work. All such considerations should be referred to the Capirca project. There is no intention to modify the output that Capirca creates **in any situation** within this plugin. diff --git a/mkdocs.yml b/mkdocs.yml index 389cc4ea..b595c06a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -25,3 +25,4 @@ nav: - Examples: "example.md" - Development Environment: "development.md" - Models: "models.md" + - Capirca Usage: "capirca.md" diff --git a/nautobot_firewall_models/api/nested_serializers.py b/nautobot_firewall_models/api/nested_serializers.py index 45078897..4342668d 100644 --- a/nautobot_firewall_models/api/nested_serializers.py +++ b/nautobot_firewall_models/api/nested_serializers.py @@ -1,6 +1,6 @@ """Nested serializers.""" from nautobot.core.api import WritableNestedSerializer -from rest_framework.serializers import HyperlinkedIdentityField +from rest_framework.serializers import CharField, HyperlinkedIdentityField from nautobot_firewall_models import models @@ -21,6 +21,8 @@ class NestedIPRangeSerializer(WritableNestedSerializer): """Nested serializer for IPRange.""" url = HyperlinkedIdentityField(view_name="plugins-api:nautobot_firewall_models-api:fqdn-detail") + start_address = CharField() + end_address = CharField() class Meta: """Meta attributes.""" diff --git a/nautobot_firewall_models/api/serializers.py b/nautobot_firewall_models/api/serializers.py index e03efd5d..1e44c716 100644 --- a/nautobot_firewall_models/api/serializers.py +++ b/nautobot_firewall_models/api/serializers.py @@ -18,7 +18,7 @@ from nautobot_firewall_models import models -from nautobot_firewall_models.api import nested_serializers +from nautobot_firewall_models.api.nested_serializers import NestedFQDNSerializer, NestedIPRangeSerializer class StatusModelSerializerMixin(_StatusModelSerializerMixin): # pylint: disable=abstract-method @@ -66,8 +66,8 @@ class AddressObjectSerializer(TaggedObjectSerializer, StatusModelSerializerMixin url = serializers.HyperlinkedIdentityField( view_name="plugins-api:nautobot_firewall_models-api:addressobject-detail" ) - ip_range = nested_serializers.NestedIPRangeSerializer(required=False) - fqdn = nested_serializers.NestedFQDNSerializer(required=False) + ip_range = NestedIPRangeSerializer(required=False) + fqdn = NestedFQDNSerializer(required=False) ip_address = NestedIPAddressSerializer(required=False) prefix = NestedPrefixSerializer(required=False) diff --git a/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py b/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py new file mode 100644 index 00000000..a77252a6 --- /dev/null +++ b/nautobot_firewall_models/migrations/0009_proper_ordering_on_through.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.15 on 2022-09-22 13:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("nautobot_firewall_models", "0008_renaming_part3"), + ] + + operations = [ + migrations.AlterModelOptions( + name="policyrulem2m", + options={"ordering": ["rule__index"]}, + ), + ] diff --git a/nautobot_firewall_models/models/through_models.py b/nautobot_firewall_models/models/through_models.py index 2a7edb1a..9ccfb7de 100644 --- a/nautobot_firewall_models/models/through_models.py +++ b/nautobot_firewall_models/models/through_models.py @@ -66,6 +66,11 @@ class PolicyRuleM2M(BaseModel): policy = models.ForeignKey("nautobot_firewall_models.Policy", on_delete=models.CASCADE) rule = models.ForeignKey("nautobot_firewall_models.PolicyRule", on_delete=models.PROTECT) + class Meta: + """Meta class.""" + + ordering = ["rule__index"] + class ServiceObjectGroupM2M(BaseModel): """Custom through model to on_delete=models.PROTECT to prevent deleting associated ServiceGroup if assigned to a PolicyRule.""" diff --git a/pyproject.toml b/pyproject.toml index 6a18095a..0208f73d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-firewall-models" -version = "1.0.1" +version = "1.0.2" description = "Nautobot plugin to model firewall objects." authors = ["Network to Code, LLC "] license = "Apache-2.0"