Update Projection Definition

put
Update projection definition

https://api.serialized.io/projections/definitions/{projectionName}
Update projection definition
Request
Response
Request
Headers
Serialized-Access-Key
required
string
Serialized access key
Serialized-Secret-Access-Key
required
string
Serialized secret key
Body Parameters
signingSecret
optional
string
Secret used in HMAC signing of outgoing request to custom projection function.
aggregated
optional
boolean
If true, creates an aggregated Projection. Default: false
idField
optional
string
Field in the Projection to use as id field in queries. Defaults to the aggregate id.
projectionName
required
string
Name of the projection type
feedName
required
string
Name of the feed
handlers
required
array
Handlers for the reaction. See examples below.
Response
200: OK
Projection definition successfully updated
422: Unprocessable Entity
Invalid request body
cURL
Java
C#
Node
cURL
curl -i https://api.serialized.io/projections/definitions/orders \
--header "Content-Type: application/json" \
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
-X PUT \
--data '
{
"projectionName": "orders",
"feedName": "order",
"handlers": [
{
"eventType": "OrderPlacedEvent",
"functions": [
{
"function": "set",
"targetSelector": "$.projection.status",
"rawData": "PLACED"
},
{
"function": "set",
"targetSelector": "$.projection.orderAmount",
"eventSelector": "$.event.orderAmount"
}
]
}
]
}
'
Java
import com.google.common.collect.ImmutableMap;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
Client client = ClientBuilder.newClient();
URI apiRoot = URI.create("https://api.serialized.io");
Map<String, Object> projectionDefinition = ImmutableMap.of(
"projectionName", "orders",
"feedName", "order",
"handlers", ImmutableList.of(
ImmutableMap.of(
"eventType", "OrderPlacedEvent",
"functions", ImmutableList.of(
ImmutableMap.of(
"function", "set",
"targetSelector", "$.projection.status",
"rawData", "PLACED"
),
ImmutableMap.of(
"function", "set",
"targetSelector", "$.projection.orderAmount",
"eventSelector", "$.event.orderAmount"
)
)
)
)
);
Response response = client.target(apiRoot)
.path("projections")
.path("definitions")
.path("orders")
.request()
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
.put(Entity.json(projectionDefinition));
C#
using System;
using System.Collections.Generic;
using RestSharp;
var definition = new Dictionary<string, Object>
{
{ "projectionName", "orders" },
{ "feedName", "order" },
{ "handlers", new List<Dictionary<string, Object>>
{
new Dictionary<string, Object>
{
{"eventType", "OrderPlacedEvent"},
{"functions", new List<Dictionary<string, Object>>
{
new Dictionary<string, Object>
{
{"function", "set"},
{"targetSelector", "$.projection.status"},
{ "rawData", "PLACED"}
},
new Dictionary<string, Object>
{
{"function", "set"},
{"targetSelector", "$.projection.orderAmount"},
{ "eventSelector", "$.event.orderAmount"}
}
}
}
}
}
}
};
var request = new RestRequest("projections/definitions/{projectionName}", Method.PUT)
.AddUrlSegment("projectionName", "orders")
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>");
.AddJsonBody(definition);
var response = client.Execute(request);
Node
const axios = require("axios");
const client = axios.create({
baseURL: "https://api.serialized.io",
headers: {"Serialized-Access-Key": "<YOUR_ACCESS_KEY>"},
headers: {"Serialized-Secret-Access-Key": "<YOUR_SECRET_ACCESS_KEY>"}
});
const definition = {
projectionName: "orders",
feedName: "order",
handlers: [
{
eventType: "OrderPlacedEvent",
functions: [
{
"function": "set",
"targetSelector": "$.projection.status",
"rawData": "PLACED"
},
{
"function": "set",
"targetSelector": "$.projection.orderAmount",
"eventSelector": "$.event.orderAmount"
}
]
}
]
};
client.put("projections/definitions/orders", definition)
.then(function (response) {
// Handle response
})
.catch(function (error) {
// Handle error
});