forked from Xandyhoss/blockbank-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtryout.sh
executable file
·182 lines (161 loc) · 4.14 KB
/
tryout.sh
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
#!/usr/bin/env bash
if [ $# -lt 1 ] ; then
HOST="localhost"
else
HOST=$1
fi
CCAPI_ORG1_PORT=80
CCAPI_ORG2_PORT=980
CCAPI_ORG3_PORT=1080
if [[ $(docker container ls -f name=ccapi.org --format '{{.Names}}') == "ccapi.org.example.com" ]]
then
CCAPI_ORG2_PORT=80
CCAPI_ORG3_PORT=80
fi
printf "Sending requests to ${HOST}"
printf '\n\nGet Header\n';
curl -k \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/getHeader" \
-H 'cache-control: no-cache'
printf '\n\nGet Transactions\n';
curl -k \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/getTx" \
-H 'cache-control: no-cache'
printf '\n\nGet CreateAsset definition\n';
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/getTx" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"txName": "createAsset"
}'
printf '\n\nGet Asset Types\n';
curl -k \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/getSchema" \
-H 'cache-control: no-cache'
printf '\n\nGet person schema\n';
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/getSchema" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"assetType": "person"
}'
printf '\n\nCreate person\n'
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/invoke/createAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"asset": [
{
"@assetType": "person",
"name": "Maria",
"id": "318.207.920-48"
}
]
}'
printf '\n\nCreate book\n'
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG2_PORT}/api/gateway/invoke/createAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"asset": [
{
"@assetType": "book",
"title": "Meu Nome é Maria",
"author": "Maria Viana",
"currentTenant": {
"id": "318.207.920-48"
},
"genres": ["biography", "non-fiction"],
"published": "2019-05-06T22:12:41Z"
}
]
}'
printf '\n\nRead book\n';
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/readAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"key": {
"@assetType": "book",
"author": "Maria Viana",
"title": "Meu Nome é Maria"
},
"resolve": true
}'
printf '\n\nUpdate person\n'
curl -k -X PUT \
"http://${HOST}/api/gateway/invoke/updateAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"update": {
"@assetType": "person",
"id": "318.207.920-48",
"name": "Maria",
"readerScore": 75
}
}'
printf '\n\nRead person to check if it was updated\n';
curl -k -X POST \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/query/readAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"key": {
"@assetType": "person",
"id": "318.207.920-48"
}
}'
printf '\n\nQuery all books using couchdb queries\n';
curl -k -X POST \
"http://${HOST}/api/gateway/query/search" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"query": {
"selector": {
"@assetType": "book"
}
},
"resolve": true
}'
printf '\n\nDelete book\n'
curl -k -X DELETE \
"http://${HOST}:${CCAPI_ORG2_PORT}/api/gateway/invoke/deleteAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"key": {
"@assetType": "book",
"title": "Meu Nome é Maria",
"author": "Maria Viana"
}
}'
printf '\n\nDelete person\n'
curl -k -X DELETE \
"http://${HOST}:${CCAPI_ORG1_PORT}/api/gateway/invoke/deleteAsset" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"key": {
"@assetType": "person",
"id": "318.207.920-48"
}
}'
printf '\n\nRead person History\n';
curl -k \
"http://${HOST}/api/gateway/query/readAssetHistory" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"key": {
"@assetType": "person",
"id": "318.207.920-48"
}
}'
printf '\n'