Commit 1f3c58a2 authored by Nick Thomas's avatar Nick Thomas

Document the project templates API endpoint

This commit also refactors the existing documentation, and adds
missing documentation for the Dockerfile template type.
parent 071e3d7d
...@@ -20,13 +20,14 @@ following locations: ...@@ -20,13 +20,14 @@ following locations:
- [Custom Attributes](custom_attributes.md) - [Custom Attributes](custom_attributes.md)
- [Deployments](deployments.md) - [Deployments](deployments.md)
- [Deploy Keys](deploy_keys.md) - [Deploy Keys](deploy_keys.md)
- [Dockerfile templates](templates/dockerfiles.md)
- [Environments](environments.md) - [Environments](environments.md)
- [Epics](epics.md) **[ULTIMATE]** - [Epics](epics.md) **[ULTIMATE]**
- [Epic Issues](epic_issues.md) **[ULTIMATE]** - [Epic Issues](epic_issues.md) **[ULTIMATE]**
- [Events](events.md) - [Events](events.md)
- [Feature flags](features.md) - [Feature flags](features.md)
- [Geo Nodes](geo_nodes.md) **[PREMIUM]** - [Geo Nodes](geo_nodes.md) **[PREMIUM]**
- [Gitignores templates](templates/gitignores.md) - [Gitignore templates](templates/gitignores.md)
- [GitLab CI Config templates](templates/gitlab_ci_ymls.md) - [GitLab CI Config templates](templates/gitlab_ci_ymls.md)
- [Groups](groups.md) - [Groups](groups.md)
- [Group Access Requests](access_requests.md) - [Group Access Requests](access_requests.md)
...@@ -62,6 +63,7 @@ following locations: ...@@ -62,6 +63,7 @@ following locations:
- [Project import/export](project_import_export.md) - [Project import/export](project_import_export.md)
- [Project Members](members.md) - [Project Members](members.md)
- [Project Snippets](project_snippets.md) - [Project Snippets](project_snippets.md)
- [Project Templates](project_templates.md)
- [Protected Branches](protected_branches.md) - [Protected Branches](protected_branches.md)
- [Protected Tags](protected_tags.md) - [Protected Tags](protected_tags.md)
- [Repositories](repositories.md) - [Repositories](repositories.md)
......
# Project templates API
This API is a project-specific implementation of these endpoints:
- [Dockerfile templates](templates/dockerfiles.md)
- [Gitignore templates](templates/gitignores.md)
- [GitLab CI Config templates](templates/gitlab_ci_ymls.md)
- [Open source license templates](templates/licenses.md)
It deprecates those endpoints, which will be removed for API version 5.
Project-specific templates will be added to this API in time. This includes, but
is not limited to:
- [Issue and Merge Request templates](../user/project/description_templates.html)
- [Group level file templates](https://gitlab.com/gitlab-org/gitlab-ee/issues/5987) **(Premium)**
## Get all templates of a particular type
```
GET /projects/:id/templates/:type
```
| Attribute | Type | Required | Description |
| ---------- | ------ | -------- | ----------- |
| `id ` | integer / string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `type` | string | yes| The type `(dockerfiles|gitignores|gitlab_ci_ymls|licenses)` of the template |
Example response (licenses):
```json
[
{
"key": "epl-1.0",
"name": "Eclipse Public License 1.0"
},
{
"key": "lgpl-3.0",
"name": "GNU Lesser General Public License v3.0"
},
{
"key": "unlicense",
"name": "The Unlicense"
},
{
"key": "agpl-3.0",
"name": "GNU Affero General Public License v3.0"
},
{
"key": "gpl-3.0",
"name": "GNU General Public License v3.0"
},
{
"key": "bsd-3-clause",
"name": "BSD 3-clause \"New\" or \"Revised\" License"
},
{
"key": "lgpl-2.1",
"name": "GNU Lesser General Public License v2.1"
},
{
"key": "mit",
"name": "MIT License"
},
{
"key": "apache-2.0",
"name": "Apache License 2.0"
},
{
"key": "bsd-2-clause",
"name": "BSD 2-clause \"Simplified\" License"
},
{
"key": "mpl-2.0",
"name": "Mozilla Public License 2.0"
},
{
"key": "gpl-2.0",
"name": "GNU General Public License v2.0"
}
]
```
## Get one template of a particular type
```
GET /projects/:id/templates/:type/:key
```
| Attribute | Type | Required | Description |
| ---------- | ------ | -------- | ----------- |
| `id ` | integer / string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `type` | string | yes| The type `(dockerfiles|gitignores|gitlab_ci_ymls|licenses)` of the template |
| `key` | string | yes | The key of the template, as obtained from the collection endpoint |
| `project` | string | no | The project name to use when expanding placeholders in the template. Only affects licenses |
| `fullname` | string | no | The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses |
Example response (dockerfile):
```json
{
"name": "Binary",
"content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:jessie\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n"
}
```
Example response (license):
```json
{
"key": "mit",
"name": "MIT License",
"nickname": null,
"popular": true,
"html_url": "http://choosealicense.com/licenses/mit/",
"source_url": "https://opensource.org/licenses/MIT",
"description": "A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.",
"conditions": [
"include-copyright"
],
"permissions": [
"commercial-use",
"modifications",
"distribution",
"private-use"
],
"limitations": [
"liability",
"warranty"
],
"content": "MIT License\n\nCopyright (c) 2018 [fullname]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
}
```
# Dockerfiles API
## List dockerfile templates
Get all dockerfile templates.
```
GET /templates/dockerfiles
```
```bash
curl https://gitlab.example.com/api/v4/templates/dockerfiles
```
Example response:
```json
[
{
"key": "Binary",
"name": "Binary"
},
{
"key": "Binary-alpine",
"name": "Binary-alpine"
},
{
"key": "Binary-scratch",
"name": "Binary-scratch"
},
{
"key": "Golang",
"name": "Golang"
},
{
"key": "Golang-alpine",
"name": "Golang-alpine"
},
{
"key": "Golang-scratch",
"name": "Golang-scratch"
},
{
"key": "HTTPd",
"name": "HTTPd"
},
{
"key": "Node",
"name": "Node"
},
{
"key": "Node-alpine",
"name": "Node-alpine"
},
{
"key": "OpenJDK",
"name": "OpenJDK"
},
{
"key": "OpenJDK-alpine",
"name": "OpenJDK-alpine"
},
{
"key": "PHP",
"name": "PHP"
},
{
"key": "Python",
"name": "Python"
},
{
"key": "Python-alpine",
"name": "Python-alpine"
},
{
"key": "Python2",
"name": "Python2"
},
{
"key": "Ruby",
"name": "Ruby"
},
{
"key": "Ruby-alpine",
"name": "Ruby-alpine"
}
]
```
## Single dockerfile template
Get a single dockerfile template.
```
GET /templates/dockerfiles/:key
```
| Attribute | Type | Required | Description |
| ---------- | ------ | -------- | ----------- |
| `key` | string | yes | The key of the dockerfile template |
```bash
curl https://gitlab.example.com/api/v4/templates/dockerfiles/Binary
```
Example response:
```json
{
"name": "Binary",
"content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:jessie\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n"
}
```
...@@ -17,538 +17,84 @@ Example response: ...@@ -17,538 +17,84 @@ Example response:
```json ```json
[ [
{ {
"name": "AppEngine" "key": "Actionscript",
}, "name": "Actionscript"
{
"name": "Laravel"
},
{
"name": "Elisp"
},
{
"name": "SketchUp"
}, },
{ {
"key": "Ada",
"name": "Ada" "name": "Ada"
}, },
{ {
"name": "Ruby" "key": "Agda",
}, "name": "Agda"
{
"name": "Kohana"
},
{
"name": "Nanoc"
},
{
"name": "Erlang"
},
{
"name": "OCaml"
},
{
"name": "Lithium"
},
{
"name": "Fortran"
},
{
"name": "Scala"
},
{
"name": "Node"
},
{
"name": "Fancy"
},
{
"name": "Perl"
},
{
"name": "Zephir"
},
{
"name": "WordPress"
},
{
"name": "Symfony"
},
{
"name": "FuelPHP"
},
{
"name": "DM"
},
{
"name": "Sdcc"
},
{
"name": "Rust"
},
{
"name": "C"
},
{
"name": "Umbraco"
},
{
"name": "Actionscript"
}, },
{ {
"key": "Android",
"name": "Android" "name": "Android"
}, },
{ {
"name": "Grails" "key": "AppEngine",
}, "name": "AppEngine"
{
"name": "Composer"
},
{
"name": "ExpressionEngine"
},
{
"name": "Gcov"
},
{
"name": "Qt"
}, },
{ {
"name": "Phalcon" "key": "AppceleratorTitanium",
"name": "AppceleratorTitanium"
}, },
{ {
"key": "ArchLinuxPackages",
"name": "ArchLinuxPackages" "name": "ArchLinuxPackages"
}, },
{ {
"name": "TeX" "key": "Autotools",
},
{
"name": "SCons"
},
{
"name": "Lilypond"
},
{
"name": "CommonLisp"
},
{
"name": "Rails"
},
{
"name": "Mercury"
},
{
"name": "Magento"
},
{
"name": "ChefCookbook"
},
{
"name": "GitBook"
},
{
"name": "C++"
},
{
"name": "Eagle"
},
{
"name": "Go"
},
{
"name": "OpenCart"
},
{
"name": "Scheme"
},
{
"name": "Typo3"
},
{
"name": "SeamGen"
},
{
"name": "Swift"
},
{
"name": "Elm"
},
{
"name": "Unity"
},
{
"name": "Agda"
},
{
"name": "CUDA"
},
{
"name": "VVVV"
},
{
"name": "Finale"
},
{
"name": "LemonStand"
},
{
"name": "Textpattern"
},
{
"name": "Julia"
},
{
"name": "Packer"
},
{
"name": "Scrivener"
},
{
"name": "Dart"
},
{
"name": "Plone"
},
{
"name": "Jekyll"
},
{
"name": "Xojo"
},
{
"name": "LabVIEW"
},
{
"name": "Autotools" "name": "Autotools"
}, },
{ {
"name": "KiCad" "key": "C",
}, "name": "C"
{
"name": "Prestashop"
},
{
"name": "ROS"
},
{
"name": "Smalltalk"
},
{
"name": "GWT"
},
{
"name": "OracleForms"
},
{
"name": "SugarCRM"
},
{
"name": "Nim"
},
{
"name": "SymphonyCMS"
}, },
{ {
"name": "Maven" "key": "C++",
"name": "C++"
}, },
{ {
"key": "CFWheels",
"name": "CFWheels" "name": "CFWheels"
}, },
{ {
"name": "Python" "key": "CMake",
},
{
"name": "ZendFramework"
},
{
"name": "CakePHP"
},
{
"name": "Concrete5"
},
{
"name": "PlayFramework"
},
{
"name": "Terraform"
},
{
"name": "Elixir"
},
{
"name": "CMake" "name": "CMake"
}, },
{ {
"name": "Joomla" "key": "CUDA",
}, "name": "CUDA"
{
"name": "Coq"
},
{
"name": "Delphi"
},
{
"name": "Haskell"
},
{
"name": "Yii"
},
{
"name": "Java"
},
{
"name": "UnrealEngine"
},
{
"name": "AppceleratorTitanium"
},
{
"name": "CraftCMS"
},
{
"name": "ForceDotCom"
},
{
"name": "ExtJs"
},
{
"name": "MetaProgrammingSystem"
},
{
"name": "D"
},
{
"name": "Objective-C"
},
{
"name": "RhodesRhomobile"
},
{
"name": "R"
},
{
"name": "EPiServer"
},
{
"name": "Yeoman"
},
{
"name": "VisualStudio"
},
{
"name": "Processing"
},
{
"name": "Leiningen"
},
{
"name": "Stella"
},
{
"name": "Opa"
},
{
"name": "Drupal"
},
{
"name": "TurboGears2"
},
{
"name": "Idris"
},
{
"name": "Jboss"
},
{
"name": "CodeIgniter"
},
{
"name": "Qooxdoo"
},
{
"name": "Waf"
}, },
{ {
"name": "Sass" "key": "CakePHP",
"name": "CakePHP"
}, },
{ {
"name": "Lua" "key": "ChefCookbook",
"name": "ChefCookbook"
}, },
{ {
"key": "Clojure",
"name": "Clojure" "name": "Clojure"
}, },
{ {
"name": "IGORPro" "key": "CodeIgniter",
}, "name": "CodeIgniter"
{
"name": "Gradle"
},
{
"name": "Archives"
},
{
"name": "SynopsysVCS"
},
{
"name": "Ninja"
},
{
"name": "Tags"
},
{
"name": "OSX"
},
{
"name": "Dreamweaver"
},
{
"name": "CodeKit"
},
{
"name": "NotepadPP"
},
{
"name": "VisualStudioCode"
},
{
"name": "Mercurial"
},
{
"name": "BricxCC"
},
{
"name": "DartEditor"
},
{
"name": "Eclipse"
},
{
"name": "Cloud9"
},
{
"name": "TortoiseGit"
},
{
"name": "NetBeans"
},
{
"name": "GPG"
},
{
"name": "Espresso"
},
{
"name": "Redcar"
},
{
"name": "Xcode"
},
{
"name": "Matlab"
},
{
"name": "LyX"
},
{
"name": "SlickEdit"
},
{
"name": "Dropbox"
},
{
"name": "CVS"
},
{
"name": "Calabash"
},
{
"name": "JDeveloper"
},
{
"name": "Vagrant"
},
{
"name": "IPythonNotebook"
},
{
"name": "TextMate"
},
{
"name": "Ensime"
},
{
"name": "WebMethods"
},
{
"name": "VirtualEnv"
},
{
"name": "Emacs"
},
{
"name": "Momentics"
},
{
"name": "JetBrains"
},
{
"name": "SublimeText"
},
{
"name": "Kate"
},
{
"name": "ModelSim"
},
{
"name": "Redis"
},
{
"name": "KDevelop4"
},
{
"name": "Bazaar"
},
{
"name": "Linux"
},
{
"name": "Windows"
},
{
"name": "XilinxISE"
},
{
"name": "Lazarus"
},
{
"name": "EiffelStudio"
},
{
"name": "Anjuta"
},
{
"name": "Vim"
},
{
"name": "Otto"
},
{
"name": "MicrosoftOffice"
},
{
"name": "LibreOffice"
},
{
"name": "SBT"
}, },
{ {
"name": "MonoDevelop" "key": "CommonLisp",
"name": "CommonLisp"
}, },
{ {
"name": "SVN" "key": "Composer",
"name": "Composer"
}, },
{ {
"name": "FlexBuilder" "key": "Concrete5",
"name": "Concrete5"
} }
] ]
``` ```
......
...@@ -17,79 +17,84 @@ Example response: ...@@ -17,79 +17,84 @@ Example response:
```json ```json
[ [
{ {
"name": "C++" "key": "Android",
}, "name": "Android"
{
"name": "Docker"
},
{
"name": "Elixir"
},
{
"name": "LaTeX"
},
{
"name": "Grails"
},
{
"name": "Rust"
}, },
{ {
"name": "Nodejs" "key": "Auto-DevOps",
"name": "Auto-DevOps"
}, },
{ {
"name": "Ruby" "key": "Bash",
"name": "Bash"
}, },
{ {
"name": "Scala" "key": "C++",
"name": "C++"
}, },
{ {
"name": "Maven" "key": "Chef",
"name": "Chef"
}, },
{ {
"name": "Harp" "key": "Clojure",
"name": "Clojure"
}, },
{ {
"name": "Pelican" "key": "Crystal",
"name": "Crystal"
}, },
{ {
"name": "Hyde" "key": "Django",
"name": "Django"
}, },
{ {
"name": "Nanoc" "key": "Docker",
"name": "Docker"
}, },
{ {
"name": "Octopress" "key": "Elixir",
"name": "Elixir"
}, },
{ {
"name": "JBake" "key": "Go",
"name": "Go"
}, },
{ {
"name": "HTML" "key": "Gradle",
"name": "Gradle"
}, },
{ {
"name": "Hugo" "key": "Grails",
"name": "Grails"
}, },
{ {
"name": "Metalsmith" "key": "Julia",
"name": "Julia"
}, },
{ {
"name": "Hexo" "key": "LaTeX",
"name": "LaTeX"
}, },
{ {
"name": "Lektor" "key": "Laravel",
"name": "Laravel"
}, },
{ {
"name": "Doxygen" "key": "Maven",
"name": "Maven"
}, },
{ {
"name": "Brunch" "key": "Mono",
"name": "Mono"
}, },
{ {
"name": "Jekyll" "key": "Nodejs",
"name": "Nodejs"
}, },
{ {
"name": "Middleman" "key": "OpenShift",
"name": "OpenShift"
} }
] ]
``` ```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment