-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_accessions.json
221 lines (221 loc) · 5.99 KB
/
update_accessions.json
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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
{
"info": {
"_postman_id": "226be18f-2d78-40ef-af6a-a756dd939c4f",
"name": "update_accession",
"description": "A demonstration collection which appends something to the Content Description field in an Accession record. This collection does not overwrite the existing description field, new content is added to the end.\n\nYou must have an active ArchivesSpace session saved as an environment variable for this collection to work. Run create_aspace_session first to set this up.",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "search_accessions",
"event": [
{
"listen": "test",
"script": {
"id": "5c67a543-a5ff-4925-88bb-68c196922a8b",
"exec": [
"var jsonObject = pm.response.json()\r",
"\r",
"pm.environment.set(\"accession_uri\", jsonObject.results[0].uri)"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"id": "f7f83e48-cbfb-4bd2-bfa6-1cbc082476e0",
"exec": [
"//Spreadsheet search variable block: \r",
"// var i = pm.iterationData.get(\"identifier\")\r",
"// var t = pm.iterationData.get(\"title\")\r",
"\r",
"//Testing search variable block:\r",
"var i = \"88-62-M-Up 496\"\r",
"var t = \"Ellis Fuller Lawrence papers\"\r",
"\r",
"//A log to the console so you can see the search string passed:\r",
"console.log (\"@@@\" + i + \" \" + t)\r",
"\r",
"////This sets the search term to be run:\r",
"pm.variables.set(\"search_term\", i + \" \" + t)"
],
"type": "text/javascript"
}
}
],
"id": "8042a5ec-3de4-46f4-88e0-7aec2c9756d5",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"description": "Archives Space session ID",
"key": "X-ArchivesSpace-Session",
"type": "text",
"value": "{{aspace_session}}"
}
],
"url": {
"raw": "{{aspace_base_url}}/repositories/2/search?q={{search_term}}&page=1&page_size=2&type[]=accession",
"host": [
"{{aspace_base_url}}"
],
"path": [
"repositories",
"2",
"search"
],
"query": [
{
"key": "q",
"value": "{{search_term}}"
},
{
"key": "page",
"value": "1"
},
{
"key": "page_size",
"value": "2"
},
{
"key": "type[]",
"value": "accession"
}
]
}
},
"response": []
},
{
"name": "accession_record",
"event": [
{
"listen": "test",
"script": {
"id": "8405b430-1255-409d-9897-a308f730808c",
"exec": [
"var jsonObject = pm.response.json()\r",
"\r",
"//This saves the entire accession record so it can be updated in the next step\r",
"pm.environment.set (\"accession_body\", JSON.stringify(jsonObject))"
],
"type": "text/javascript"
}
}
],
"id": "09630899-a7b6-45e5-8f07-6d4830061c3c",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"description": "Archives Space session ID",
"key": "X-ArchivesSpace-Session",
"type": "text",
"value": "{{aspace_session}}"
}
],
"url": "{{aspace_base_url}}{{accession_uri}}"
},
"response": []
},
{
"name": "update_to_accession",
"event": [
{
"listen": "prerequest",
"script": {
"id": "163a8741-df54-489b-82da-777987bba4d8",
"exec": [
"var a_body = JSON.parse(pm.environment.get(\"accession_body\"));\r",
"\r",
"//Spreadsheet variable:\r",
"//var n = pm.iterationData.get(\"new_thing\")\r",
"\r",
"//Testing variable:\r",
"var n = \"test\"\r",
"\r",
"var conDescr = a_body.content_description\r",
"console.log(\"@@\" + conDescr)\r",
"\r",
"var new_con = conDescr + \" \" + n\r",
"console.log(\"@@\" + new_con)\r",
"\r",
"a_body.content_description = new_con\r",
"\r",
"//If you uncomment this line, it will log the entire accession record to the console. Useful for debugging\r",
"//console.log (a_body)\r",
"\r",
"pm.variables.set(\"accession_body\", JSON.stringify(a_body));"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "e98133ca-6357-4433-a0c2-a1fdec2d6506",
"exec": [
"//This gets the response from Postman that you see in the Response area after you hit send\r",
"var jsonObject = pm.response.json()\r",
"\r",
"//This tests whether the API returns a status code in the 200s, which means good (unlike 404 not found or things like that)\r",
"pm.test(\"Status code is 200\", function () {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"//This logs the uri and status returned by ArchivesSpace. If run as a GET, the status will be \"undefined\". A successful POST should return a status of \"Updated\"\r",
"console.log (\"@@@@\" + jsonObject.uri + \" \" + jsonObject.status)"
],
"type": "text/javascript"
}
}
],
"id": "3d20173a-91a0-4d9c-a2f6-bf3b4ad51624",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"description": "Archives Space session ID",
"key": "X-ArchivesSpace-Session",
"type": "text",
"value": "{{aspace_session}}"
}
],
"body": {
"mode": "raw",
"raw": "{{accession_body}}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{aspace_base_url}}{{accession_uri}}",
"host": [
"{{aspace_base_url}}{{accession_uri}}"
],
"query": [
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
]
}
},
"response": []
}
]
}