Skip to content

Commit 333c02b

Browse files
zubeydecivelekzzacharo
authored andcommitted
Add Bruno Collection for REST API's
1 parent ec9b0d6 commit 333c02b

File tree

2 files changed

+447
-45
lines changed

2 files changed

+447
-45
lines changed
Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
{
2+
"name": "CDS Videos Publish Video",
3+
"version": "1",
4+
"items": [
5+
{
6+
"type": "http",
7+
"name": "Optional Change access of the video",
8+
"seq": 8,
9+
"request": {
10+
"url": "{{baseURl}}/api/deposits/video/{{video_id}}",
11+
"method": "PUT",
12+
"headers": [
13+
{
14+
"name": "content-type",
15+
"value": "application/vnd.video.partial+json",
16+
"enabled": true
17+
}
18+
],
19+
"params": [],
20+
"body": {
21+
"mode": "json",
22+
"json": "{\n \"_access\": {\n \"update\": [\n \"[email protected]\",\n \"[email protected]\" //Update the access according to category\n ],\n // If you want to restrict the video, update access read\n \"read\": [\n \"[email protected]\"\n ]\n\n }\n}\n\n",
23+
"formUrlEncoded": [],
24+
"multipartForm": []
25+
},
26+
"script": {},
27+
"vars": {},
28+
"assertions": [],
29+
"tests": "",
30+
"auth": {
31+
"mode": "inherit"
32+
}
33+
}
34+
},
35+
{
36+
"type": "http",
37+
"name": "Get project to check the flow is finished",
38+
"seq": 5,
39+
"request": {
40+
"url": "{{baseURl}}/api/deposits/project/{{project_id}}",
41+
"method": "GET",
42+
"headers": [
43+
{
44+
"name": "content-type",
45+
"value": "application/vnd.project.partial+json",
46+
"enabled": true
47+
}
48+
],
49+
"params": [],
50+
"body": {
51+
"mode": "json",
52+
"json": "",
53+
"formUrlEncoded": [],
54+
"multipartForm": []
55+
},
56+
"script": {},
57+
"vars": {},
58+
"assertions": [],
59+
"tests": "",
60+
"auth": {
61+
"mode": "inherit"
62+
}
63+
}
64+
},
65+
{
66+
"type": "http",
67+
"name": "Step 1- Create a project",
68+
"seq": 1,
69+
"request": {
70+
"url": "{{baseURl}}/api/deposits/project/",
71+
"method": "POST",
72+
"headers": [
73+
{
74+
"name": "content-type",
75+
"value": "application/vnd.project.partial+json",
76+
"enabled": true
77+
}
78+
],
79+
"params": [],
80+
"body": {
81+
"mode": "json",
82+
"json": "{\n \"$schema\": \"https://localhost:5000/schemas/deposits/records/videos/project/project-v1.0.0.json\",\n \"_access\": {\n \"update\": [\n \"[email protected]\",\n \"[email protected]\"\n ],\n \"read\": [ // If you want to restrict the project, add access read\n \"[email protected]\"\n ]\n },\n // Add category and type\n \"category\": \"ATLAS\",\n \"type\": \"VIDEO\"\n}",
83+
"formUrlEncoded": [],
84+
"multipartForm": []
85+
},
86+
"script": {
87+
"res": "let data = res.body ;\nbru.setEnvVar(\"project_id\", data.id);"
88+
},
89+
"vars": {},
90+
"assertions": [],
91+
"tests": "",
92+
"auth": {
93+
"mode": "inherit"
94+
}
95+
}
96+
},
97+
{
98+
"type": "http",
99+
"name": "Step 2- Create a video",
100+
"seq": 2,
101+
"request": {
102+
"url": "{{baseURl}}/api/deposits/video/",
103+
"method": "POST",
104+
"headers": [
105+
{
106+
"name": "content-type",
107+
"value": "application/vnd.video.partial+json",
108+
"enabled": true
109+
}
110+
],
111+
"params": [],
112+
"body": {
113+
"mode": "json",
114+
"json": "{\n \"$schema\":\"https://localhost:5000/schemas/deposits/records/videos/video/video-v1.0.0.json\",\n \"_project_id\":\"{{project_id}}\",\n \"title\":\n {\n \"title\":\"217490_medium\"\n },\n\n \"vr\": false,\n \"featured\": false,\n \"language\": \"en\",\n \"contributors\": [\n {\n \"name\": \"Civelek, Zubeyde\",\n \"ids\": [\n {\n \"value\": \"868056\",\n \"source\": \"cern\"\n }\n ],\n \"email\": \"[email protected]\",\n \"role\": \"Co-Producer\"\n }\n ],\n \"description\": \"Description\",\n \"date\": \"2024-11-12\"\n}",
115+
"formUrlEncoded": [],
116+
"multipartForm": []
117+
},
118+
"script": {
119+
"res": "let data = res.body ;\nbru.setEnvVar(\"video_id\", data.id);\nbru.setEnvVar(\"bucket_id\", data.metadata._buckets.deposit);\n"
120+
},
121+
"vars": {},
122+
"assertions": [],
123+
"tests": "",
124+
"auth": {
125+
"mode": "inherit"
126+
}
127+
}
128+
},
129+
{
130+
"type": "http",
131+
"name": "Step 3- Upload the video",
132+
"seq": 3,
133+
"request": {
134+
"url": "{{baseURl}}/api/files/{{bucket_id}}/{{video_name}}",
135+
"method": "PUT",
136+
"headers": [
137+
{
138+
"name": "content-type",
139+
"value": "video/mp4",
140+
"enabled": true
141+
},
142+
{
143+
"name": "Accept",
144+
"value": "application/json, text/plain, */*",
145+
"enabled": true
146+
},
147+
{
148+
"name": "Accept-Encoding",
149+
"value": "gzip, deflate, br, zstd",
150+
"enabled": true
151+
}
152+
],
153+
"params": [],
154+
"body": {
155+
"mode": "formUrlEncoded",
156+
"formUrlEncoded": [],
157+
"multipartForm": [
158+
{
159+
"type": "file",
160+
"name": "",
161+
"value": [
162+
"/Users/zubeydecivelek/Downloads/217490_medium.mp4"
163+
],
164+
"enabled": true
165+
}
166+
]
167+
},
168+
"script": {
169+
"req": "const fs = require('fs');\nconst path = require('path');\n\n// File details\nconst filename = \"CHANGE HERE\";\nconst filePath = \"CHANGE HERE\";\nbru.setEnvVar(\"video_name\",filename);\n\n// Read the file as raw binary data\nconst fileContent = fs.readFileSync(filePath);\n\n// Set request headers\nreq.setHeader(\"Content-Type\", \"video/mp4\"); // File content type\nreq.setHeader(\"Accept\", \"application/json, text/plain, */*\"); \nreq.setHeader(\"Accept-Encoding\", \"gzip, deflate, br, zstd\"); \nreq.setHeader(\"Content-Length\", fileContent.length);\n\n// Attach the file content as the request body\nreq.setBody(fileContent);\n",
170+
"res": "let data = res.body ;\nbru.setEnvVar(\"main_file_version_id\", data.version_id);\nbru.setEnvVar(\"video_key\", data.key);"
171+
},
172+
"vars": {},
173+
"assertions": [],
174+
"tests": "",
175+
"auth": {
176+
"mode": "inherit"
177+
}
178+
}
179+
},
180+
{
181+
"type": "http",
182+
"name": "Step 4- Create a flow",
183+
"seq": 4,
184+
"request": {
185+
"url": "{{baseURl}}/api/flows/",
186+
"method": "POST",
187+
"headers": [
188+
{
189+
"name": "content-type",
190+
"value": "application/vnd.project.partial+json",
191+
"enabled": true
192+
}
193+
],
194+
"params": [],
195+
"body": {
196+
"mode": "json",
197+
"json": "{\n \"version_id\":\"{{main_file_version_id}}\", //response of the put the video 'version_id' \n \"key\": \"{{video_key}}\",//response of the put the video 'key' \n \"bucket_id\":\"{{bucket_id}}\", // create video response \n \"deposit_id\":\"{{video_id}}\" // create video response\n}",
198+
"formUrlEncoded": [],
199+
"multipartForm": []
200+
},
201+
"script": {},
202+
"vars": {},
203+
"assertions": [],
204+
"tests": "",
205+
"auth": {
206+
"mode": "inherit"
207+
}
208+
}
209+
},
210+
{
211+
"type": "http",
212+
"name": "Step 5- Upload additional file",
213+
"seq": 6,
214+
"request": {
215+
"url": "{{baseURl}}/api/files/{{bucket_id}}/{{additional_file}}",
216+
"method": "PUT",
217+
"headers": [],
218+
"params": [],
219+
"body": {
220+
"mode": "json",
221+
"json": "",
222+
"formUrlEncoded": [],
223+
"multipartForm": []
224+
},
225+
"script": {
226+
"req": "const fs = require('fs');\nconst path = require('path');\n\n// File details\nconst filename = \"CHANGE HERE\";\nconst filePath = \"CHANGE HERE\";\nbru.setEnvVar(\"additional_file\", filename);\n\n// Read the file as raw binary data\nconst fileContent = fs.readFileSync(filePath);\n\n// Set request headers\nreq.setHeader(\"Accept\", \"application/json, text/plain, */*\"); \nreq.setHeader(\"Accept-Encoding\", \"gzip, deflate, br, zstd\"); \nreq.setHeader(\"Content-Length\", fileContent.length);\n\n// Attach the file content as the request body\nreq.setBody(fileContent);\n"
227+
},
228+
"vars": {},
229+
"assertions": [],
230+
"tests": "",
231+
"auth": {
232+
"mode": "inherit"
233+
}
234+
}
235+
},
236+
{
237+
"type": "http",
238+
"name": "Step 6- Publish",
239+
"seq": 7,
240+
"request": {
241+
"url": "{{baseURl}}/api/deposits/video/{{video_id}}/actions/publish",
242+
"method": "POST",
243+
"headers": [
244+
{
245+
"name": "content-type",
246+
"value": "application/json",
247+
"enabled": true
248+
}
249+
],
250+
"params": [],
251+
"body": {
252+
"mode": "json",
253+
"json": "",
254+
"formUrlEncoded": [],
255+
"multipartForm": []
256+
},
257+
"script": {},
258+
"vars": {},
259+
"assertions": [],
260+
"tests": "",
261+
"auth": {
262+
"mode": "inherit"
263+
}
264+
}
265+
}
266+
],
267+
"activeEnvironmentUid": "zqLEVCQ0eIhimP48VysTg",
268+
"environments": [
269+
{
270+
"variables": [
271+
{
272+
"name": "baseURl",
273+
"value": "https://localhost:5000/",
274+
"enabled": true,
275+
"secret": false,
276+
"type": "text"
277+
}
278+
],
279+
"name": "Localhost"
280+
}
281+
],
282+
"root": {
283+
"request": {
284+
"auth": {
285+
"mode": "bearer",
286+
"bearer": {
287+
"token": "CHANGE HERE"
288+
}
289+
}
290+
}
291+
},
292+
"brunoConfig": {
293+
"version": "1",
294+
"name": "CDS Videos Publish Video",
295+
"type": "collection",
296+
"scripts": {
297+
"filesystemAccess": {
298+
"allow": true
299+
}
300+
},
301+
"ignore": [
302+
"node_modules",
303+
".git"
304+
]
305+
}
306+
}

0 commit comments

Comments
 (0)