Skip to content

Commit aa68fc6

Browse files
committed
Add sync to DNS records
1 parent 47f221e commit aa68fc6

27 files changed

+837
-495
lines changed

app/Http/Controllers/API/DNSRecordController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ public function destroy(Project $project, Domain $domain, DNSRecord $dnsRecord):
8686
return response()->json(['message' => 'DNS record deleted successfully']);
8787
}
8888

89+
#[Post('/sync', name: 'api.dns-records.sync', middleware: 'ability:write')]
90+
public function sync(Project $project, Domain $domain): JsonResponse
91+
{
92+
$this->authorize('update', $domain);
93+
$this->validateRoute($project, $domain);
94+
95+
$domain->syncDnsRecords();
96+
97+
return response()->json(['message' => 'DNS records synced successfully']);
98+
}
99+
89100
private function validateRoute(Project $project, Domain $domain): void
90101
{
91102
if ($project->id !== $domain->project_id) {

app/Http/Controllers/DNSRecordController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ public function destroy(Domain $domain, DNSRecord $dnsRecord): RedirectResponse
8080

8181
return back()->with('success', 'DNS record deleted.');
8282
}
83+
84+
#[Post('/sync', name: 'dns-records.sync')]
85+
public function sync(Domain $domain): RedirectResponse
86+
{
87+
$this->authorize('update', $domain);
88+
89+
$domain->syncDnsRecords();
90+
91+
return back()->with('success', 'DNS records synced successfully.');
92+
}
8393
}

public/api-docs/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
tryItOutEnabled: true,
5050
requestInterceptor: (request) => {
5151
// Add any custom request headers if needed
52+
delete request.headers['accept']
53+
delete request.headers['Accept']
54+
request.headers["Accept"] = "application/json";
5255
return request;
5356
}
5457
});

public/api-docs/openapi/cronjobs.yaml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ paths:
2929
application/json:
3030
schema:
3131
allOf:
32-
- $ref: './openapi/schemas/PaginatedResponse.yaml'
32+
- $ref: '/api-docs/openapi/schemas/PaginatedResponse.yaml'
3333
- type: object
3434
properties:
3535
data:
3636
type: array
3737
items:
38-
$ref: './openapi/schemas/CronJob.yaml'
38+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
3939
example:
4040
data:
4141
- id: 1
@@ -65,19 +65,19 @@ paths:
6565
content:
6666
application/json:
6767
schema:
68-
$ref: './openapi/schemas/ErrorResponse.yaml'
68+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
6969
'403':
7070
description: Forbidden
7171
content:
7272
application/json:
7373
schema:
74-
$ref: './openapi/schemas/ErrorResponse.yaml'
74+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
7575
'404':
7676
description: Project or server not found
7777
content:
7878
application/json:
7979
schema:
80-
$ref: './openapi/schemas/ErrorResponse.yaml'
80+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
8181

8282
post:
8383
summary: Create cron job
@@ -140,31 +140,31 @@ paths:
140140
content:
141141
application/json:
142142
schema:
143-
$ref: './openapi/schemas/CronJob.yaml'
143+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
144144
'401':
145145
description: Unauthorized
146146
content:
147147
application/json:
148148
schema:
149-
$ref: './openapi/schemas/ErrorResponse.yaml'
149+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
150150
'403':
151151
description: Forbidden
152152
content:
153153
application/json:
154154
schema:
155-
$ref: './openapi/schemas/ErrorResponse.yaml'
155+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
156156
'404':
157157
description: Project or server not found
158158
content:
159159
application/json:
160160
schema:
161-
$ref: './openapi/schemas/ErrorResponse.yaml'
161+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
162162
'422':
163163
description: Validation error
164164
content:
165165
application/json:
166166
schema:
167-
$ref: './openapi/schemas/ValidationError.yaml'
167+
$ref: '/api-docs/openapi/schemas/ValidationError.yaml'
168168

169169
/api/projects/{project}/servers/{server}/cron-jobs/{cronJob}:
170170
get:
@@ -202,25 +202,25 @@ paths:
202202
content:
203203
application/json:
204204
schema:
205-
$ref: './openapi/schemas/CronJob.yaml'
205+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
206206
'401':
207207
description: Unauthorized
208208
content:
209209
application/json:
210210
schema:
211-
$ref: './openapi/schemas/ErrorResponse.yaml'
211+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
212212
'403':
213213
description: Forbidden
214214
content:
215215
application/json:
216216
schema:
217-
$ref: './openapi/schemas/ErrorResponse.yaml'
217+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
218218
'404':
219219
description: Cron job not found
220220
content:
221221
application/json:
222222
schema:
223-
$ref: './openapi/schemas/ErrorResponse.yaml'
223+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
224224

225225
delete:
226226
summary: Delete cron job
@@ -259,19 +259,19 @@ paths:
259259
content:
260260
application/json:
261261
schema:
262-
$ref: './openapi/schemas/ErrorResponse.yaml'
262+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
263263
'403':
264264
description: Forbidden
265265
content:
266266
application/json:
267267
schema:
268-
$ref: './openapi/schemas/ErrorResponse.yaml'
268+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
269269
'404':
270270
description: Cron job not found
271271
content:
272272
application/json:
273273
schema:
274-
$ref: './openapi/schemas/ErrorResponse.yaml'
274+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
275275

276276
/api/projects/{project}/servers/{server}/cron-jobs/sites/{site}/cron-jobs:
277277
get:
@@ -310,31 +310,31 @@ paths:
310310
application/json:
311311
schema:
312312
allOf:
313-
- $ref: './openapi/schemas/PaginatedResponse.yaml'
313+
- $ref: '/api-docs/openapi/schemas/PaginatedResponse.yaml'
314314
- type: object
315315
properties:
316316
data:
317317
type: array
318318
items:
319-
$ref: './openapi/schemas/CronJob.yaml'
319+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
320320
'401':
321321
description: Unauthorized
322322
content:
323323
application/json:
324324
schema:
325-
$ref: './openapi/schemas/ErrorResponse.yaml'
325+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
326326
'403':
327327
description: Forbidden
328328
content:
329329
application/json:
330330
schema:
331-
$ref: './openapi/schemas/ErrorResponse.yaml'
331+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
332332
'404':
333333
description: Project, server, or site not found
334334
content:
335335
application/json:
336336
schema:
337-
$ref: './openapi/schemas/ErrorResponse.yaml'
337+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
338338

339339
post:
340340
summary: Create site cron job
@@ -398,31 +398,31 @@ paths:
398398
content:
399399
application/json:
400400
schema:
401-
$ref: './openapi/schemas/CronJob.yaml'
401+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
402402
'401':
403403
description: Unauthorized
404404
content:
405405
application/json:
406406
schema:
407-
$ref: './openapi/schemas/ErrorResponse.yaml'
407+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
408408
'403':
409409
description: Forbidden
410410
content:
411411
application/json:
412412
schema:
413-
$ref: './openapi/schemas/ErrorResponse.yaml'
413+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
414414
'404':
415415
description: Project, server, or site not found
416416
content:
417417
application/json:
418418
schema:
419-
$ref: './openapi/schemas/ErrorResponse.yaml'
419+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
420420
'422':
421421
description: Validation error
422422
content:
423423
application/json:
424424
schema:
425-
$ref: './openapi/schemas/ValidationError.yaml'
425+
$ref: '/api-docs/openapi/schemas/ValidationError.yaml'
426426

427427
/api/projects/{project}/servers/{server}/cron-jobs/sites/{site}/cron-jobs/{cronJob}:
428428
get:
@@ -467,25 +467,25 @@ paths:
467467
content:
468468
application/json:
469469
schema:
470-
$ref: './openapi/schemas/CronJob.yaml'
470+
$ref: '/api-docs/openapi/schemas/CronJob.yaml'
471471
'401':
472472
description: Unauthorized
473473
content:
474474
application/json:
475475
schema:
476-
$ref: './openapi/schemas/ErrorResponse.yaml'
476+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
477477
'403':
478478
description: Forbidden
479479
content:
480480
application/json:
481481
schema:
482-
$ref: './openapi/schemas/ErrorResponse.yaml'
482+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
483483
'404':
484484
description: Cron job not found
485485
content:
486486
application/json:
487487
schema:
488-
$ref: './openapi/schemas/ErrorResponse.yaml'
488+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
489489

490490
delete:
491491
summary: Delete site cron job
@@ -531,17 +531,17 @@ paths:
531531
content:
532532
application/json:
533533
schema:
534-
$ref: './openapi/schemas/ErrorResponse.yaml'
534+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
535535
'403':
536536
description: Forbidden
537537
content:
538538
application/json:
539539
schema:
540-
$ref: './openapi/schemas/ErrorResponse.yaml'
540+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
541541
'404':
542542
description: Cron job not found
543543
content:
544544
application/json:
545545
schema:
546-
$ref: './openapi/schemas/ErrorResponse.yaml'
546+
$ref: '/api-docs/openapi/schemas/ErrorResponse.yaml'
547547

0 commit comments

Comments
 (0)