Nautobot App Livedata API Package¶
nautobot_app_livedata.api
¶
REST API module for Nautobot App Livedata.
serializers
¶
Nautobot App Livedata API Serializers.
LivedataJobResultSerializer
¶
Bases: Serializer
Serializer for the Nautobot App Livedata API to return the Job Result.
This serializer is used to get the job result for the given jobresult_id.
Properties:
- jobresult_id (UUID): The job result ID of the job that was enqueued.
Raises: - ValidationError: If the job result ID is not defined. - ValidationError: If the job result is not found.
Source code in nautobot_app_livedata/api/serializers.py
LivedataSerializer
¶
Bases: Serializer
Serializer for the Nautobot App Livedata API to return the Managed Device.
For more information on implementing jobs, refer to the Nautobot job documentation: https://docs.nautobot.com/projects/core/en/stable/development/jobs/
This serializer is used to get the managed device for the given object_type and ID.
Properties:
- pk (UUID): The primary key of the object.
- object_type (str): The object type to get the managed device for.
Raises: - ValidationError: If the object type is not defined. - ValidationError: If the object ID is not defined. - ValidationError: If the object_type is not valid. - ValidationError: If the object is not found. - ValidationError: If the object does not have a primary IP address. - ValidationError: If the object state is not Active.
Source code in nautobot_app_livedata/api/serializers.py
create(validated_data)
¶
update(instance, validated_data)
¶
validate(attrs)
¶
Validate the object type and the device/interface ID.
Source code in nautobot_app_livedata/api/serializers.py
urls
¶
Nautobot App Livedata API URLs.
views
¶
Views for the Livedata API.
LivedataPrimaryDeviceApiView
¶
Bases: ObjectPermissionRequiredMixin
, GenericAPIView
Nautobot App Livedata API Primary Device view.
For more information on implementing jobs, refer to the Nautobot job documentation: https://docs.nautobot.com/projects/core/en/stable/development/jobs/
Source code in nautobot_app_livedata/api/views.py
get(request, *args, pk=None, object_type=None, **kwargs)
¶
Handle GET request for Livedata Primary Device API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
HttpRequest
|
The request object. |
required |
pk
|
Optional[int]
|
The primary key of the object. |
None
|
object_type
|
str
|
The object type. |
None
|
*args
|
Any
|
Additional positional arguments. |
()
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Response |
Response
|
The response object. "application/json" data = { "object_type": "The object type to get the primary device for", "pk": "The primary key", "device": "The device ID of the device that is referred in object_type", "interface": "The interface ID if the object type is 'dcim.interface'", "virtual_chassis": "The virtual chassis ID if the object type is 'dcim.virtualchassis'", "primary_device": "The primary device ID" } |
Raises:
Type | Description |
---|---|
Response
|
If the user does not have permission to execute 'livedata' on an interface. |
Response
|
If the serializer is not valid. |
Response
|
If the primary device is not found. |
Source code in nautobot_app_livedata/api/views.py
get_required_permission()
¶
Get the required permission for the view.
Format: app_label.action_model
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The permission required to access the view. |
LivedataQueryApiView
¶
Bases: ObjectPermissionRequiredMixin
, GenericAPIView
, ABC
Abstract Livedata Query API view.
Source code in nautobot_app_livedata/api/views.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
get(request, *args, pk=None, **kwargs)
¶
Handle GET request for Livedata Query API.
The get method is used to enqueue the Livedata Query Job.
To access the JobResult object, use the jobresult_id returned in the response and make a GET request to the JobResult endpoint.
For Example
GET /api/extras/job-results/{jobresult_id}/
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
The request object. |
required |
pk
|
uuid
|
The primary key of the model instance. |
None
|
*args
|
Any
|
Additional positional arguments. |
()
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
jobresult_id |
Response
|
The job result ID of the job that was enqueued. |
Raises:
Type | Description |
---|---|
Response
|
If the user does not have permission to execute 'livedata' on the instance. |
Response
|
If the serializer is not valid. |
Response
|
If the job Livedata Api-Job is not found. |
Response
|
If the job failed to run. |
Source code in nautobot_app_livedata/api/views.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
get_commands(instance)
abstractmethod
¶
Get the commands to be executed for the given instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance
|
Model
|
The model instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The commands to be executed. |
get_object_type()
abstractmethod
¶
get_required_permission()
¶
Get the required permission for the view.
Format: app_label.action_model
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The permission required to access the view. |
LivedataQueryDeviceApiView
¶
Bases: LivedataQueryApiView
Livedata Query Device API view.
Source code in nautobot_app_livedata/api/views.py
get_commands(instance)
¶
Get the commands to be executed for the given device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance
|
Device
|
The device instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The commands to be executed. |
Source code in nautobot_app_livedata/api/views.py
get_object_type()
¶
LivedataQueryInterfaceApiView
¶
Bases: LivedataQueryApiView
Livedata Query Interface API view.
Source code in nautobot_app_livedata/api/views.py
get_commands(instance)
¶
Get the commands to be executed for the given interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance
|
Interface
|
The interface instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The commands to be executed. |