-
Notifications
You must be signed in to change notification settings - Fork 0
/
02 CURL CRUD.bat
63 lines (55 loc) · 2.07 KB
/
02 CURL CRUD.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@echo on
@set SITE=http://localhost:8080/company
@set CURL=c:\tools\curl-7.58.0\bin\curl.exe
@set CURL=%CURL% -g -i -H "Accept: application/hal+json" -H "Content-Type: application/hal+json"
@set HR_YELLOW=@powershell -Command Write-Host "----------------------------------------------------------------------" -foreground "Yellow"
@set HR_RED=@powershell -Command Write-Host "----------------------------------------------------------------------" -foreground "Red"
@set DEP_ID=12345
@set EMP_ID=67890
:create
%HR_YELLOW%
@powershell -Command Write-Host "CREATE" -foreground "Green"
%CURL% -d {\"id\":%DEP_ID%,\"name\":\"D-Name-CREATE\"} -X POST "%SITE%/departments"
@echo.
%CURL% -d {\"id\":%EMP_ID%,\"firstName\":\"EF-Name-CREATE\",\"lastName\":\"EL-Name-CREATE\",\"department\":{\"id\":%DEP_ID%}} -X POST "%SITE%/employees"
@echo.
:read-created
%HR_YELLOW%
@powershell -Command Write-Host "READ by id - after CREATE" -foreground "Green"
%CURL% "%SITE%/departments/%DEP_ID%"
@echo.
%CURL% "%SITE%/employees/%EMP_ID%"
@echo.&pause
:update
%HR_YELLOW%
@powershell -Command Write-Host "UPDATE by id" -foreground "Green"
%CURL% -d {\"name\":\"D-Name-UPDATE\"} -X PATCH "%SITE%/departments/%DEP_ID%"
@echo.
%CURL% -d {\"firstName\":\"EF-Name-UPDATE\",\"lastName\":\"EL-Name-UPDATE\",\"department\":{\"id\":%DEP_ID%}} -X PATCH "%SITE%/employees/%EMP_ID%"
@echo.
:read-updated
%HR_YELLOW%
@powershell -Command Write-Host "READ by id - after UPDATE" -foreground "Green"
%CURL% "%SITE%/departments/%DEP_ID%"
@echo.
%CURL% "%SITE%/employees/%EMP_ID%"
@echo.&pause
::goto :read-deleted
:delete
%HR_YELLOW%
@powershell -Command Write-Host "DELETE by id" -foreground "Green"
%CURL% -X DELETE "%SITE%/departments/%DEP_ID%"
@echo.
%CURL% -X DELETE "%SITE%/employees/%EMP_ID%"
@echo.
:read-deleted
%HR_YELLOW%
@powershell -Command Write-Host "READ by id - after DELETE" -foreground "Green"
%CURL% "%SITE%/departments/%DEP_ID%"
@echo.
%CURL% "%SITE%/employees/%EMP_ID%"
@echo.&pause
:finish
%HR_RED%
@powershell -Command Write-Host "FINISH" -foreground "Red"
pause