Update Projection Definition
put
https://api.serialized.io
/projections/definitions/{projectionName}
Update projection definition
cURL
Java
C#
Node
1
curl -i https://api.serialized.io/projections/definitions/orders \
2
--header "Content-Type: application/json" \
3
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
4
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
5
-X PUT \
6
--data '
7
{
8
"projectionName": "orders",
9
"feedName": "order",
10
"handlers": [
11
{
12
"eventType": "OrderPlacedEvent",
13
"functions": [
14
{
15
"function": "set",
16
"targetSelector": "$.projection.status",
17
"rawData": "PLACED"
18
},
19
{
20
"function": "set",
21
"targetSelector": "$.projection.orderAmount",
22
"eventSelector": "$.event.orderAmount"
23
}
24
]
25
}
26
]
27
}
28
'
Copied!
1
import com.google.common.collect.ImmutableMap;
2
import javax.ws.rs.client.Client;
3
import javax.ws.rs.client.ClientBuilder;
4
5
Client client = ClientBuilder.newClient();
6
URI apiRoot = URI.create("https://api.serialized.io");
7
8
Map<String, Object> projectionDefinition = ImmutableMap.of(
9
"projectionName", "orders",
10
"feedName", "order",
11
"handlers", ImmutableList.of(
12
ImmutableMap.of(
13
"eventType", "OrderPlacedEvent",
14
"functions", ImmutableList.of(
15
ImmutableMap.of(
16
"function", "set",
17
"targetSelector", "$.projection.status",
18
"rawData", "PLACED"
19
),
20
ImmutableMap.of(
21
"function", "set",
22
"targetSelector", "$.projection.orderAmount",
23
"eventSelector", "$.event.orderAmount"
24
)
25
)
26
27
)
28
)
29
);
30
31
Response response = client.target(apiRoot)
32
.path("projections")
33
.path("definitions")
34
.path("orders")
35
.request()
36
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
37
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
38
.put(Entity.json(projectionDefinition));
Copied!
1
using System;
2
using System.Collections.Generic;
3
using RestSharp;
4
5
var definition = new Dictionary<string, Object>
6
{
7
{ "projectionName", "orders" },
8
{ "feedName", "order" },
9
{ "handlers", new List<Dictionary<string, Object>>
10
{
11
new Dictionary<string, Object>
12
{
13
{"eventType", "OrderPlacedEvent"},
14
{"functions", new List<Dictionary<string, Object>>
15
{
16
new Dictionary<string, Object>
17
{
18
{"function", "set"},
19
{"targetSelector", "$.projection.status"},
20
{ "rawData", "PLACED"}
21
},
22
new Dictionary<string, Object>
23
{
24
{"function", "set"},
25
{"targetSelector", "$.projection.orderAmount"},
26
{ "eventSelector", "$.event.orderAmount"}
27
}
28
}
29
}
30
}
31
}
32
}
33
};
34
35
var request = new RestRequest("projections/definitions/{projectionName}", Method.PUT)
36
.AddUrlSegment("projectionName", "orders")
37
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
38
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>");
39
.AddJsonBody(definition);
40
41
var response = client.Execute(request);
Copied!
1
const axios = require("axios");
2
3
const client = axios.create({
4
baseURL: "https://api.serialized.io",
5
headers: {"Serialized-Access-Key": "<YOUR_ACCESS_KEY>"},
6
headers: {"Serialized-Secret-Access-Key": "<YOUR_SECRET_ACCESS_KEY>"}
7
});
8
9
const definition = {
10
projectionName: "orders",
11
feedName: "order",
12
handlers: [
13
{
14
eventType: "OrderPlacedEvent",
15
functions: [
16
{
17
"function": "set",
18
"targetSelector": "$.projection.status",
19
"rawData": "PLACED"
20
},
21
{
22
"function": "set",
23
"targetSelector": "$.projection.orderAmount",
24
"eventSelector": "$.event.orderAmount"
25
}
26
]
27
}
28
]
29
};
30
31
client.put("projections/definitions/orders", definition)
32
.then(function (response) {
33
// Handle response
34
})
35
.catch(function (error) {
36
// Handle error
37
});
Copied!
Copy link