Skip to content

Commit 957c4a3

Browse files
committed
[chores] Changed device_pk to device_id for consistency with docs
The URL params appear in the API docs and in the unified docs too, but the format used was different and inconsistent.
1 parent eeb8abb commit 957c4a3

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

openwisp_controller/connection/api/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ def get_api_urls(api_views):
1111
"""
1212
return [
1313
path(
14-
'api/v1/controller/device/<uuid:device_pk>/command/',
14+
'api/v1/controller/device/<uuid:device_id>/command/',
1515
api_views.command_list_create_view,
1616
name='device_command_list',
1717
),
1818
path(
19-
'api/v1/controller/device/<uuid:device_pk>/command/<uuid:pk>/',
19+
'api/v1/controller/device/<uuid:device_id>/command/<uuid:pk>/',
2020
api_views.command_details_view,
2121
name='device_command_details',
2222
),
@@ -31,12 +31,12 @@ def get_api_urls(api_views):
3131
name='credential_detail',
3232
),
3333
path(
34-
'api/v1/controller/device/<uuid:device_pk>/connection/',
34+
'api/v1/controller/device/<uuid:device_id>/connection/',
3535
api_views.deviceconnection_list_create_view,
3636
name='deviceconnection_list',
3737
),
3838
path(
39-
'api/v1/controller/device/<uuid:device_pk>/connection/<uuid:pk>/',
39+
'api/v1/controller/device/<uuid:device_id>/connection/<uuid:pk>/',
4040
api_views.deviceconnection_details_view,
4141
name='deviceconnection_detail',
4242
),

openwisp_controller/connection/api/views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ def get_permissions(self):
4949

5050
def get_parent_queryset(self):
5151
return Device.objects.filter(
52-
pk=self.kwargs['device_pk'],
52+
pk=self.kwargs['device_id'],
5353
)
5454

5555
def get_queryset(self):
56-
return super().get_queryset().filter(device_id=self.kwargs['device_pk'])
56+
return super().get_queryset().filter(device_id=self.kwargs['device_id'])
5757

5858
def get_serializer_context(self):
5959
context = super().get_serializer_context()
60-
context['device_id'] = self.kwargs['device_pk']
60+
context['device_id'] = self.kwargs['device_id']
6161
return context
6262

6363

@@ -101,7 +101,7 @@ def get_queryset(self):
101101

102102
def get_serializer_context(self):
103103
context = super().get_serializer_context()
104-
context['device_id'] = self.kwargs['device_pk']
104+
context['device_id'] = self.kwargs['device_id']
105105
return context
106106

107107
def initial(self, *args, **kwargs):
@@ -112,11 +112,11 @@ def assert_parent_exists(self):
112112
try:
113113
assert self.get_parent_queryset().exists()
114114
except (AssertionError, ValidationError):
115-
device_id = self.kwargs['device_pk']
115+
device_id = self.kwargs['device_id']
116116
raise NotFound(detail=f'Device with ID "{device_id}" not found.')
117117

118118
def get_parent_queryset(self):
119-
return Device.objects.filter(pk=self.kwargs['device_pk'])
119+
return Device.objects.filter(pk=self.kwargs['device_id'])
120120

121121

122122
class DeviceConnenctionListCreateView(BaseDeviceConnection, ListCreateAPIView):
@@ -126,7 +126,7 @@ def get_queryset(self):
126126
return (
127127
super()
128128
.get_queryset()
129-
.filter(device_id=self.kwargs['device_pk'])
129+
.filter(device_id=self.kwargs['device_id'])
130130
.order_by('-created')
131131
)
132132

openwisp_controller/connection/apps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def command_save_receiver(cls, sender, created, instance, **kwargs):
8181
)
8282

8383
@classmethod
84-
def _launch_update_config(cls, device_pk):
84+
def _launch_update_config(cls, device_id):
8585
"""
8686
Calls the background task update_config only if
8787
no other tasks are running for the same device
8888
"""
8989
from .tasks import update_config
9090

91-
update_config.delay(device_pk)
91+
update_config.delay(device_id)
9292

9393
@classmethod
9494
def is_working_changed_receiver(

openwisp_controller/connection/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
_TASK_NAME = 'openwisp_controller.connection.tasks.update_config'
1616

1717

18-
def _is_update_in_progress(device_pk):
18+
def _is_update_in_progress(device_id):
1919
active = current_app.control.inspect().active()
2020
if not active:
2121
return False
2222
# check if there's any other running task before adding it
2323
for task_list in active.values():
2424
for task in task_list:
25-
if task['name'] == _TASK_NAME and str(device_pk) in task['args']:
25+
if task['name'] == _TASK_NAME and str(device_id) in task['args']:
2626
return True
2727
return False
2828

0 commit comments

Comments
 (0)