Skip to content

Models

Resource models returned by the managers. These are pydantic models — you read fields off them and pass identifiers or model objects back into manager methods.

models

Pydantic models for API resources.

Delegation module-attribute

A DNS delegation: always a concrete forward or reverse zone delegation.

Zone module-attribute

A DNS zone: always a concrete forward or reverse zone.

Atom pydantic-model

Bases: HostPolicy

Model for an atom.

Show JSON schema:
{
  "description": "Model for an atom.",
  "properties": {
    "create_date": {
      "format": "date-time",
      "title": "Create Date",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "roles": {
      "items": {
        "type": "string"
      },
      "title": "Roles",
      "type": "array"
    }
  },
  "required": [
    "create_date",
    "updated_at",
    "name",
    "description",
    "id",
    "roles"
  ],
  "title": "Atom",
  "type": "object"
}

Fields:

Validators:

created_at property

created_at: datetime

Creation time.

created_at_tz_naive pydantic-field

created_at_tz_naive: datetime

Constructed datetime field from create_date in the API.

WARNING

DO NOT USE THIS FIELD FOR TIMEZONE-AWARE COMPARISONS! Always use created_at instead when comparing with timezone-aware fields such as update_time.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

validate_created_at pydantic-validator

validate_created_at(value: Any) -> datetime

Convert a datetime string to a datetime object.

Parameters:

Name Type Description Default
value Any

The input value - should be a datetime string.

required

Returns:

Type Description
datetime

The input value converted to a datetime object.

BacnetID pydantic-model

Bases: MregModel

Represents a Bacnet ID record.

Show JSON schema:
{
  "description": "Represents a Bacnet ID record.",
  "properties": {
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "hostname": {
      "title": "Hostname",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "id",
    "hostname",
    "host"
  ],
  "title": "BacnetID",
  "type": "object"
}

Fields:

MAX_ID classmethod

MAX_ID() -> int

Return the maximum ID for a Bacnet ID.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

CNAME pydantic-model

Bases: MregModelWithTimestamps

Represents a CNAME record.

Show JSON schema:
{
  "description": "Represents a CNAME record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    },
    "ttl": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ttl"
    },
    "zone": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "host"
  ],
  "title": "CNAME",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

Community pydantic-model

Bases: MregModelWithTimestamps

Network community.

Show JSON schema:
{
  "description": "Network community.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "network": {
      "title": "Network",
      "type": "integer"
    },
    "hosts": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Hosts",
      "type": "array"
    },
    "global_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Global Name"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "description",
    "network"
  ],
  "title": "Community",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

ContactEmail pydantic-model

Bases: MregModelWithTimestamps

Model for a host's contact email.

Show JSON schema:
{
  "description": "Model for a host's contact email.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "email": {
      "title": "Email",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "email"
  ],
  "title": "ContactEmail",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

DhcpHost pydantic-model

Bases: MregModel, ABC

Base model for all DHCP hosts.

Show JSON schema:
{
  "description": "Base model for all DHCP hosts.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "macaddress": {
      "title": "Macaddress",
      "type": "string"
    },
    "zone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "name",
    "ipaddress",
    "macaddress"
  ],
  "title": "DhcpHost",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

DhcpHostIPv4 pydantic-model

Bases: DhcpHost

Model for a DHCP host with an IPv4 address.

Show JSON schema:
{
  "description": "Model for a DHCP host with an IPv4 address.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "macaddress": {
      "title": "Macaddress",
      "type": "string"
    },
    "zone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "name",
    "ipaddress",
    "macaddress"
  ],
  "title": "DhcpHostIPv4",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

DhcpHostIPv6 pydantic-model

Bases: DhcpHost

Model for a DHCP host with an IPv6 address.

Show JSON schema:
{
  "description": "Model for a DHCP host with an IPv6 address.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "macaddress": {
      "title": "Macaddress",
      "type": "string"
    },
    "zone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "name",
    "ipaddress",
    "macaddress"
  ],
  "title": "DhcpHostIPv6",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

DhcpHostIPv6ByIPv4 pydantic-model

Bases: DhcpHost

Model for a DHCP hosts with an IPv6 address via IPv4 address.

Show JSON schema:
{
  "description": "Model for a DHCP hosts with an IPv6 address via IPv4 address.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "macaddress": {
      "title": "Macaddress",
      "type": "string"
    },
    "zone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "name",
    "ipaddress",
    "macaddress"
  ],
  "title": "DhcpHostIPv6ByIPv4",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

ExcludedRange pydantic-model

Bases: MregModelWithTimestamps

Model for an excluded IP range for a network.

Show JSON schema:
{
  "description": "Model for an excluded IP range for a network.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "network": {
      "title": "Network",
      "type": "integer"
    },
    "start_ip": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Start Ip"
    },
    "end_ip": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "End Ip"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "network",
    "start_ip",
    "end_ip"
  ],
  "title": "ExcludedRange",
  "type": "object"
}

Fields:

  • created_at (datetime)
  • updated_at (datetime)
  • id (int)
  • network (int)
  • start_ip (IP_AddressT)
  • end_ip (IP_AddressT)

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

excluded_ips

excluded_ips() -> int

Return the number of IP addresses in the excluded range.

ForwardZone pydantic-model

Bases: _Zone

A forward zone.

Show JSON schema:
{
  "$defs": {
    "NameServer": {
      "description": "Model for representing a nameserver within a DNS zone.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "ttl"
      ],
      "title": "NameServer",
      "type": "object"
    }
  },
  "description": "A forward zone.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "nameservers": {
      "items": {
        "$ref": "#/$defs/NameServer"
      },
      "title": "Nameservers",
      "type": "array"
    },
    "updated": {
      "title": "Updated",
      "type": "boolean"
    },
    "primary_ns": {
      "title": "Primary Ns",
      "type": "string"
    },
    "email": {
      "title": "Email",
      "type": "string"
    },
    "serialno": {
      "title": "Serialno",
      "type": "integer"
    },
    "serialno_updated_at": {
      "format": "date-time",
      "title": "Serialno Updated At",
      "type": "string"
    },
    "refresh": {
      "title": "Refresh",
      "type": "integer"
    },
    "retry": {
      "title": "Retry",
      "type": "integer"
    },
    "expire": {
      "title": "Expire",
      "type": "integer"
    },
    "soa_ttl": {
      "title": "Soa Ttl",
      "type": "integer"
    },
    "default_ttl": {
      "title": "Default Ttl",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "nameservers",
    "updated",
    "primary_ns",
    "email",
    "serialno",
    "serialno_updated_at",
    "refresh",
    "retry",
    "expire",
    "soa_ttl",
    "default_ttl",
    "name"
  ],
  "title": "ForwardZone",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

ensure_delegation_in_zone

ensure_delegation_in_zone(name: str) -> None

Ensure a delegation is in the zone.

Parameters:

Name Type Description Default
name str

The name of the delegation to check.

required

Returns:

Type Description
None

True if the delegation is in the zone.

is_delegated

is_delegated() -> bool

Return True if the zone is delegated.

is_reverse

is_reverse() -> bool

Return True if the zone is a reverse zone.

ForwardZoneDelegation pydantic-model

Bases: _Delegation

A forward zone delegation.

Show JSON schema:
{
  "$defs": {
    "NameServer": {
      "description": "Model for representing a nameserver within a DNS zone.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "ttl"
      ],
      "title": "NameServer",
      "type": "object"
    }
  },
  "description": "A forward zone delegation.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "nameservers": {
      "items": {
        "$ref": "#/$defs/NameServer"
      },
      "title": "Nameservers",
      "type": "array"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "comment": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Comment"
    },
    "zone": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "nameservers",
    "name"
  ],
  "title": "ForwardZoneDelegation",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

is_delegated

is_delegated() -> bool

Return True if the zone is delegated.

is_reverse classmethod

is_reverse() -> bool

Return True if the delegation is for a reverse zone.

HInfo pydantic-model

Bases: MregModelWithTimestamps

Represents a HINFO record.

Show JSON schema:
{
  "description": "Represents a HINFO record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "cpu": {
      "title": "Cpu",
      "type": "string"
    },
    "os": {
      "title": "Os",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "cpu",
    "os",
    "host"
  ],
  "title": "HInfo",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

HealthInfo pydantic-model

Bases: BaseModel

Combined information from all health endpoints.

Show JSON schema:
{
  "$defs": {
    "HeartbeatHealth": {
      "description": "Model for heartbeat health endpoint.",
      "properties": {
        "uptime": {
          "title": "Uptime",
          "type": "integer"
        },
        "start_time": {
          "title": "Start Time",
          "type": "integer"
        }
      },
      "required": [
        "uptime",
        "start_time"
      ],
      "title": "HeartbeatHealth",
      "type": "object"
    },
    "LDAPHealth": {
      "description": "Model for LDAP health endpoint.",
      "properties": {
        "status": {
          "enum": [
            "OK",
            "Down",
            "Unknown"
          ],
          "title": "Status",
          "type": "string"
        }
      },
      "required": [
        "status"
      ],
      "title": "LDAPHealth",
      "type": "object"
    }
  },
  "description": "Combined information from all health endpoints.",
  "properties": {
    "heartbeat": {
      "$ref": "#/$defs/HeartbeatHealth"
    },
    "ldap": {
      "$ref": "#/$defs/LDAPHealth"
    }
  },
  "required": [
    "heartbeat",
    "ldap"
  ],
  "title": "HealthInfo",
  "type": "object"
}

Fields:

HeartbeatHealth pydantic-model

Bases: BaseModel

Model for heartbeat health endpoint.

Show JSON schema:
{
  "description": "Model for heartbeat health endpoint.",
  "properties": {
    "uptime": {
      "title": "Uptime",
      "type": "integer"
    },
    "start_time": {
      "title": "Start Time",
      "type": "integer"
    }
  },
  "required": [
    "uptime",
    "start_time"
  ],
  "title": "HeartbeatHealth",
  "type": "object"
}

Fields:

  • uptime (int)
  • start_time (int)

as_str

as_str() -> str

Return the uptime as a string.

Host pydantic-model

Bases: MregModelWithTimestamps

Model for an individual host.

Show JSON schema:
{
  "$defs": {
    "CNAME": {
      "description": "Represents a CNAME record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        },
        "zone": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Zone"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "host"
      ],
      "title": "CNAME",
      "type": "object"
    },
    "Community": {
      "description": "Network community.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "network": {
          "title": "Network",
          "type": "integer"
        },
        "hosts": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Hosts",
          "type": "array"
        },
        "global_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Global Name"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "description",
        "network"
      ],
      "title": "Community",
      "type": "object"
    },
    "ContactEmail": {
      "description": "Model for a host's contact email.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "email": {
          "title": "Email",
          "type": "string"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "email"
      ],
      "title": "ContactEmail",
      "type": "object"
    },
    "HInfo": {
      "description": "Represents a HINFO record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "cpu": {
          "title": "Cpu",
          "type": "string"
        },
        "os": {
          "title": "Os",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "cpu",
        "os",
        "host"
      ],
      "title": "HInfo",
      "type": "object"
    },
    "HostCommunity": {
      "description": "Model for a host's community.\n\nCommunities are associated with hosts via IP addresses.",
      "properties": {
        "ipaddress": {
          "title": "Ipaddress",
          "type": "integer"
        },
        "community": {
          "$ref": "#/$defs/Community"
        }
      },
      "required": [
        "ipaddress",
        "community"
      ],
      "title": "HostCommunity",
      "type": "object"
    },
    "IPAddress": {
      "description": "Represents an IP address with associated details.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "macaddress": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Macaddress"
        },
        "ipaddress": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "Ipaddress"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "ipaddress",
        "host"
      ],
      "title": "IPAddress",
      "type": "object"
    },
    "Location": {
      "description": "Represents a LOC record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "loc": {
          "title": "Loc",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "loc",
        "host"
      ],
      "title": "Location",
      "type": "object"
    },
    "MX": {
      "description": "Represents a MX record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "mx": {
          "title": "Mx",
          "type": "string"
        },
        "priority": {
          "title": "Priority",
          "type": "integer"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "mx",
        "priority",
        "host"
      ],
      "title": "MX",
      "type": "object"
    },
    "NAPTR": {
      "description": "Represents a NAPTR record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "preference": {
          "title": "Preference",
          "type": "integer"
        },
        "order": {
          "title": "Order",
          "type": "integer"
        },
        "flag": {
          "default": "",
          "title": "Flag",
          "type": "string"
        },
        "service": {
          "default": "",
          "title": "Service",
          "type": "string"
        },
        "regex": {
          "default": "",
          "title": "Regex",
          "type": "string"
        },
        "replacement": {
          "title": "Replacement",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "preference",
        "order",
        "replacement",
        "host"
      ],
      "title": "NAPTR",
      "type": "object"
    },
    "PTR_override": {
      "description": "Represents a PTR override record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "ipaddress": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "Ipaddress"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "ipaddress",
        "host"
      ],
      "title": "PTR_override",
      "type": "object"
    },
    "SSHFP": {
      "description": "Represents a SSHFP record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "algorithm": {
          "title": "Algorithm",
          "type": "integer"
        },
        "hash_type": {
          "title": "Hash Type",
          "type": "integer"
        },
        "fingerprint": {
          "title": "Fingerprint",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "algorithm",
        "hash_type",
        "fingerprint",
        "host"
      ],
      "title": "SSHFP",
      "type": "object"
    },
    "Srv": {
      "description": "Represents a SRV record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "priority": {
          "title": "Priority",
          "type": "integer"
        },
        "weight": {
          "title": "Weight",
          "type": "integer"
        },
        "port": {
          "title": "Port",
          "type": "integer"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        },
        "zone": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Zone"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "priority",
        "weight",
        "port",
        "host"
      ],
      "title": "Srv",
      "type": "object"
    },
    "TXT": {
      "description": "Represents a TXT record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "txt": {
          "title": "Txt",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "txt",
        "host"
      ],
      "title": "TXT",
      "type": "object"
    }
  },
  "description": "Model for an individual host.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ipaddresses": {
      "items": {
        "$ref": "#/$defs/IPAddress"
      },
      "title": "Ipaddresses",
      "type": "array"
    },
    "cnames": {
      "default": [],
      "items": {
        "$ref": "#/$defs/CNAME"
      },
      "title": "Cnames",
      "type": "array"
    },
    "mxs": {
      "default": [],
      "items": {
        "$ref": "#/$defs/MX"
      },
      "title": "Mxs",
      "type": "array"
    },
    "txts": {
      "default": [],
      "items": {
        "$ref": "#/$defs/TXT"
      },
      "title": "Txts",
      "type": "array"
    },
    "ptr_overrides": {
      "default": [],
      "items": {
        "$ref": "#/$defs/PTR_override"
      },
      "title": "Ptr Overrides",
      "type": "array"
    },
    "hinfo": {
      "anyOf": [
        {
          "$ref": "#/$defs/HInfo"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "loc": {
      "anyOf": [
        {
          "$ref": "#/$defs/Location"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "bacnetid": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Bacnetid"
    },
    "ttl": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ttl"
    },
    "srvs": {
      "default": [],
      "items": {
        "$ref": "#/$defs/Srv"
      },
      "title": "Srvs",
      "type": "array"
    },
    "naptrs": {
      "default": [],
      "items": {
        "$ref": "#/$defs/NAPTR"
      },
      "title": "Naptrs",
      "type": "array"
    },
    "sshfps": {
      "default": [],
      "items": {
        "$ref": "#/$defs/SSHFP"
      },
      "title": "Sshfps",
      "type": "array"
    },
    "roles": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Roles",
      "type": "array"
    },
    "hostgroups": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Hostgroups",
      "type": "array"
    },
    "comment": {
      "title": "Comment",
      "type": "string"
    },
    "contacts": {
      "default": [],
      "items": {
        "$ref": "#/$defs/ContactEmail"
      },
      "title": "Contacts",
      "type": "array"
    },
    "contact": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "deprecated": true,
      "title": "Contact"
    },
    "zone": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    },
    "communities": {
      "default": [],
      "items": {
        "$ref": "#/$defs/HostCommunity"
      },
      "title": "Communities",
      "type": "array"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "ipaddresses",
    "comment"
  ],
  "title": "Host",
  "type": "object"
}

Fields:

Validators:

  • _set_deprecated_contact_field
  • _validate_none_communities_as_empty_listcommunities
  • convert_bacnetidbacnetid

contact_emails property

contact_emails: list[str]

A list of contact email addresses for the host.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__hash__

__hash__() -> int

Hash by ID and name.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

__str__

__str__() -> str

Return the host name.

convert_bacnetid pydantic-validator

convert_bacnetid(v: Any) -> Any

Use nested ID value in bacnetid value.

get_community

get_community(
    name: str, ip: IPAddress | None = None
) -> Community | None

Get a community by name, optionally filtered by IP address.

Parameters:

Name Type Description Default
name str

The name of the community to search for.

required
ip IPAddress | None

If given, only match communities associated with this IP.

None

Returns:

Type Description
Community | None

The community if found, None otherwise.

get_community_associations

get_community_associations(
    name: str,
) -> list[tuple[Community, IPAddress]]

Get all IPAddress->Community associations for a given community name.

Parameters:

Name Type Description Default
name str

The name of the community to search for.

required

Returns:

Type Description
list[tuple[Community, IPAddress]]

A list of tuples of (Community, IPAddress) for all associations with the given name

get_ip

get_ip(arg_ip: IP_AddressT) -> IPAddress | None

Get the IP address object for the given IP address.

Parameters:

Name Type Description Default
arg_ip IP_AddressT

IP address to search for

required

Returns:

Type Description
IPAddress | None

IPAddress | None: IP address object if found, None otherwise

get_ip_by_id

get_ip_by_id(ip_id: int) -> IPAddress | None

Get the IP address object for the given ID.

get_ip_by_mac

get_ip_by_mac(arg_mac: MacAddress) -> IPAddress | None

Return the IPAddress with the given MAC, or None if not found.

get_ptr_override

get_ptr_override(ip: IP_AddressT) -> PTR_override | None

Get the PTR override for the given IP address.

has_ip

has_ip(arg_ip: IP_AddressT) -> bool

Return True if the host has the given IP address.

has_ip_with_mac

has_ip_with_mac(arg_mac: MacAddress) -> IPAddress | None

Return the IPAddress with the given MAC, or None if not found.

has_mx_with_priority

has_mx_with_priority(
    mx_arg: str, priority: int
) -> MX | None

Return the MX record matching mx and priority, or None.

has_ptr_override

has_ptr_override(arg_ip: IP_AddressT) -> bool

Return True if the host has a PTR override for the given IP.

has_txt

has_txt(arg_txt: str) -> bool

Return True if the host has the given TXT record.

ips_with_macaddresses

ips_with_macaddresses() -> list[IPAddress]

Return all IP addresses that have a MAC address set.

ipv4_addresses

ipv4_addresses() -> list[IPAddress]

Return all IPv4 addresses.

ipv6_addresses

ipv6_addresses() -> list[IPAddress]

Return all IPv6 addresses.

HostCommunity pydantic-model

Bases: MregModel

Model for a host's community.

Communities are associated with hosts via IP addresses.

Show JSON schema:
{
  "$defs": {
    "Community": {
      "description": "Network community.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "network": {
          "title": "Network",
          "type": "integer"
        },
        "hosts": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Hosts",
          "type": "array"
        },
        "global_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Global Name"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "description",
        "network"
      ],
      "title": "Community",
      "type": "object"
    }
  },
  "description": "Model for a host's community.\n\nCommunities are associated with hosts via IP addresses.",
  "properties": {
    "ipaddress": {
      "title": "Ipaddress",
      "type": "integer"
    },
    "community": {
      "$ref": "#/$defs/Community"
    }
  },
  "required": [
    "ipaddress",
    "community"
  ],
  "title": "HostCommunity",
  "type": "object"
}

Fields:

ipaddress pydantic-field

ipaddress: int

ID of the IP address associated with the community

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

HostContactModification pydantic-model

Bases: MregModel

Model for host contact email modifications.

Show JSON schema:
{
  "description": "Model for host contact email modifications.",
  "properties": {
    "added": {
      "items": {
        "type": "string"
      },
      "title": "Added",
      "type": "array"
    },
    "already_exists": {
      "items": {
        "type": "string"
      },
      "title": "Already Exists",
      "type": "array"
    },
    "removed": {
      "items": {
        "type": "string"
      },
      "title": "Removed",
      "type": "array"
    },
    "not_found": {
      "items": {
        "type": "string"
      },
      "title": "Not Found",
      "type": "array"
    }
  },
  "title": "HostContactModification",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

HostGroup pydantic-model

Bases: MregModelWithTimestamps

Model for a hostgroup.

Show JSON schema:
{
  "description": "Model for a hostgroup.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Description"
    },
    "parent": {
      "items": {
        "type": "string"
      },
      "title": "Parent",
      "type": "array"
    },
    "groups": {
      "items": {
        "type": "string"
      },
      "title": "Groups",
      "type": "array"
    },
    "hosts": {
      "items": {
        "type": "string"
      },
      "title": "Hosts",
      "type": "array"
    },
    "owners": {
      "items": {
        "type": "string"
      },
      "title": "Owners",
      "type": "array"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "parent",
    "groups",
    "hosts",
    "owners"
  ],
  "title": "HostGroup",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

has_group

has_group(groupname: str) -> bool

Check if the hostgroup has the given group.

Parameters:

Name Type Description Default
groupname str

The group to check for.

required

Returns:

Type Description
bool

True if the hostgroup has the group, False otherwise.

has_host

has_host(hostname: str) -> bool

Check if the hostgroup has the given host.

Parameters:

Name Type Description Default
hostname str

The host to check for.

required

Returns:

Type Description
bool

True if the hostgroup has the host, False otherwise.

has_owner

has_owner(ownername: str) -> bool

Check if the hostgroup has the given owner.

Parameters:

Name Type Description Default
ownername str

The owner to check for.

required

Returns:

Type Description
bool

True if the hostgroup has the owner, False otherwise.

HostList pydantic-model

Bases: MregModel

Model for a list of hosts.

Show JSON schema:
{
  "$defs": {
    "CNAME": {
      "description": "Represents a CNAME record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        },
        "zone": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Zone"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "host"
      ],
      "title": "CNAME",
      "type": "object"
    },
    "Community": {
      "description": "Network community.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "network": {
          "title": "Network",
          "type": "integer"
        },
        "hosts": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Hosts",
          "type": "array"
        },
        "global_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Global Name"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "description",
        "network"
      ],
      "title": "Community",
      "type": "object"
    },
    "ContactEmail": {
      "description": "Model for a host's contact email.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "email": {
          "title": "Email",
          "type": "string"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "email"
      ],
      "title": "ContactEmail",
      "type": "object"
    },
    "HInfo": {
      "description": "Represents a HINFO record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "cpu": {
          "title": "Cpu",
          "type": "string"
        },
        "os": {
          "title": "Os",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "cpu",
        "os",
        "host"
      ],
      "title": "HInfo",
      "type": "object"
    },
    "Host": {
      "description": "Model for an individual host.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "ipaddresses": {
          "items": {
            "$ref": "#/$defs/IPAddress"
          },
          "title": "Ipaddresses",
          "type": "array"
        },
        "cnames": {
          "default": [],
          "items": {
            "$ref": "#/$defs/CNAME"
          },
          "title": "Cnames",
          "type": "array"
        },
        "mxs": {
          "default": [],
          "items": {
            "$ref": "#/$defs/MX"
          },
          "title": "Mxs",
          "type": "array"
        },
        "txts": {
          "default": [],
          "items": {
            "$ref": "#/$defs/TXT"
          },
          "title": "Txts",
          "type": "array"
        },
        "ptr_overrides": {
          "default": [],
          "items": {
            "$ref": "#/$defs/PTR_override"
          },
          "title": "Ptr Overrides",
          "type": "array"
        },
        "hinfo": {
          "anyOf": [
            {
              "$ref": "#/$defs/HInfo"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "loc": {
          "anyOf": [
            {
              "$ref": "#/$defs/Location"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "bacnetid": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Bacnetid"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        },
        "srvs": {
          "default": [],
          "items": {
            "$ref": "#/$defs/Srv"
          },
          "title": "Srvs",
          "type": "array"
        },
        "naptrs": {
          "default": [],
          "items": {
            "$ref": "#/$defs/NAPTR"
          },
          "title": "Naptrs",
          "type": "array"
        },
        "sshfps": {
          "default": [],
          "items": {
            "$ref": "#/$defs/SSHFP"
          },
          "title": "Sshfps",
          "type": "array"
        },
        "roles": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Roles",
          "type": "array"
        },
        "hostgroups": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Hostgroups",
          "type": "array"
        },
        "comment": {
          "title": "Comment",
          "type": "string"
        },
        "contacts": {
          "default": [],
          "items": {
            "$ref": "#/$defs/ContactEmail"
          },
          "title": "Contacts",
          "type": "array"
        },
        "contact": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "deprecated": true,
          "title": "Contact"
        },
        "zone": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Zone"
        },
        "communities": {
          "default": [],
          "items": {
            "$ref": "#/$defs/HostCommunity"
          },
          "title": "Communities",
          "type": "array"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "ipaddresses",
        "comment"
      ],
      "title": "Host",
      "type": "object"
    },
    "HostCommunity": {
      "description": "Model for a host's community.\n\nCommunities are associated with hosts via IP addresses.",
      "properties": {
        "ipaddress": {
          "title": "Ipaddress",
          "type": "integer"
        },
        "community": {
          "$ref": "#/$defs/Community"
        }
      },
      "required": [
        "ipaddress",
        "community"
      ],
      "title": "HostCommunity",
      "type": "object"
    },
    "IPAddress": {
      "description": "Represents an IP address with associated details.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "macaddress": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Macaddress"
        },
        "ipaddress": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "Ipaddress"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "ipaddress",
        "host"
      ],
      "title": "IPAddress",
      "type": "object"
    },
    "Location": {
      "description": "Represents a LOC record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "loc": {
          "title": "Loc",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "loc",
        "host"
      ],
      "title": "Location",
      "type": "object"
    },
    "MX": {
      "description": "Represents a MX record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "mx": {
          "title": "Mx",
          "type": "string"
        },
        "priority": {
          "title": "Priority",
          "type": "integer"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "mx",
        "priority",
        "host"
      ],
      "title": "MX",
      "type": "object"
    },
    "NAPTR": {
      "description": "Represents a NAPTR record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "preference": {
          "title": "Preference",
          "type": "integer"
        },
        "order": {
          "title": "Order",
          "type": "integer"
        },
        "flag": {
          "default": "",
          "title": "Flag",
          "type": "string"
        },
        "service": {
          "default": "",
          "title": "Service",
          "type": "string"
        },
        "regex": {
          "default": "",
          "title": "Regex",
          "type": "string"
        },
        "replacement": {
          "title": "Replacement",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "preference",
        "order",
        "replacement",
        "host"
      ],
      "title": "NAPTR",
      "type": "object"
    },
    "PTR_override": {
      "description": "Represents a PTR override record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "ipaddress": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "Ipaddress"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "ipaddress",
        "host"
      ],
      "title": "PTR_override",
      "type": "object"
    },
    "SSHFP": {
      "description": "Represents a SSHFP record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "algorithm": {
          "title": "Algorithm",
          "type": "integer"
        },
        "hash_type": {
          "title": "Hash Type",
          "type": "integer"
        },
        "fingerprint": {
          "title": "Fingerprint",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "algorithm",
        "hash_type",
        "fingerprint",
        "host"
      ],
      "title": "SSHFP",
      "type": "object"
    },
    "Srv": {
      "description": "Represents a SRV record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "priority": {
          "title": "Priority",
          "type": "integer"
        },
        "weight": {
          "title": "Weight",
          "type": "integer"
        },
        "port": {
          "title": "Port",
          "type": "integer"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ttl"
        },
        "zone": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Zone"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "priority",
        "weight",
        "port",
        "host"
      ],
      "title": "Srv",
      "type": "object"
    },
    "TXT": {
      "description": "Represents a TXT record.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "txt": {
          "title": "Txt",
          "type": "string"
        },
        "host": {
          "title": "Host",
          "type": "integer"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "txt",
        "host"
      ],
      "title": "TXT",
      "type": "object"
    }
  },
  "description": "Model for a list of hosts.",
  "properties": {
    "results": {
      "items": {
        "$ref": "#/$defs/Host"
      },
      "title": "Results",
      "type": "array"
    }
  },
  "required": [
    "results"
  ],
  "title": "HostList",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__getitem__

__getitem__(key: int) -> Host

Get a result by index.

__len__

__len__() -> int

Return the number of results.

__repr__

__repr__() -> str

Return a repr of the results.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

__str__

__str__() -> str

Return a string representation of the results.

count

count() -> int

Return the number of results.

hostnames

hostnames() -> list[str]

Return a list of hostnames.

HostPolicy pydantic-model

Bases: MregModel, ABC

Base model for Host Policy objects.

Note

Host policy models in MREG have a different created_at field than other models. It is called create_date and is a date - not a datetime.

This model has a custom validator to validate and convert the create_date field to a datetime object with the expected created_at name.

Show JSON schema:
{
  "description": "Base model for Host Policy objects.\n\nNote:\n    Host policy models in MREG have a different `created_at` field than\n    other models. It is called `create_date` and is a date - not a datetime.\n\n    This model has a custom validator to validate and convert the `create_date`\n    field to a datetime object with the expected `created_at` name.",
  "properties": {
    "create_date": {
      "format": "date-time",
      "title": "Create Date",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    }
  },
  "required": [
    "create_date",
    "updated_at",
    "name",
    "description"
  ],
  "title": "HostPolicy",
  "type": "object"
}

Fields:

Validators:

created_at property

created_at: datetime

Creation time.

created_at_tz_naive pydantic-field

created_at_tz_naive: datetime

Constructed datetime field from create_date in the API.

WARNING

DO NOT USE THIS FIELD FOR TIMEZONE-AWARE COMPARISONS! Always use created_at instead when comparing with timezone-aware fields such as update_time.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

validate_created_at pydantic-validator

validate_created_at(value: Any) -> datetime

Convert a datetime string to a datetime object.

Parameters:

Name Type Description Default
value Any

The input value - should be a datetime string.

required

Returns:

Type Description
datetime

The input value converted to a datetime object.

IPAddress pydantic-model

Bases: MregModelWithTimestamps

Represents an IP address with associated details.

Show JSON schema:
{
  "description": "Represents an IP address with associated details.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "macaddress": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Macaddress"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "ipaddress",
    "host"
  ],
  "title": "IPAddress",
  "type": "object"
}

Fields:

Validators:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__hash__

__hash__()

Return a hash of the IP address.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

__str__

__str__() -> str

Return the IP address as a string.

create_valid_macadress_or_none pydantic-validator

create_valid_macadress_or_none(v: Any) -> MacAddress | None

Create macaddress or convert empty strings to None.

The API can return an empty string for this field, which fails to validate as a MAC address. Therefore, treat empty strings as None.

is_ipv4

is_ipv4() -> bool

Return True if the IP address is IPv4.

is_ipv6

is_ipv6() -> bool

Return True if the IP address is IPv6.

LDAPHealth pydantic-model

Bases: BaseModel

Model for LDAP health endpoint.

Show JSON schema:
{
  "description": "Model for LDAP health endpoint.",
  "properties": {
    "status": {
      "enum": [
        "OK",
        "Down",
        "Unknown"
      ],
      "title": "Status",
      "type": "string"
    }
  },
  "required": [
    "status"
  ],
  "title": "LDAPHealth",
  "type": "object"
}

Fields:

  • status (Literal['OK', 'Down', 'Unknown'])

Label pydantic-model

Bases: MregModelWithTimestamps

Model for a label.

Show JSON schema:
{
  "description": "Model for a label.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "description"
  ],
  "title": "Label",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

Library pydantic-model

Bases: BaseModel

Model for library metadata.

Show JSON schema:
{
  "description": "Model for library metadata.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "version": {
      "title": "Version",
      "type": "string"
    }
  },
  "required": [
    "name",
    "version"
  ],
  "title": "Library",
  "type": "object"
}

Fields:

Location pydantic-model

Bases: MregModelWithTimestamps

Represents a LOC record.

Show JSON schema:
{
  "description": "Represents a LOC record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "loc": {
      "title": "Loc",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "loc",
    "host"
  ],
  "title": "Location",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

MX pydantic-model

Bases: MregModelWithTimestamps

Represents a MX record.

Show JSON schema:
{
  "description": "Represents a MX record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "mx": {
      "title": "Mx",
      "type": "string"
    },
    "priority": {
      "title": "Priority",
      "type": "integer"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "mx",
    "priority",
    "host"
  ],
  "title": "MX",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

has_mx_with_priority

has_mx_with_priority(mx: str, priority: int) -> bool

Return True if the MX record has the given MX and priority.

Parameters:

Name Type Description Default
mx str

The MX record to check.

required
priority int

The priority to check.

required

Returns:

Type Description
bool

True if the MX record has the given MX and priority.

NAPTR pydantic-model

Bases: MregModelWithTimestamps

Represents a NAPTR record.

Show JSON schema:
{
  "description": "Represents a NAPTR record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "preference": {
      "title": "Preference",
      "type": "integer"
    },
    "order": {
      "title": "Order",
      "type": "integer"
    },
    "flag": {
      "default": "",
      "title": "Flag",
      "type": "string"
    },
    "service": {
      "default": "",
      "title": "Service",
      "type": "string"
    },
    "regex": {
      "default": "",
      "title": "Regex",
      "type": "string"
    },
    "replacement": {
      "title": "Replacement",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "preference",
    "order",
    "replacement",
    "host"
  ],
  "title": "NAPTR",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

headers classmethod

headers() -> list[str]

Return the headers for the NAPTR record.

NameServer pydantic-model

Bases: MregModelWithTimestamps

Model for representing a nameserver within a DNS zone.

Show JSON schema:
{
  "description": "Model for representing a nameserver within a DNS zone.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "ttl": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ttl"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "ttl"
  ],
  "title": "NameServer",
  "type": "object"
}

Config:

  • frozen: True

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

Network pydantic-model

Bases: MregModelWithTimestamps

Model for a network.

Show JSON schema:
{
  "$defs": {
    "Community": {
      "description": "Network community.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "network": {
          "title": "Network",
          "type": "integer"
        },
        "hosts": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Hosts",
          "type": "array"
        },
        "global_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Global Name"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "description",
        "network"
      ],
      "title": "Community",
      "type": "object"
    },
    "ExcludedRange": {
      "description": "Model for an excluded IP range for a network.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "network": {
          "title": "Network",
          "type": "integer"
        },
        "start_ip": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "Start Ip"
        },
        "end_ip": {
          "anyOf": [
            {
              "format": "ipv4",
              "type": "string"
            },
            {
              "format": "ipv6",
              "type": "string"
            }
          ],
          "title": "End Ip"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "network",
        "start_ip",
        "end_ip"
      ],
      "title": "ExcludedRange",
      "type": "object"
    },
    "NetworkPolicy": {
      "description": "Network policy used in a community.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Description"
        },
        "attributes": {
          "default": [],
          "items": {
            "$ref": "#/$defs/NetworkPolicyAttributeValue"
          },
          "title": "Attributes",
          "type": "array"
        },
        "community_template_pattern": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Community Template Pattern"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name"
      ],
      "title": "NetworkPolicy",
      "type": "object"
    },
    "NetworkPolicyAttributeValue": {
      "description": "Name and value of a network policy's attribute.",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "value": {
          "title": "Value",
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "value"
      ],
      "title": "NetworkPolicyAttributeValue",
      "type": "object"
    }
  },
  "description": "Model for a network.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "excluded_ranges": {
      "items": {
        "$ref": "#/$defs/ExcludedRange"
      },
      "title": "Excluded Ranges",
      "type": "array"
    },
    "network": {
      "title": "Network",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "vlan": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Vlan"
    },
    "dns_delegated": {
      "title": "Dns Delegated",
      "type": "boolean"
    },
    "category": {
      "title": "Category",
      "type": "string"
    },
    "location": {
      "title": "Location",
      "type": "string"
    },
    "frozen": {
      "title": "Frozen",
      "type": "boolean"
    },
    "reserved": {
      "title": "Reserved",
      "type": "integer"
    },
    "policy": {
      "anyOf": [
        {
          "$ref": "#/$defs/NetworkPolicy"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "communities": {
      "default": [],
      "items": {
        "$ref": "#/$defs/Community"
      },
      "title": "Communities",
      "type": "array"
    },
    "max_communities": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Max Communities"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "excluded_ranges",
    "network",
    "description",
    "dns_delegated",
    "category",
    "location",
    "frozen",
    "reserved"
  ],
  "title": "Network",
  "type": "object"
}

Fields:

broadcast_address property

broadcast_address: IP_AddressT

The broadcast address of the network.

ip_network cached property

ip_network: IP_NetworkT

IP network object for the network.

network_address property

network_address: IP_AddressT

The network address of the network.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__hash__

__hash__()

Return a hash of the network.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

dummy_network_from_ip classmethod

dummy_network_from_ip(ip: IPAddress) -> Self

Create a Network object for an unknown network given an IP.

NOTE: Does not perform any API calls. This is purely to work around the fact that MREG supports creating IP addresses for networks that are not registered in MREG.

get_communities

get_communities(name: str) -> list[Community]

Get all communities with the given name.

Parameters:

Name Type Description Default
name str

The name of the communities to search for.

required

Returns:

Type Description
list[Community]

A list of communities with the given name.

get_community

get_community(name: str) -> Community | None

Get a community by name.

Returns the first community with the given name, or None if not found.

Parameters:

Name Type Description Default
name str

The name of the community to search for.

required

Returns:

Type Description
Community | None

The community if found, None otherwise.

overlaps

overlaps(other: Network | str | IP_NetworkT) -> bool

Check if the network overlaps with another network.

NetworkOrIP pydantic-model

Bases: BaseModel

A model for either a network or an IP address.

Show JSON schema:
{
  "description": "A model for either a network or an IP address.",
  "properties": {
    "ip_or_network": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        },
        {
          "format": "ipv4network",
          "type": "string"
        },
        {
          "format": "ipv6network",
          "type": "string"
        }
      ],
      "title": "Ip Or Network"
    }
  },
  "required": [
    "ip_or_network"
  ],
  "title": "NetworkOrIP",
  "type": "object"
}

Fields:

  • ip_or_network (IP_AddressT | IP_NetworkT)

Validators:

__str__

__str__() -> str

Return the value as a string.

as_ip

as_ip() -> IP_AddressT

Return the value as an IP address.

as_ipv4

as_ipv4() -> IPv4Address

Return the value as an IPv4 address.

as_ipv4_network

as_ipv4_network() -> IPv4Network

Return the value as a network.

as_ipv6

as_ipv6() -> IPv6Address

Return the value as an IPv6 address.

as_ipv6_network

as_ipv6_network() -> IP_NetworkT

Return the value as a network.

as_network

as_network() -> IP_NetworkT

Return the value as a network.

is_ip

is_ip() -> bool

Return True if the value is an IP address.

is_ipv4

is_ipv4() -> bool

Return True if the value is an IPv4 address.

is_ipv4_network

is_ipv4_network() -> bool

Return True if the value is an IPv4 network.

is_ipv6

is_ipv6() -> bool

Return True if the value is an IPv6 address.

is_ipv6_network

is_ipv6_network() -> bool

Return True if the value is an IPv6 network.

is_network

is_network() -> bool

Return True if the value is a network.

parse classmethod

parse(
    value: Any, mode: None = None
) -> IP_AddressT | IP_NetworkT | None
parse(
    value: Any, mode: Literal["ip"]
) -> IP_AddressT | None
parse(
    value: Any, mode: Literal["ipv4"]
) -> IPv4Address | None
parse(
    value: Any, mode: Literal["ipv6"]
) -> IPv6Address | None
parse(
    value: Any, mode: Literal["network"]
) -> IP_NetworkT | None
parse(
    value: Any, mode: Literal["networkv4"]
) -> IPv4Network | None
parse(
    value: Any, mode: Literal["networkv6"]
) -> IPv6Network | None
parse(
    value: Any, mode: IPNetMode | None = None
) -> IP_AddressT | IP_NetworkT | None

Parse a value as an IP address or network, or None if parsing fails.

Optionally specify the mode to validate the input as.

Parameters:

Name Type Description Default
value Any

The value to parse.

required
mode IPNetMode | None

The mode to validate the input as.

None

Returns:

Type Description
IP_AddressT | IP_NetworkT | None

The parsed value as an IP address or network, or None.

parse_or_raise classmethod

parse_or_raise(
    value: Any, mode: None = None
) -> IP_AddressT | IP_NetworkT
parse_or_raise(
    value: Any, mode: Literal["ip"]
) -> IP_AddressT
parse_or_raise(
    value: Any, mode: Literal["ipv4"]
) -> IPv4Address
parse_or_raise(
    value: Any, mode: Literal["ipv6"]
) -> IPv6Address
parse_or_raise(
    value: Any, mode: Literal["network"]
) -> IP_NetworkT
parse_or_raise(
    value: Any, mode: Literal["networkv4"]
) -> IPv4Network
parse_or_raise(
    value: Any, mode: Literal["networkv6"]
) -> IPv6Network
parse_or_raise(
    value: Any, mode: IPNetMode | None = None
) -> IP_AddressT | IP_NetworkT

Parse a value as an IP address or network.

Optionally specify the mode to validate the input as.

Parameters:

Name Type Description Default
value Any

The value to parse.

required
mode IPNetMode | None

The mode to validate the input as.

None

Returns:

Type Description
IP_AddressT | IP_NetworkT

The parsed value as an IP address or network.

Raises:

Type Description
IPNetworkError

If the value is not an IP address or network.

validate classmethod

validate(
    value: str | IP_AddressT | IP_NetworkT | Self,
) -> Self

Create a NetworkOrIP model instance from a value.

This constructor validates and wraps the IP/network in the model.

Parameters:

Name Type Description Default
value str | IP_AddressT | IP_NetworkT | Self

The value to convert (string or IP object)

required

Returns:

Type Description
Self

A NetworkOrIP model instance

Raises:

Type Description
InputFailure

If validation fails

validate_ip_or_network pydantic-validator

validate_ip_or_network(
    value: Any,
) -> IP_AddressT | IP_NetworkT

Validate and convert the input to an IP address or network.

NetworkPolicy pydantic-model

Bases: MregModelWithTimestamps

Network policy used in a community.

Show JSON schema:
{
  "$defs": {
    "NetworkPolicyAttributeValue": {
      "description": "Name and value of a network policy's attribute.",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "value": {
          "title": "Value",
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "value"
      ],
      "title": "NetworkPolicyAttributeValue",
      "type": "object"
    }
  },
  "description": "Network policy used in a community.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Description"
    },
    "attributes": {
      "default": [],
      "items": {
        "$ref": "#/$defs/NetworkPolicyAttributeValue"
      },
      "title": "Attributes",
      "type": "array"
    },
    "community_template_pattern": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Community Template Pattern"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name"
  ],
  "title": "NetworkPolicy",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

get_attribute

get_attribute(
    name: str,
) -> NetworkPolicyAttributeValue | None

Get a attribute by name.

Parameters:

Name Type Description Default
name str

The name of the attribute to search for.

required

Returns:

Type Description
NetworkPolicyAttributeValue | None

The attribute if found, None otherwise.

get_attribute_or_raise

get_attribute_or_raise(
    name: str,
) -> NetworkPolicyAttributeValue

Get a network attribute value by name, and raise if not found.

Parameters:

Name Type Description Default
name str

The name of the attribute to search for.

required

Returns:

Type Description
NetworkPolicyAttributeValue

The attribute if found.

Raises:

Type Description
EntityNotFound

If the attribute is not found.

NetworkPolicyAttribute pydantic-model

Bases: MregModelWithTimestamps

The definition of a network policy attribute.

See NetworkPolicyAttr for the representation of attributes in Policies.

Show JSON schema:
{
  "description": "The definition of a network policy attribute.\n\nSee NetworkPolicyAttr for the representation of attributes in Policies.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "description"
  ],
  "title": "NetworkPolicyAttribute",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

NetworkPolicyAttributeValue pydantic-model

Bases: BaseModel

Name and value of a network policy's attribute.

Show JSON schema:
{
  "description": "Name and value of a network policy's attribute.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "value": {
      "title": "Value",
      "type": "boolean"
    }
  },
  "required": [
    "name",
    "value"
  ],
  "title": "NetworkPolicyAttributeValue",
  "type": "object"
}

Fields:

PTR_override pydantic-model

Bases: MregModelWithTimestamps

Represents a PTR override record.

Show JSON schema:
{
  "description": "Represents a PTR override record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "ipaddress": {
      "anyOf": [
        {
          "format": "ipv4",
          "type": "string"
        },
        {
          "format": "ipv6",
          "type": "string"
        }
      ],
      "title": "Ipaddress"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "ipaddress",
    "host"
  ],
  "title": "PTR_override",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

Permission pydantic-model

Bases: MregModelWithTimestamps

Model for a permission object.

Show JSON schema:
{
  "description": "Model for a permission object.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "group": {
      "title": "Group",
      "type": "string"
    },
    "range": {
      "anyOf": [
        {
          "format": "ipv4network",
          "type": "string"
        },
        {
          "format": "ipv6network",
          "type": "string"
        }
      ],
      "title": "Range"
    },
    "regex": {
      "title": "Regex",
      "type": "string"
    },
    "labels": {
      "items": {
        "type": "integer"
      },
      "title": "Labels",
      "type": "array"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "group",
    "range",
    "regex",
    "labels"
  ],
  "title": "Permission",
  "type": "object"
}

Fields:

Validators:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

validate_ip_or_network pydantic-validator

validate_ip_or_network(value: Any) -> IP_NetworkT

Validate and convert the input to a network.

ReverseZone pydantic-model

Bases: _Zone

A reverse zone.

Show JSON schema:
{
  "$defs": {
    "NameServer": {
      "description": "Model for representing a nameserver within a DNS zone.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "ttl"
      ],
      "title": "NameServer",
      "type": "object"
    }
  },
  "description": "A reverse zone.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "nameservers": {
      "items": {
        "$ref": "#/$defs/NameServer"
      },
      "title": "Nameservers",
      "type": "array"
    },
    "updated": {
      "title": "Updated",
      "type": "boolean"
    },
    "primary_ns": {
      "title": "Primary Ns",
      "type": "string"
    },
    "email": {
      "title": "Email",
      "type": "string"
    },
    "serialno": {
      "title": "Serialno",
      "type": "integer"
    },
    "serialno_updated_at": {
      "format": "date-time",
      "title": "Serialno Updated At",
      "type": "string"
    },
    "refresh": {
      "title": "Refresh",
      "type": "integer"
    },
    "retry": {
      "title": "Retry",
      "type": "integer"
    },
    "expire": {
      "title": "Expire",
      "type": "integer"
    },
    "soa_ttl": {
      "title": "Soa Ttl",
      "type": "integer"
    },
    "default_ttl": {
      "title": "Default Ttl",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "nameservers",
    "updated",
    "primary_ns",
    "email",
    "serialno",
    "serialno_updated_at",
    "refresh",
    "retry",
    "expire",
    "soa_ttl",
    "default_ttl",
    "name"
  ],
  "title": "ReverseZone",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

ensure_delegation_in_zone

ensure_delegation_in_zone(name: str) -> None

Ensure a delegation is in the zone.

Parameters:

Name Type Description Default
name str

The name of the delegation to check.

required

Returns:

Type Description
None

True if the delegation is in the zone.

is_delegated

is_delegated() -> bool

Return True if the zone is delegated.

is_reverse

is_reverse() -> bool

Return True if the zone is a reverse zone.

ReverseZoneDelegation pydantic-model

Bases: _Delegation

A reverse zone delegation.

Show JSON schema:
{
  "$defs": {
    "NameServer": {
      "description": "Model for representing a nameserver within a DNS zone.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "title": "Created At",
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "title": "Updated At",
          "type": "string"
        },
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "ttl": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ttl"
        }
      },
      "required": [
        "created_at",
        "updated_at",
        "id",
        "name",
        "ttl"
      ],
      "title": "NameServer",
      "type": "object"
    }
  },
  "description": "A reverse zone delegation.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "nameservers": {
      "items": {
        "$ref": "#/$defs/NameServer"
      },
      "title": "Nameservers",
      "type": "array"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "comment": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Comment"
    },
    "zone": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "nameservers",
    "name"
  ],
  "title": "ReverseZoneDelegation",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

is_delegated

is_delegated() -> bool

Return True if the zone is delegated.

is_reverse classmethod

is_reverse() -> bool

Return True if the delegation is for a reverse zone.

Role pydantic-model

Bases: HostPolicy

Model for a role.

Show JSON schema:
{
  "description": "Model for a role.",
  "properties": {
    "create_date": {
      "format": "date-time",
      "title": "Create Date",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "hosts": {
      "items": {
        "type": "string"
      },
      "title": "Hosts",
      "type": "array"
    },
    "atoms": {
      "items": {
        "type": "string"
      },
      "title": "Atoms",
      "type": "array"
    },
    "labels": {
      "items": {
        "type": "integer"
      },
      "title": "Labels",
      "type": "array"
    }
  },
  "required": [
    "create_date",
    "updated_at",
    "name",
    "description",
    "id",
    "hosts",
    "atoms",
    "labels"
  ],
  "title": "Role",
  "type": "object"
}

Fields:

Validators:

created_at property

created_at: datetime

Creation time.

created_at_tz_naive pydantic-field

created_at_tz_naive: datetime

Constructed datetime field from create_date in the API.

WARNING

DO NOT USE THIS FIELD FOR TIMEZONE-AWARE COMPARISONS! Always use created_at instead when comparing with timezone-aware fields such as update_time.

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__hash__

__hash__() -> int

Hash the role by ID and name.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

validate_created_at pydantic-validator

validate_created_at(value: Any) -> datetime

Convert a datetime string to a datetime object.

Parameters:

Name Type Description Default
value Any

The input value - should be a datetime string.

required

Returns:

Type Description
datetime

The input value converted to a datetime object.

SSHFP pydantic-model

Bases: MregModelWithTimestamps

Represents a SSHFP record.

Show JSON schema:
{
  "description": "Represents a SSHFP record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "algorithm": {
      "title": "Algorithm",
      "type": "integer"
    },
    "hash_type": {
      "title": "Hash Type",
      "type": "integer"
    },
    "fingerprint": {
      "title": "Fingerprint",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    },
    "ttl": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ttl"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "algorithm",
    "hash_type",
    "fingerprint",
    "host"
  ],
  "title": "SSHFP",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

ServerLibraries pydantic-model

Bases: BaseModel

Model for server libraries metadata.

Show JSON schema:
{
  "$defs": {
    "Library": {
      "description": "Model for library metadata.",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "version": {
          "title": "Version",
          "type": "string"
        }
      },
      "required": [
        "name",
        "version"
      ],
      "title": "Library",
      "type": "object"
    }
  },
  "description": "Model for server libraries metadata.",
  "properties": {
    "libraries": {
      "items": {
        "$ref": "#/$defs/Library"
      },
      "title": "Libraries",
      "type": "array"
    }
  },
  "required": [
    "libraries"
  ],
  "title": "ServerLibraries",
  "type": "object"
}

Fields:

ServerVersion pydantic-model

Bases: BaseModel

Model for server version metadata.

Show JSON schema:
{
  "description": "Model for server version metadata.",
  "properties": {
    "version": {
      "title": "Version",
      "type": "string"
    }
  },
  "required": [
    "version"
  ],
  "title": "ServerVersion",
  "type": "object"
}

Fields:

  • version (str)

Srv pydantic-model

Bases: MregModelWithTimestamps

Represents a SRV record.

Show JSON schema:
{
  "description": "Represents a SRV record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "priority": {
      "title": "Priority",
      "type": "integer"
    },
    "weight": {
      "title": "Weight",
      "type": "integer"
    },
    "port": {
      "title": "Port",
      "type": "integer"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    },
    "ttl": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ttl"
    },
    "zone": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zone"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "name",
    "priority",
    "weight",
    "port",
    "host"
  ],
  "title": "Srv",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

__str__

__str__() -> str

Return a string representation of the SRV record.

TXT pydantic-model

Bases: MregModelWithTimestamps

Represents a TXT record.

Show JSON schema:
{
  "description": "Represents a TXT record.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    },
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "txt": {
      "title": "Txt",
      "type": "string"
    },
    "host": {
      "title": "Host",
      "type": "integer"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "id",
    "txt",
    "host"
  ],
  "title": "TXT",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

TokenAuth pydantic-model

Bases: MregModel

Model for token authentication response.

Show JSON schema:
{
  "description": "Model for token authentication response.",
  "properties": {
    "token": {
      "title": "Token",
      "type": "string"
    }
  },
  "required": [
    "token"
  ],
  "title": "TokenAuth",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

TokenInfo pydantic-model

Bases: BaseModel

Model for token information.

Show JSON schema:
{
  "description": "Model for token information.",
  "properties": {
    "is_valid": {
      "title": "Is Valid",
      "type": "boolean"
    },
    "created": {
      "title": "Created",
      "type": "string"
    },
    "expire": {
      "title": "Expire",
      "type": "string"
    },
    "last_used": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last Used"
    },
    "lifespan": {
      "title": "Lifespan",
      "type": "string"
    }
  },
  "required": [
    "is_valid",
    "created",
    "expire",
    "lifespan"
  ],
  "title": "TokenInfo",
  "type": "object"
}

Fields:

  • is_valid (bool)
  • created (str)
  • expire (str)
  • last_used (str | None)
  • lifespan (str)

UserDjangoStatus pydantic-model

Bases: BaseModel

Model for Django status in the user response.

Show JSON schema:
{
  "description": "Model for Django status in the user response.",
  "properties": {
    "superuser": {
      "default": false,
      "title": "Superuser",
      "type": "boolean"
    },
    "staff": {
      "default": false,
      "title": "Staff",
      "type": "boolean"
    },
    "active": {
      "default": false,
      "title": "Active",
      "type": "boolean"
    }
  },
  "title": "UserDjangoStatus",
  "type": "object"
}

Fields:

UserInfo pydantic-model

Bases: BaseModel

Model for the user information.

Show JSON schema:
{
  "$defs": {
    "TokenInfo": {
      "description": "Model for token information.",
      "properties": {
        "is_valid": {
          "title": "Is Valid",
          "type": "boolean"
        },
        "created": {
          "title": "Created",
          "type": "string"
        },
        "expire": {
          "title": "Expire",
          "type": "string"
        },
        "last_used": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Last Used"
        },
        "lifespan": {
          "title": "Lifespan",
          "type": "string"
        }
      },
      "required": [
        "is_valid",
        "created",
        "expire",
        "lifespan"
      ],
      "title": "TokenInfo",
      "type": "object"
    },
    "UserDjangoStatus": {
      "description": "Model for Django status in the user response.",
      "properties": {
        "superuser": {
          "default": false,
          "title": "Superuser",
          "type": "boolean"
        },
        "staff": {
          "default": false,
          "title": "Staff",
          "type": "boolean"
        },
        "active": {
          "default": false,
          "title": "Active",
          "type": "boolean"
        }
      },
      "title": "UserDjangoStatus",
      "type": "object"
    },
    "UserMregStatus": {
      "description": "Model for Mreg status in the user response.",
      "properties": {
        "superuser": {
          "default": false,
          "title": "Superuser",
          "type": "boolean"
        },
        "admin": {
          "default": false,
          "title": "Admin",
          "type": "boolean"
        },
        "group_admin": {
          "default": false,
          "title": "Group Admin",
          "type": "boolean"
        },
        "network_admin": {
          "default": false,
          "title": "Network Admin",
          "type": "boolean"
        },
        "hostpolicy_admin": {
          "default": false,
          "title": "Hostpolicy Admin",
          "type": "boolean"
        },
        "dns_wildcard_admin": {
          "default": false,
          "title": "Dns Wildcard Admin",
          "type": "boolean"
        },
        "underscore_admin": {
          "default": false,
          "title": "Underscore Admin",
          "type": "boolean"
        }
      },
      "title": "UserMregStatus",
      "type": "object"
    },
    "UserPermission": {
      "description": "Model for permissions in the user response.",
      "properties": {
        "group": {
          "title": "Group",
          "type": "string"
        },
        "range": {
          "title": "Range",
          "type": "string"
        },
        "regex": {
          "title": "Regex",
          "type": "string"
        },
        "labels": {
          "items": {
            "type": "string"
          },
          "title": "Labels",
          "type": "array"
        }
      },
      "required": [
        "group",
        "range",
        "regex",
        "labels"
      ],
      "title": "UserPermission",
      "type": "object"
    }
  },
  "description": "Model for the user information.",
  "properties": {
    "username": {
      "title": "Username",
      "type": "string"
    },
    "last_login": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last Login"
    },
    "token": {
      "anyOf": [
        {
          "$ref": "#/$defs/TokenInfo"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "django_status": {
      "$ref": "#/$defs/UserDjangoStatus"
    },
    "mreg_status": {
      "$ref": "#/$defs/UserMregStatus"
    },
    "groups": {
      "items": {
        "type": "string"
      },
      "title": "Groups",
      "type": "array"
    },
    "permissions": {
      "items": {
        "$ref": "#/$defs/UserPermission"
      },
      "title": "Permissions",
      "type": "array"
    }
  },
  "required": [
    "username"
  ],
  "title": "UserInfo",
  "type": "object"
}

Fields:

UserMregStatus pydantic-model

Bases: BaseModel

Model for Mreg status in the user response.

Show JSON schema:
{
  "description": "Model for Mreg status in the user response.",
  "properties": {
    "superuser": {
      "default": false,
      "title": "Superuser",
      "type": "boolean"
    },
    "admin": {
      "default": false,
      "title": "Admin",
      "type": "boolean"
    },
    "group_admin": {
      "default": false,
      "title": "Group Admin",
      "type": "boolean"
    },
    "network_admin": {
      "default": false,
      "title": "Network Admin",
      "type": "boolean"
    },
    "hostpolicy_admin": {
      "default": false,
      "title": "Hostpolicy Admin",
      "type": "boolean"
    },
    "dns_wildcard_admin": {
      "default": false,
      "title": "Dns Wildcard Admin",
      "type": "boolean"
    },
    "underscore_admin": {
      "default": false,
      "title": "Underscore Admin",
      "type": "boolean"
    }
  },
  "title": "UserMregStatus",
  "type": "object"
}

Fields:

  • superuser (bool)
  • admin (bool)
  • group_admin (bool)
  • network_admin (bool)
  • hostpolicy_admin (bool)
  • dns_wildcard_admin (bool)
  • underscore_admin (bool)

UserPermission pydantic-model

Bases: BaseModel

Model for permissions in the user response.

Show JSON schema:
{
  "description": "Model for permissions in the user response.",
  "properties": {
    "group": {
      "title": "Group",
      "type": "string"
    },
    "range": {
      "title": "Range",
      "type": "string"
    },
    "regex": {
      "title": "Regex",
      "type": "string"
    },
    "labels": {
      "items": {
        "type": "string"
      },
      "title": "Labels",
      "type": "array"
    }
  },
  "required": [
    "group",
    "range",
    "regex",
    "labels"
  ],
  "title": "UserPermission",
  "type": "object"
}

Fields:

labels_str property

labels_str: str

Return the labels as a string.

ZoneFile

Bases: RootModel[str]

Zone file model.

Uses a RootModel-based approach that does not inherit from MregModel and APIMixin, because the endpoint itself just returns text blobs.

__str__

__str__() -> str

Return the zone file contents.

is_reverse_zone_name

is_reverse_zone_name(name: str) -> bool

Determine if a zone is a reverse zone by its name.

Parameters:

Name Type Description Default
name str

The name of the zone.

required

Returns:

Type Description
bool

True if the zone is a reverse zone.

history

History abstractions for mreg-cli.

HistoryItem pydantic-model

Bases: BaseModel

Represents a history item.

Show JSON schema:
{
  "$defs": {
    "HistoryResource": {
      "description": "History resources for the API.\n\nNames represent resource names.\nValues represent resource relations.\n\nAccess resource names and relation with the `resource()` and `relation()` methods.",
      "enum": [
        "hosts",
        "groups",
        "roles",
        "atoms"
      ],
      "title": "HistoryResource",
      "type": "string"
    },
    "JsonValue": {}
  },
  "description": "Represents a history item.",
  "properties": {
    "id": {
      "title": "Id",
      "type": "integer"
    },
    "timestamp": {
      "format": "date-time",
      "title": "Timestamp",
      "type": "string"
    },
    "user": {
      "title": "User",
      "type": "string"
    },
    "resource": {
      "$ref": "#/$defs/HistoryResource"
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "model_id": {
      "title": "Model Id",
      "type": "integer"
    },
    "model": {
      "title": "Model",
      "type": "string"
    },
    "action": {
      "title": "Action",
      "type": "string"
    },
    "data": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "title": "Data",
      "type": "object"
    }
  },
  "required": [
    "id",
    "timestamp",
    "user",
    "resource",
    "name",
    "model_id",
    "model",
    "action",
    "data"
  ],
  "title": "HistoryItem",
  "type": "object"
}

Fields:

Validators:

message property

message: str

Human-readable description of this history entry.

Guards rendering from failing due to malformed data, and falls back to a raw string representation of the data if rendering fails.

parse_json_data pydantic-validator

parse_json_data(v: Any) -> Any

Parse the data field as JSON if it's a string.

HistoryRelation pydantic-model

Bases: BaseModel

Data for history of addition/removal of relations.

Show JSON schema:
{
  "description": "Data for history of addition/removal of relations.",
  "properties": {
    "relation": {
      "title": "Relation",
      "type": "string"
    },
    "id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "string"
        }
      ],
      "title": "Id"
    },
    "name": {
      "title": "Name",
      "type": "string"
    }
  },
  "required": [
    "relation",
    "id",
    "name"
  ],
  "title": "HistoryRelation",
  "type": "object"
}

Fields:

render

render(action: str, resource: str, target: str) -> str

Render the history data as a human-readable string.

HistoryResource

Bases: str, Enum

History resources for the API.

Names represent resource names. Values represent resource relations.

Access resource names and relation with the resource() and relation() methods.

relation

relation() -> str

Get the resource relation.

resource

resource() -> str

Get the resource name.

HistoryUpdate pydantic-model

Bases: BaseModel

Data for history of updates to an object.

Show JSON schema:
{
  "$defs": {
    "JsonValue": {}
  },
  "description": "Data for history of updates to an object.",
  "properties": {
    "current_data": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "title": "Current Data",
      "type": "object"
    },
    "update": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "title": "Update",
      "type": "object"
    }
  },
  "required": [
    "current_data",
    "update"
  ],
  "title": "HistoryUpdate",
  "type": "object"
}

Fields:

  • current_data (JsonMapping)
  • update (JsonMapping)

render

render(model: str) -> str

Render the history data as a human-readable string.

fields

Custom field types for Pydantic models.

The types resolve to basic types like str, int, etc., but with additional validation added to them. The types are used in Pydantic models for consistent validation of common fields such as hostnames, MAC addresses, etc.

Warning: Values constructed from these types should NOT be checked at runtime with isinstance()! Pydantic will always coerce these types to their schema types (str, int, etc.).

HostName module-attribute

HostName = NewType('HostName', str)

Validated hostname string type.

HostNameField module-attribute

Pydantic-compatible hostname field type.

Use as a model field type where the server returns hostnames that should be normalised (lowercase, trailing dot stripped) on deserialisation.

No expansion occurs, since the server should always return fully qualified hostnames. Furthermore, we have no way to know what domain to expand to, so we don't attempt it.

TODO: Consider if we should remove validation of incoming hostnames from the server. It is not really the client's responsibility to validate server data to this level of granularity.

NameList module-attribute

NameList = Annotated[
    list[Annotated[str, BeforeValidator(_extract_name)]],
    AfterValidator(_remove_falsy_list_items),
]

List of names extracted from a list of dicts.

VerifiedNS module-attribute

VerifiedNS = NewType('VerifiedNS', HostName)

A nameserver that is a (best-effort) FQDN and has been verified to exist in mreg and have an A-record/glue.

Acts like a string on runtime.

MacAddress

Bases: MacAddress

MAC address string type used in Pydantic models.

parse classmethod

parse(obj: Any) -> MacAddress | None

Parse a MAC address from a string. Returns None if the MAC address is invalid.

Parameters:

Name Type Description Default
obj Any

The object to parse.

required

Returns:

Type Description
MacAddress | None

The MAC address as a string or None if it is invalid.

parse_or_raise classmethod

parse_or_raise(obj: Any) -> MacAddress

Parse a MAC address from a string. Returns the MAC address as a string.

Parameters:

Name Type Description Default
obj Any

The object to parse.

required

Returns:

Type Description
MacAddress

The MAC address as a string.

Raises:

Type Description
ValueError

If the object is not a valid MAC address.

parse_hostname

parse_hostname(
    value: str, domain: str | None = None
) -> HostName

Normalise and optionally expand a hostname.

Normalisation: lowercase, strip trailing dot, validate shape. Expansion: if no dot remains after normalisation and domain is non-empty, append the domain.

Parameters:

Name Type Description Default
value str

Raw hostname string.

required
domain str | None

Domain to append when the name has no dot after normalisation. Pass None (default) to skip expansion.

None

Returns:

Type Description
HostName

Normalised (and optionally expanded) :data:HostName.

Raises:

Type Description
InputFailure

If the value is not a valid hostname shape.

abstracts

Abstract models for the API.

MregModel pydantic-model

Bases: BaseModel

Model for an immutable object.

Show JSON schema:
{
  "description": "Model for an immutable object.",
  "properties": {},
  "title": "MregModel",
  "type": "object"
}

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.

MregModelWithTimestamps pydantic-model

Bases: MregModel

Model with created_at and updated_at fields.

Show JSON schema:
{
  "description": "Model with created_at and updated_at fields.",
  "properties": {
    "created_at": {
      "format": "date-time",
      "title": "Created At",
      "type": "string"
    },
    "updated_at": {
      "format": "date-time",
      "title": "Updated At",
      "type": "string"
    }
  },
  "required": [
    "created_at",
    "updated_at"
  ],
  "title": "MregModelWithTimestamps",
  "type": "object"
}

Fields:

__delattr__

__delattr__(name: str)

Raise an exception when trying to delete an attribute.

__setattr__

__setattr__(name: str, value: Any)

Raise an exception when trying to set an attribute.