{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Delivery compilation API"
  },
  "tags": [
    {
      "name": "delivery",
      "description": "Operations about delivery"
    }
  ],
  "paths": {
    "/taoDeliveryRdf/RestDelivery/generate": {
      "post": {
        "description": "Generate a delivery from a valid test uri",
        "tags": [
          "delivery"
        ],
        "parameters": [
          {
            "name": "test",
            "in": "formData",
            "description": "Test identifier, in URI format",
            "required": true,
            "type": "string"
          },{
            "name": "delivery-uri",
            "in": "formData",
            "description": "Delivery class uri where to create test delivery",
            "required": false,
            "type": "string"
          },{
            "name": "delivery-label",
            "in": "formData",
            "description": "If delivery-uri is specified, this parameter will be ignored. Delivery class label where to create test delivery otherwise root class will be used",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "response",
              "format": "json",
              "type": "object",
              "required": [
                "success",
                "version"
              ],
              "properties": {
                "success": {
                  "type": "boolean",
                  "description": "false on failure, true on success"
                },
                "version": {
                  "type": "string",
                  "description": "tao version"
                },
                "data": {
                  "$ref": "#/definitions/data"
                },
                "errorCode": {
                  "type": "string",
                  "description": "error code. it appear if success value is false"
                },
                "errorMsg": {
                  "type": "string",
                  "description": "error description. it appear if success value is false"
                }
              }
            },
            "examples": {
              "application/json": {
                "success": true,
                "data": {
                  "delivery": [
                    "http://tao.local/mytao.rdf#xxxxxxxxxxxxx1"
                  ]
                },
                "version": "3.1.0"
              }
            }
          },
          "400": {
            "description": "Bad request if you send invalid parameters. Test uri is mandatory.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "At least one mandatory parameter was required but found missing in your request",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "401": {
            "description": "Unauthorized",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "You don't have permission to access this resource.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "404": {
            "description": "Test uri is provided but not found.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Unable to find a test associated to the given uri.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "500": {
            "description": "Internal error, if delivery class label is found multiple times.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Exception error description",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          }
        }
      }
    },
    "/taoDeliveryRdf/RestDelivery/generateDeferred": {
      "post": {
        "description": "Generate a delivery from a valid test uri using task queue",
        "tags": [
          "delivery"
        ],
        "parameters": [
          {
            "name": "test",
            "in": "formData",
            "description": "Test identifier, in URI format",
            "required": true,
            "type": "string"
          },{
            "name": "delivery-uri",
            "in": "formData",
            "description": "Delivery class uri where to create test delivery",
            "required": false,
            "type": "string"
          },{
            "name": "delivery-label",
            "in": "formData",
            "description": "If delivery-uri is specified, this parameter will be ignored. Delivery class label where to create test delivery otherwise root class will be used",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "response",
              "format": "json",
              "type": "object",
              "required": [
                "success",
                "version"
              ],
              "properties": {
                "success": {
                  "type": "boolean",
                  "description": "false on failure, true on success"
                },
                "version": {
                  "type": "string",
                  "description": "tao version"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "reference_id" : {
                      "type": "string",
                      "description": "Identifier of the task in the task queue"
                    }
                  }
                },
                "errorCode": {
                  "type": "string",
                  "description": "error code. it appear if success value is false"
                },
                "errorMsg": {
                  "type": "string",
                  "description": "error description. it appear if success value is false"
                }
              }
            },
            "examples": {
              "application/json": {
                "success": true,
                "data": {
                  "reference_id": "http://tao.local/mytao.rdf#xxxxxxxxxxxxx"
                },
                "version": "3.1.0"
              }
            }
          },
          "400": {
            "description": "Bad request if you send invalid parameters. Test uri is mandatory.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "At least one mandatory parameter was required but found missing in your request",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "401": {
            "description": "Unauthorized",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "You don't have permission to access this resource.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "404": {
            "description": "Test uri is provided but not found.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Unable to find a test associated to the given uri.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "500": {
            "description": "Internal error, if delivery class label is found multiple times.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Exception error description",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          }
        }
      }
    },
    "/taoDeliveryRdf/RestDelivery/getStatus": {
      "get": {
        "description": "Check status of generate delivery task. Available since Tao 3.1.",
        "tags": [
          "delivery"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "Task identifier",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "response",
              "format": "json",
              "type": "object",
              "required": [
                "success",
                "version"
              ],
              "properties": {
                "success": {
                  "type": "boolean",
                  "description": "false on failure, true on success"
                },
                "version": {
                  "type": "string",
                  "description": "tao version"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "id" : {
                      "type": "string",
                      "description": "Task identifier"
                    },
                    "status" : {
                      "type": "string",
                      "description": "Task execution status"
                    },
                    "delivery" : {
                      "type": "string",
                      "description": "Generated delivery identifier"
                    }
                  }
                },
                "errorCode": {
                  "type": "string",
                  "description": "error code. it appear if success value is false"
                },
                "errorMsg": {
                  "type": "string",
                  "description": "error description. it appear if success value is false"
                }
              }
            },
            "examples": {
              "application/json": {
                "success": true,
                "data": {
                  "id": "http://tao.local/mytao.rdf#xxxxxxxxxxxxx",
                  "status": "Success",
                  "delivery": "http://tao.local/mytao.rdf#xxxxxxxxxxxxx"
                },
                "version": "3.1.0"
              }
            }
          },
          "400": {
            "description": "Bad request if you send invalid parameters. Test uri is mandatory.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "At least one mandatory parameter was required but found missing in your request",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "401": {
            "description": "Unauthorized",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "You don't have permission to access this resource.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "404": {
            "description": "Task with given id was not found",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Task not found.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "500": {
            "description": "Internal error (should not occur)",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Exception error description",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          }
        }
      }
    },
    "/taoDeliveryRdf/RestTest/compileDeferred": {
      "post": {
        "description": "Import test and compile delivery using task queue",
        "tags": [
          "delivery", "test"
        ],
        "parameters": [
          {
            "name": "testPackage",
            "in": "formData",
            "description": "Test package archive",
            "required": true,
            "type": "file"
          },
          {
            "name": "importerId",
            "in": "formData",
            "description": "Importer name",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "response",
              "format": "json",
              "type": "object",
              "required": [
                "success",
                "version"
              ],
              "properties": {
                "success": {
                  "type": "boolean",
                  "description": "false on failure, true on success"
                },
                "version": {
                  "type": "string",
                  "description": "tao version"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "reference_id" : {
                      "type": "string",
                      "description": "Identifier of the task in the task queue"
                    }
                  }
                },
                "errorCode": {
                  "type": "string",
                  "description": "error code. it appear if success value is false"
                },
                "errorMsg": {
                  "type": "string",
                  "description": "error description. it appear if success value is false"
                }
              }
            },
            "examples": {
              "application/json": {
                "success": true,
                "data": {
                  "reference_id": "http://tao.local/mytao.rdf#xxxxxxxxxxxxx"
                },
                "version": "3.1.0"
              }
            }
          },
          "400": {
            "description": "Bad request if you send invalid parameters.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "At least one mandatory parameter was required but found missing in your request",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "401": {
            "description": "Unauthorized",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "You don't have permission to access this resource.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "404": {
            "description": "Test uri is provided but not found.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Unable to find a importer by given identifier",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "500": {
            "description": "Internal error (should not occur)",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Exception error description",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          }
        }
      }
    },
    "/taoDeliveryRdf/RestDelivery/createClass": {
      "post": {
        "description": "Create a delivery class",
        "tags": [
          "delivery"
        ],
        "parameters": [
          {
            "name": "delivery-label",
            "in": "formData",
            "description": "Delivery class label to create",
            "required": true,
            "type": "string"
          },{
            "name": "delivery-parent",
            "in": "formData",
            "description": "Parent delivery class uri. If not specified root delivery class will be used",
            "required": false,
            "type": "string"
          },{
            "name": "delivery-comment",
            "in": "formData",
            "description": "The comment of new created class",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "response",
              "format": "json",
              "type": "object",
              "required": [
                "success",
                "version"
              ],
              "properties": {
                "success": {
                  "type": "boolean",
                  "description": "false on failure, true on success"
                },
                "version": {
                  "type": "string",
                  "description": "tao version"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "message" : {
                      "type": "string",
                      "description": "A message to explain if class is newly created or it already exists"
                    },
                    "delivery-uri" : {
                      "type": "string",
                      "description": "The uri of newly created delivery class"
                    }
                  }
                },
                "errorCode": {
                  "type": "string",
                  "description": "error code. it appear if success value is false"
                },
                "errorMsg": {
                  "type": "string",
                  "description": "error description. it appear if success value is false"
                }
              }
            },
            "examples": {
              "application/json": {
                "success": true,
                "data": {
                  "delivery-uri": "http://tao.local/mytao.rdf#xxxxxxxxxxxxx"
                },
                "version": "3.1.0"
              }
            }
          },
          "400": {
            "description": "Bad request if you send invalid parameters. delivery-label uri is mandatory.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "At least one mandatory parameter was required but found missing in your request",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "401": {
            "description": "Unauthorized",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "You don't have permission to access this resource.",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          },
          "500": {
            "description": "Internal error, if delivery-parent if not a valid delivery class.",
            "examples": {
              "application/json": {
                "success": false,
                "errorCode": 0,
                "errorMsg": "Exception error description",
                "version": "3.1.0"
              }
            },
            "schema": {
              "$ref": "#/definitions/errorModel"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "errorModel": {
      "type": "object",
      "description": "contain error",
      "required": [
        "success",
        "version",
        "errorCode",
        "errorMsg"
      ],
      "properties": {
        "success": {
          "type": "boolean",
          "description": "false on failure",
          "default": false
        },
        "version": {
          "type": "string",
          "description": "tao version"
        },
        "errorCode": {
          "type": "integer",
          "description": "error code"
        },
        "errorMsg": {
          "type": "string",
          "description": "error description"
        }
      }
    },
    "data": {
      "type": "object",
      "description": "Generated delivery URI , it appear if success value is true",
      "properties": {
        "delivery": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "taoDeliveryRdf on Github",
    "url": "https://github.com/oat-sa/extension-tao-delivery-rdf"
  }
}
