Ajouter une règle

POST /v2/rules

Creates a new transfer rule with the ObjectRule passed in the request body. The created entry is returned in the response body, along with its URI.

Example request:

POST /v2/rules HTTP/1.1
Host: example.com
Content-Type: application/json

{
    "name": "example",
    "hostIds": [
        "server1",
        "server2"
    ],
    "modeTrans": "send",
    "recvPath": "in/",
    "sendPath": "out/",
    "archivePath": "arch/",
    "workPath": "work/",
    "rPreTasks": [
        {
            "type": "ZIP",
            "arguments": "file.txt work/",
            "delay": 1
        }
    ],
    "rPostTask": [
        {
            "type": "MOVERENAME",
            "arguments": "arch/file.bak"
        }
    ],
    "rErrorTasks": [
        {
            "type": "RESCHEDULE",
            "arguments": "-delay 3600000 -case ConnectionImpossible,ServerOverloaded,Shutdown"
        }
    ],
    "sPreTasks": [],
    "sPostTasks": [
        {
            "type": "ZIP",
            "arguments": "file.zip work/",
            "delay": 0
        }
    ],
    "sErrorTasks": [
        {
            "type": "DELETE"
        }
    ]
}
Status Codes:
  • 201 Created

    La nouvelle règle de transfert a été ajoutée avec succès.

    Example response:

    HTTP/1.1 201 Created
    Content-Type: application/json
    
    {
        "name": "example",
        "hostIds": [
            "server1",
            "server2"
        ],
        "modeTrans": "send",
        "recvPath": "in/",
        "sendPath": "out/",
        "archivePath": "arch/",
        "workPath": "work/",
        "rPreTasks": [
            {
                "type": "ZIP",
                "arguments": "file.txt work/",
                "delay": 1
            }
        ],
        "rPostTask": [
            {
                "type": "MOVERENAME",
                "arguments": "arch/file.bak"
            }
        ],
        "rErrorTasks": [
            {
                "type": "RESCHEDULE",
                "arguments": "-delay 3600000 -case ConnectionImpossible,ServerOverloaded,Shutdown"
            }
        ],
        "sPreTasks": [],
        "sPostTasks": [
            {
                "type": "ZIP",
                "arguments": "file.zip work/",
                "delay": 0
            }
        ],
        "sErrorTasks": [
            {
                "type": "DELETE"
            }
        ]
    }
    

  • 400 Bad Request

    La requête est invalide, soit à cause de paramètres de requête erronés, soit à cause d’un corps de requête invalide.

    Les causes de l’échec de la requête sont données dans le corps de la réponse sour forme d’un tableau JSON.

    Example response:

    HTTP/1.1 400 Bad Request
    Content-Type: application/json
    
    {
        "errors": [
            {
                "message": "Query parameter 'startTrans' : illegal value 'not_a_date'.",
                "errorCode": 4
            },
            {
                "message": "Query parameter 'status' : illegal value 'not_a_status'.",
                "errorCode": 4
            }
        ]
    }
    

En-têtes de réponse:
  • ruleURI – L’URI d’accès à la nouvelle règle créée.