mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
Add model documentation
This commit is contained in:
parent
1c17ecd2c8
commit
a6e2c4c583
25
docs/models/core/datafile.md
Normal file
25
docs/models/core/datafile.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Data Files
|
||||||
|
|
||||||
|
A data file object is the representation in NetBox's database of some file belonging to a remote [data source](./datasource.md). Data files are synchronized automatically, and cannot be modified locally (although they can be deleted).
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
### Source
|
||||||
|
|
||||||
|
The [data source](./datasource.md) to which this file belongs.
|
||||||
|
|
||||||
|
### Path
|
||||||
|
|
||||||
|
The path to the file, relative to its source's URL. For example, a file at `/opt/config-data/routing/bgp/peer.yaml` with a source URL of `file:///opt/config-data/` would have its path set to `routing/bgp/peer.yaml`.
|
||||||
|
|
||||||
|
### Last Updated
|
||||||
|
|
||||||
|
The date and time at which the file most recently updated from its source. Note that this attribute is updated only when the file's contents have been modified. Re-synchronizing the data source will not update this timestamp if the upstream file's data has not changed.
|
||||||
|
|
||||||
|
### Size
|
||||||
|
|
||||||
|
The file's size, in bytes.
|
||||||
|
|
||||||
|
### Hash
|
||||||
|
|
||||||
|
A [SHA256 hash](https://en.wikipedia.org/wiki/SHA-2) of the file's data. This can be compared to a hash taken from the original file to determine whether any changes have been made.
|
47
docs/models/core/datasource.md
Normal file
47
docs/models/core/datasource.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Data Sources
|
||||||
|
|
||||||
|
A data source represents some external repository of data which NetBox can consume, such as a git repository. Files within the data source are synchronized to NetBox by saving them in the database as [data file](./datafile.md) objects.
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
### Name
|
||||||
|
|
||||||
|
The data source's human-friendly name.
|
||||||
|
|
||||||
|
### Type
|
||||||
|
|
||||||
|
The type of data source. Supported options include:
|
||||||
|
|
||||||
|
* Local directory
|
||||||
|
* git repository
|
||||||
|
|
||||||
|
### URL
|
||||||
|
|
||||||
|
The URL identifying the remote source. Some examples are included below.
|
||||||
|
|
||||||
|
| Type | Example URL |
|
||||||
|
|------|-------------|
|
||||||
|
| Local | file:///var/my/data/source/ |
|
||||||
|
| git | https://https://github.com/my-organization/my-repo |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
The source's current synchronization status. Note that this cannot be set manually: It is updated automatically when the source is synchronized.
|
||||||
|
|
||||||
|
### Enabled
|
||||||
|
|
||||||
|
If false, synchronization will be disabled.
|
||||||
|
|
||||||
|
### Ignore Rules
|
||||||
|
|
||||||
|
A set of rules (one per line) identifying filenames to ignore during synchronization. Some examples are provided below. See Python's [`fnmatch()` documentation](https://docs.python.org/3/library/fnmatch.html) for a complete reference.
|
||||||
|
|
||||||
|
| Rule | Description |
|
||||||
|
|----------------|------------------------------------------|
|
||||||
|
| `README` | Ignore any files named `README` |
|
||||||
|
| `*.txt` | Ignore any files with a `.txt` extension |
|
||||||
|
| `data???.json` | Ignore e.g. `data123.json` |
|
||||||
|
|
||||||
|
### Last Synced
|
||||||
|
|
||||||
|
The date and time at which the source was most recently synchronized successfully.
|
@ -3,6 +3,7 @@ import os
|
|||||||
from fnmatch import fnmatchcase
|
from fnmatch import fnmatchcase
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
@ -81,6 +82,10 @@ class DataSource(ChangeLoggedModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('core:datasource', args=[self.pk])
|
return reverse('core:datasource', args=[self.pk])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def docs_url(self):
|
||||||
|
return f'{settings.STATIC_URL}docs/models/{self._meta.app_label}/{self._meta.model_name}/'
|
||||||
|
|
||||||
def get_type_color(self):
|
def get_type_color(self):
|
||||||
return DataSourceTypeChoices.colors.get(self.type)
|
return DataSourceTypeChoices.colors.get(self.type)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user