This method provides equivalent functionality to the
PUTSCRIPT, DELETESCRIPT, RENAMESCRIPT, and SETACTIVE commands
in [RFC5804].¶
If the SieveScript can not be created or updated because it
would result in two SieveScripts with the same name, the
server MUST reject the request with an "alreadyExists"
SetError.
An "existingId" property of type "Id" MUST be included on the
SetError object with the id of the existing SieveScript.¶
If the SieveScript can not be created or updated because
its size exceeds the "maxSizeScript" limit, the server MUST
reject the request with a "tooLarge" SetError.¶
If the SieveScript can not be created because it would
exceed the "maxNumberScripts" limit or would exceed a
server-imposed storage limit, the server MUST
reject the request with an "overQuota" SetError.¶
The active SieveScript MUST NOT be destroyed
unless it is first deactivated in a separate SieveScript/set
method call.¶
Request (and response) to upload a script
requiring the Imap4Flags
[RFC5232]
Extension using the JMAP uploadUrl as advertised in
Section 1.2.2:¶
POST /jmap/upload/ken/ HTTP/1.1
Host: jmap.example.com
Authorization: Basic a2VuOnBhc3N3b3Jk
Content-Type: application/sieve
Content-Length: 98
require "imapflags";
if address :is ["To", "Cc"] "jmap@ietf.org" {
setflag "\\Flagged";
}
HTTP/1.1 201 Created
Date: Thu, 10 Dec 2020 17:14:31 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 171
{
"accountId": "ken",
"blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123",
"type": "application/sieve"
"size": 98
}
¶
Request (and response) to create and activate a script
using the uploaded blob. Note that the response shows
that an existing active script has been deactivated in
lieu of the newly created script being activated.¶
{
"using": [ "urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:sieve" ],
"methodCalls": [
["SieveScript/set", {
"accountId": "ken",
"create": {
"A": {
"name": null,
"blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123"
}
},
"onSuccessActivateScript": "#A"
}, "0"]
]
}
{
"methodResponses": [
[
"SieveScript/set",
{
"oldState": "1603741717.50737918-4096",
"newState": "1603741751.227268529-4096",
"created": {
"A": {
"id": "dd1b164f-8cdc-448c-9f54",
"name": "ken-20201210T171432-0",
"blobId": "Sdd1b164f-8cdc-448c-9f54",
"isActive": true
}
},
"updated": {
"8abd6f4a-bcb4d-87650-3fcd": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"0"
]
]
}
¶
Request (and response) to update script content using
the JMAP Blob management extension [RFC9404]:¶
{
"using": [ "urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:blob",
"urn:ietf:params:jmap:sieve" ],
"methodCalls": [
["Blob/upload", {
"accountId": "ken",
"create": {
"B": {
"data": [ {
"data:asText":
"redirect \"ken@example.com\"\r\n;"
} ],
"type": "application/sieve"
}
}
}, "1"],
["SieveScript/set", {
"accountId": "ken",
"update": { "dd1b164f-8cdc-448c-9f54": {
"blobId": "#B"
}
}
}, "2"]
]
}
{
"methodResponses": [
[
"Blob/upload",
{
"oldState": null,
"newState": "1603741700.309607123-0128",
"created": {
"B": {
"id": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
"blobId": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
"type": "application/sieve",
"size": 29
}
},
"notCreated": null,
"accountId": "ken"
},
"1"
],
[
"SieveScript/set",
{
"oldState": "1603741751.227268529-4096",
"newState": "1603742603.309607868-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": null
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"2"
]
]
}
¶
Request (and response) to update script name and deactivate:¶
{
"using": [ "urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:sieve" ],
"methodCalls": [
["SieveScript/set", {
"accountId": "ken",
"update": { "dd1b164f-8cdc-448c-9f54": {
"name": "myscript"
}
},
"onSuccessDeactivateScript": true
}, "3"]
]
}
{
"methodResponses": [
[
"SieveScript/set",
{
"oldState": "1603742603.309607868-4096",
"newState": "1603742967.852315428-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"3"
]
]
}
¶
Request (and response) to activate a script:¶
{
"using": [ "urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:sieve" ],
"methodCalls": [
["SieveScript/set", {
"accountId": "ken",
"onSuccessActivateScript": "dd1b164f-8cdc-448c-9f54"
}, "4"]
]
}
{
"methodResponses": [
[
"SieveScript/set",
{
"oldState": "1603742967.852315428-4096",
"newState": "1603744460.316617118-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": true
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"4"
]
]
}
¶
Requests (and responses) to deactivate and destroy the
active script:¶
{
"using": [ "urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:sieve" ],
"methodCalls": [
["SieveScript/set", {
"accountId": "ken",
"onSuccessDeactivateScript": true
}, "5"],
["SieveScript/set", {
"accountId": "ken",
"destroy": [ "dd1b164f-8cdc-448c-9f54" ]
}, "6"]
]
}
{
"methodResponses": [
[
"SieveScript/set",
{
"oldState": "1603744460.316617118-4096",
"newState": "1603744637.575375572-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"5"
],
[
"SieveScript/set",
{
"oldState": "1603744637.575375572-4096",
"newState": "1603744637.854390875-4096",
"created": null,
"updated": null,
"destroyed": [
"dd1b164f-8cdc-448c-9f54"
],
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"6"
]
]
}
¶