{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Recipe",
    "description": "A container configuration recipe",
    "type": "object",
    "required": ["name"],
    "properties": {
        "name": {
            "description": "The recipe name",
            "type": "string"
        },
        "description": {
            "description": "The recipe description",
            "type": "string"
        },
        "phases": {
            "description": "The execution phases for the recipe",
            "type": "array",
            "items":{
            	"type":"string"
            }
        },
        "environment": {
            "type":"object",
            "properties":{
                "required":{
                    "type":"array",
                    "description": "Any bundles required to be deployed for this recipe to run.",
                    "items":{
                        "type":"object",
						"required":["symbolicName"],
						"properties":{
							"symbolicName":{
								"type":"string"
							},
							"version":{
								"description":"A version or version range",
								"type":"string"
							},
							"filter":{
								"description":"A filter to use against bundle headers.  An alternative to the symbolicName and version fields.",
								"type":"string"
							}
						}
                    }
                },
                "unless":{
                    "type":"array",
                    "description": "Any bundles required to not be deployed for this recipe to run.",
                    "items":{
                        "type":"object",
						"required":["symbolicName"],
						"properties":{
							"symbolicName":{
								"type":"string"
							},
							"version":{
								"description":"A version or version range",
								"type":"string"
							},
							"filter":{
								"description":"A filter to use against bundle headers.  An alternative to the symbolicName and version fields.",
								"type":"string"
							}
						}
                    }
                }                
            }
        },
        "includes": {
            "type": "array",
            "description": "Included recipes",
            "uniqueItems": true,
            "items": {
                "type": "object",
                "required":["location"],
				"properties": {
                    "name": {
                        "description": "A name for the included recipe",
                        "type": "string"
                    },	
                   "location": {
                        "description": "The included recipe URL",
                        "type": "string",
                        "format":"uri"
                    },
                    "username": {
                        "description": "The optional user name to use to access the recipe URL",
                        "type": "string"
                    },
                    "password": {
                        "description": "The optional password to use to access the recipe URL",
                        "type": "string"
                    }
                }
            }
        },
        "repositories": {
            "type": "array",
            "description": "Repositories to examine for bundles and features",
            "uniqueItems": true,
            "items": {
                "type": "object",
                "properties": {
                    "location": {
                        "description": "The repository URL",
                        "type": "string",
                        "format":"uri"
                    },  
                    "username": {
                        "description": "The optional user name to use to access the repository",
                        "type": "string"
                    },
                    "password": {
                        "description": "The optional password to use to access the repository",
                        "type": "string"
                    }
                },
                "required":["location"]
            }
        },
        "features": {
            "type": "object",
            "description": "Feature actions",
            "properties": {
                "install": {
                    "description": "The features to install",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"string"
                    }
                },  
                "uninstall": {
                    "description": "The features to uninstall",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"string"
                    }
                },
                "update": {
                    "description": "The features to update",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"string"
                    }
                }
            }
        },
        "bundles": {
            "type": "object",
            "description": "Bundle actions",
            "properties": {
                "install": {
                    "description": "The bundles to install",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"object",
                        "required":["location"],
                        "properties":{
                        	"location":{
                        		"type":"string",
                        		"format":"uri"
                        	},
                        	"username":{
                        		"type":"string"
                        	},
                        	"password":{
                        		"type":"string"
                        	},
                        	"convert":{
                        		"type":"boolean"
                        	}                       	
                        }
                    }
                },  
                "uninstall": {
                    "description": "The IDs of any bundles to uninstall",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"string"
                    }
                },
                "update": {
                    "description": "The IDs of any bundles to update",
                    "type": "array",
                    "uniqueItems": true,
                    "items":{
                        "type":"string"
                    }
                }
            }
        },
        "configurations": {
            "type": "array",
            "description": "Configuration actions",
            "uniqueItems": true,
            "items": {
                "type": "object",
                "properties": {
                    "pid": {
                        "description": "The configuration PID,  The special value 'system' refers to system properties.",
                        "type": "string"
                    },  
                    "factoryPid": {
                        "description": "The configuration factory PID.  If specified, a selector should be used to identify the correct configuration.",
                        "type": "string"
                    }, 
                    "selector": {
                        "description": "A normal OSGi filter used to identify the correct configuration when a factory PID is specified.",
                        "type": "string"
                    },  
                    "location": {
                        "description": "The location of a properties file that will overwrite the specified PID.",
                        "type": "string",
                        "format":"uri"
                    },       
                    "add": {
                        "description": "Properties to add.  If the property already exists, no action will be taken.",
                        "type": "object"
                    },  
                    "delete": {
                        "description": "Properties to remove.  If there is a value of '*' the PID will be removed.",
                        "type": "array",
                        "items":{
                            "type":"string"
                        },
                        "uniqueItems": true
                    },
                    "update": {
                        "description": "Properties to update",
                        "type": "object"
                    }
                }
            }
        },
        "tasks": {
            "type": "array",
            "description": "Task workflow actions",
            "uniqueItems": true,
            "items": {
                "type": "object",
                "required":["name"],
                "properties": {
                    "name": {
                        "description": "The task name.",
                        "type": "string"
                    },  
                    "presentationName": {
                        "description": "The task name.",
                        "type": "string"
                    },
                    "description": {
                        "description": "The task description.",
                        "type": "string"
                    },                    
                    "condition": {
                        "description": "An optional condition to evaluate that should yield true only if the task is to be executed.",
                        "type": "string"
                    }, 
                    "steps": {
                        "description": "A set of step configurations.",
                        "type": "array",
						"items": {
							"type":"object",
							"required":["name"],
							"properties": {
								"name":{
									"description":"The step name",
									"type":"string"
								},
								"presentationName":{
									"description":"The step name",
									"type":"string"
								},
								"description": {
			                        "description": "The step description.",
			                        "type": "string"
			                    },
								"properties": {
									"description":"Property values for this step",
									"type":"object"
								}
							}
						}
                    }
                }
            }
        }
    }
}
