(only supported verbs are shown for each endpoint)
Contents
GET
/app
¶Returns terse list of applications
Example request:
$ curl -XGET '/app'
GET
/app/(string: app_name)
¶Returns detail about the application including creation datetime, child resources available and a census of environments/groups/servers/gitdeploys and the builds deployed to them.
The format of census is as follows:
{
"ENVIRONMENT_NAME": {
"GROUP_NAME": {
"SERVER_NAME": {
"GITDEPLOY_NAME": {
"committed": "BUILD_NAME",
"deployed": "BUILD_NAME"
}
}
}
}
}
The difference between committed and deployed occurs when different gitdeploys share a common gitrepo. If gitdeployA and gitdeployB share a common gitrepoFoo, after FooBuild is deployed to gitdeployA (or any groups that contain gitdeployA), FooBuild will be shown as committed and deployed to gitdeployA. However it will be only shown as committed to gitdeployB (because it shares gitrepoFoo), while not deployed yet (the deployed field will still show the previous build). This can also happen with failed rolling deployments when only a fraction of the servers in a group are successfully deployed to.
Example request:
$ curl -XGET '/app/widgetmaker'
PUT
/app
¶Parameters: |
|
---|
Create a new application.
Example request:
$ curl -XPUT '/app?app_name=widgetmaker'
DELETE
/app/(string: app_name)
¶Remove an application.
Warning
This will also delete all data associated with that application. This cannot be undone.
Example request:
$ curl -XDELETE '/app/widgetmaker'
GET
/app/(string: app_name)/builds
¶Returns list of all application builds.
Example request:
$ curl -XGET '/app/widgetmaker/builds'
PUT
/app/(string: app_name)/builds
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Create a new build object.
Example request:
$ curl -XPUT '/app/widgetmakers/builds?build_name=1-master' -d '{ "attributes": { "branch_name": "master" } }'
PATCH
/app/(string: app_name)/builds/(string: build_name)
¶JSON Parameters: | |
---|---|
|
Modify the attributes of a build object.
Note
Attributes is the only valid key to modify. The provided attributes attribute will replace whatever is currently on the build object.
Example request:
$ curl -XPATCH '/app/widgetmakers/builds/1-master' -d '{ "attributes": { "branch_name": "something-else" } }'
POST
/app/(string: app_name)/builds/(string: build_name)
¶Parameters: |
|
---|---|
Form Parameters: | |
|
Upload a build. This can be done either directly by including file data in a form post, or indirectly by providing a URL-encoded location that elita can download the build from.
Optionally, the name of a package map can be supplied in the package_map parameter. After upload is successful, the package map will be applied to the build, creating all packages specified in the map.
Attention
The build object must created first (via PUT; see above) before data can be uploaded to it.
Note
If indirect_url is specified it will always be used, even if the form parameter build is also provided in the same request.
Example request (direct):
$ curl -XPOST '/app/widgetmakers/builds/1-master?file_type=zip' -F "build=@/home/user/build.zip"
Example request (indirect):
# indirect upload from http://foobar.com/build.zip
$ curl -XPOST '/app/widgetmakers/builds/1-master?file_type=zip&indirect_url=http%3A%2F%2Ffoobar.com%2Fbuild.zip'
DELETE
/app/(string: app_name)/builds/(string: build_name)
¶Remove a build object. This will delete all uploaded data associated with this object.
Example request:
$ curl -XDELETE '/app/widgetmakers/builds/1-master'
GET
/app/(string: app_name)/packagemaps
¶View all package maps associated with the application.
Example request:
$ http GET '/app/widgetmakers/packagemaps'
GET
/app/(string: app_name)/packagemaps/(string: packagemap_name)
¶View individual package map.
Example request:
$ http GET '/app/widgetmakers/packagemaps/my_package_map'
PUT
/app/(string: app_name)/packagemaps
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Create a new package map.
A package map is a mapping of package names to one or more filename patterns. Patterns are interpreted as glob expressions including ‘**’ syntax for recursive matching (similar to globstar option of the bash shell). Each package must have a “patterns” key consisting of a list of one or more pattern strings.
There can be any number of packages within the package map, and there must be at least one pattern associated with each package.
Package Map Format
A package map is a mapping of package name (which can be an arbitrary string) to a JSON object consisting of the following fields:
Example JSON body
{
"packages": {
"binaries": {
"patterns": [ "bin/**/*" ]
},
"configs": {
"patterns": [ "conf/**/*.xml" ],
"prefix": "app-config/"
}
}
}
The above package map creates two packages: “binaries” and “configs”. The first (“binaries”) contains all files in the top-level “bin/” directory within the master package. The files are added recursively preserving directory structure.
The second package (“configs”) includes all XML files under the top-level “conf/” directory within the master package. Note that it also preserves the directory structure (but directories that do not contain matching files will not be included).
Note also that the “configs” package contains a prefix field. The prefix will be prepended to the archive name of every file in the package. For example, if a file “conf/a/b/main.xml” is added to the package, the archive name (the name that the file will have when the package is unpacked) will be “app-config/conf/a/b/main.xml”. There is another optional field called “remove_prefix” which does the opposite: if that string is present in the filename, it will be removed a maximum of one time starting from the left.
Example request:
$ echo '{ "packages": { "binaries": { "patterns": [ "bin/**/*" ] } } }' |http PUT '/app/widgetmakers/packagemaps?name=example_map'
DELETE
/app/(string: app_name)/packagemaps/(string: map_name)
¶Remove a package map.
Example request:
$ http DELETE '/app/widgetmakers/packagemaps/example_map'
GET
/app/(string: app_name)/gitrepos
¶View gitrepos.
Example request:
$ curl -XGET '/app/widgetmakers/gitrepos'
GET
/app/(string: app_name)/gitrepos/(string: gitrepo_name)
¶View individual gitrepo.
Example request:
$ curl -XGET '/app/widgetmakers/gitrepos/MyRepo1'
PUT
/app/(string: app_name)/gitrepo
¶Parameters: |
|
---|
Create a new gitrepo. If the parameter “existing” is false, Elita will create the repository using the gitprovider API.
Example request:
$ curl -XPUT '/app/widgetmakers/gitrepos?name=MyRepo1&existing=false&gitprovider=gp1&keypair=kp1'
DELETE
/app/(string: app_name)/gitrepos/(string: gitrepo_name)
¶Remove a gitrepo object. This will not delete the underlying repository from the gitprovider.
Example request:
$ curl -XDELETE '/app/widgetmakers/gitrepos/MyRepo1'
GET
/app/(string: app_name)/gitdeploys
¶View gitdeploys.
Example request:
$ curl -XGET '/app/widgetmakers/gitdeploys'
GET
/app/(string: app_name)/gitdeploys/(string: gitdeploy_name)
¶View individual gitdeploy.
Example request:
$ curl -XGET '/app/widgetmakers/gitdeploys/WebApplication'
PUT
/app/(string: app_name)/gitdeploys
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Create a new gitdeploy. You must provide a valid JSON-encoded gitdeploy object in the body of the request.
“package” - the build package to deploy. Must be a string and must be a valid package name. Note that this is not checked for validity at the time of gitdeploy creation, allowing you to create gitdeploys prior to implementing packaging.
“location” - an object describing where to deploy on end servers (see below)
“attributes” - user-defined attributes
“options” - git options (see below)
“action” - pre/post salt states to run in addition to the deployment (see below)
The location object is a JSON object that has the following required keys:
“path” - absolute deployment path on end servers. This is where the gitrepo will be cloned.
“gitrepo” - name of gitrepo to deploy at path.
“default_branch” - name of git branch to deploy (use ‘master’ unless you know you need something else)
The options object allow you to specify the following git options which are used during deployments:
“favor” - can be “ours” (local) or “theirs” (remote). Defaults to “ours”. This reduces the chances of merge failures if local changes exist, preferring the local changes to the incoming remote changes.
“ignore-whitespace” - “true”/”false”. Also reduces likelihood of merge conflicts. Defaults to true.
“gitignore” - a list of strings representing the .gitignore file on end servers. Use this to ignore local changes on end servers so they don’t cause failed deployments.
The actions object allows you to inject salt states into the gitdeploy. It consists of two keys: “prepull” and “postpull”. As the names suggest, “prepull” is executed immediately prior to deployment and “postpull” is executed immediately afterward.
Salt states by convention are usually expressed as YAML. This is easily translated into JSON. Keep in mind, however, that every state must have a unique ID. It’s therefore preferable to express them with an arbitrary (but unique) ID and an explicit “name” parameter, rather than the more terse form of using the ID as the implicit name.
Example:
- This is an idiomatic Salt state to ensure httpd is running (in YAML):
httpd: service - running- Prior to injection it should be converted to the following form (in YAML):
start_apache: service: - name: httpd - running- Translated into JSON:
{ "start_apache": { "service": [ { "name": "httpd" }, "running" ] } }
Example gitdeploy object (simple):
{
"package": "webapplication_pkg",
"location": {
"path": "/opt/widgetmaker",
"default_branch": "master",
"gitrepo": "wm_webapp_gitrepo"
}
}
Example gitdeploy object (complex):
{
"attributes": {
"description": "Example gitdeploy for Elita documentation"
},
"package": "webapplication_pkg",
"location": {
"path": "/opt/widgetmaker",
"default_branch": "master",
"gitrepo": "wm_webapp_gitrepo"
},
"options": {
"favor": "ours",
"ignore-whitespace": "true",
"gitignore": [
"foo.txt"
]
},
"actions": {
"prepull": {
"stop_apache": {
"service": [
{
"name": "httpd"
},
"dead"
]
}
},
"postpull": {
"start_apache": {
"service": [
{
"name": "httpd"
},
"running"
]
}
}
}
}
Example request:
$ curl -XPUT '/app/widgetmakers/gitdeploys?name=WebApp' -d $(cat WebApp.json)
POST
/app/(string: app_name)/gitdeploy/(string: gitdeploy_name)
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Initializes (or deinitializes) a gitdeploy from one or more servers.
“Initializing” is the act of copying required keypairs, setting them up and cloning the gitrepo at the specified path. A server must have a gitdeploy initialized on it before deployments to that server can be performed.
“Deinitializing” is the act of deleting keypairs and the gitrepo from the target servers.
Attention
The parent of “path” must exist. For example, if the gitdeploy path is /opt/applications/MyApp, the directory /opt/applications must exist. The subfolder MyApp will be created as part of the clone operation.
This must have a “servers” key that is a list of servers to apply the initialization/deinitialization to.
Example:
{
"servers": [ "web01", "web02", "web03" ]
}
Example request (initialize):
$ curl -XPOST '/app/widgetmakers/gitdeploys/WebApp?initialize=true' -d '{ "servers": [ "web01" ] }'
Example request (deinitialize):
$ curl -XPOST '/app/widgetmakers/gitdeploys/WebApp?deinitialize=true' -d '{ "servers": [ "web01" ] }'
DELETE
/app/(string: app_name)/gitdeploys/(string: gitdeploy_name)
¶Remove a gitdeploy object.
Example request:
$ curl -XDELETE '/app/widgetmakers/gitdeploys/WebApp'
Application groups are logical groups of gitdeploys. Groups are used to combine gitdeploys into logical units in various ways–for example, different groups can share common gitdeploys. Server group membership is calculated dynamically based on what gitdeploys are initialized on the servers.
GET
/app/(string: app_name)/groups
¶View groups.
Example request:
$ curl -XGET '/app/widgetmakers/groups'
GET
/app/(string: app_name)/groups/(string: group_name)
¶Parameters: |
|
---|
View individual group. If environments is specified, the servers listed will be filtered by the environments specified (will return servers present in any of the environments passed).
The server list returned is dynamically calculated based on the gitdeploys initialized on servers at the time the request is made.
Example request:
$ curl -XGET '/app/widgetmakers/groups/WebFrontEnd?environments=production+testing'
PUT
/app/(string: app_name)/groups
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Create a group. You must supply a JSON-encoded list of gitdeploys in the body of the request. The “gitdeploys” key can either be a flat list of strings (unordered) or a list-of-lists (ordered). See Group Explanation for details.
Example JSON:
{
"gitdeploys": [ "Configuration", "WebApplication", "StaticAssets" ]
}
Example request:
$ curl -XPUT '/app/widgetmakers/groups?name=WebFrontEnd' -d '{ "gitdeploys": [ "Configuration", "WebApplication", "StaticAssets" ] }'
DELETE
/app/(string: app_name)/groups/(string: group_name)
¶Remove a group object.
Example request:
$ curl -XDELETE '/app/widgetmakers/groups/WebFrontEnd'
Deployment endpoints allow you to push builds to servers/gitdeploys (“manual deployment”) or environments/groups (“group deployment”). For details about the backend mechanism, see: Gitdeploy Explanation
GET
/app/(string: app_name)/deployments
¶Parameters: |
|
---|
View all deployments (by id). If details=true is passed, all detail for each deployment will be included in output (potentially a large amount of data).
Example request:
$ curl -XGET '/app/widgetmakers/deployments'
GET
/app/(string: app_name)/deployments/(string: deployment_id)
¶View deployment detail.
Example request:
$ curl -XGET '/app/widgetmakers/deployments/53716bfddf15e00e19043b8f'
POST
/app/(string: app_name)/deployments
¶Parameters: |
|
---|---|
JSON Parameters: | |
|
Perform a deployment.
There are two general ‘styles’ of deployment: manual deployment and group deployment.
A manual deployment is one in which you specify the individual servers and gitdeploys to which you want to deploy the build. This gives you the most flexibility but is also the most verbose. It also does not allow for automatic rolling deployments.
A group deployment is one in which you specify only the environment(s) and the group(s) to deploy to. Elita will calculate the servers and gitdeploys that satisfy both specifications and–if the relevant groups require it– will perform an automatic batched rolling deploy.
Pause Options
The “rolling_pause” parameter is the number of seconds to wait between batches (the total number of servers split using the rolling_divisor parameter). If any groups contain ordered gitdeploys, the batches will be further split into batches to enforce the ordering.
For example, if rolling_divisor is two (2), without ordering the servers would be split into two evenly sized batches. If each group had a set of two ordered gitdeploys, the servers would be split into four (4) batches. Batches 1 and 3 would be “ordered” batches and, after complete, would result in a pause of ordered_pause seconds. Batch 2 would result in a rolling_pause (batch 4 is last and so would not have any pause afterward).
Example request (manual):
$ curl -XPOST '/app/widgetmakers/deployments?build_name=5-master' -d '{ "servers": [ "web01" ], "gitdeploys":
[ "WebApplication", "Configuration" ] }'
Example request (group):
$ curl -XPOST '/app/widgetmakers/deployments?build_name=5-master&rolling_divisor=4' -d '{ "environments": [ "production" ],
"groups": [ "WebFrontEnd" ] }'