Files
2017-02-14 13:59:07 -08:00

74 lines
3.5 KiB
Plaintext

---
title: Rancher API - {{.schemaId}}
layout: {{.layout}}
version: {{.version}}
lang: {{.language}}
---
## {{.schemaId | capitalize}}
{{.resourceDescription}}
{{if or $.writeableFieldMap $.readOnlyFieldMap}}
### Resource Fields
{{if $.writeableFieldMap}}
#### Writeable Fields
Field | Type | Create | Update | Default | Notes
---|---|---|---|---|---
{{range $key, $value := .writeableFieldMap}}{{$key}} | {{if $value.TypeURL}}{{$value.TypeURL}}{{else}}{{$value.Type}}{{end}} | {{if $value.Create}}{{if $value.Required}}Yes{{else}}Optional{{end}}{{else}}-{{end}} | {{if $value.Update}}Yes{{else}}-{{end}} | {{if $value.Default}}{{$value.Default}}{{else}}-{{end}} | {{$value.Description}}
{{end}}{{end}}
{{if $.readOnlyFieldMap}}
#### Read Only Fields
Field | Type | Notes
---|---|---
{{range $key, $value := .readOnlyFieldMap}}{{$key}} | {{if $value.TypeURL}}{{$value.TypeURL}}{{else}}{{$value.Type}}{{end}} | {{$value.Description}}
{{end}}{{end}}
<br>
Please read more about the [common resource fields]({{"{{"}}site.baseurl{{"}}"}}/rancher/{{"{{"}}page.version{{"}}"}}/{{"{{"}}page.lang{{"}}"}}/api/common/). These fields are read only and applicable to almost every resource. We have segregated them from the list above.{{end}}
{{if .operationMap }}
### Operations
{::options parse_block_html="true" /}{{end}}
{{range $key, $value := .operationMap}}{{if eq $key "Create"}}<a id="create"></a>{{end}}{{if eq $key "Update"}}<a id="update"></a>{{end}}{{if eq $key "Delete"}}<a id="delete"></a>{{end}}
<div class="action"><span class="header">{{$key}}<span class="headerright">{{$value.Method}}: <code>{{$value.ActionURL}}</code></span></span>
<div class="action-contents"> {% highlight json %}
curl -u "${{"{"}}RANCHER_ACCESS_KEY{{"}"}}:${{"{"}}RANCHER_SECRET_KEY{{"}"}}" \
-X {{$value.Method}} \
{{if ne $value.Input.InputJSON ""}}-H 'Content-Type: application/json' \
-d '{{$value.Input.InputJSON}}' {{end}}'http://${{"{"}}RANCHER_URL{{"}"}}:8080{{$value.ActionURL}}'
{% endhighlight %}
</div></div>
{{end}}
{{if $.actionMap}}
### Actions
{{range $actionName, $action := .actionMap}}
<div class="action" id={{`"`}}{{$actionName}}{{`"`}}>
<span class="header">
{{$actionName}}
<span class="headerright">{{$action.Method}}: <code>{{$action.ActionURL}}</code></span></span>
<div class="action-contents">
{{$action.Description}}
<br>
<span class="input">
<strong>Input:</strong>{{if ne $action.Input.Name "" }} <a href="{{"{{"}}site.baseurl{{"}}"}}/rancher/{{"{{"}}page.version{{"}}"}}/{{"{{"}}page.lang{{"}}"}}/api/api-resources/{{$action.Input.Name}}/">{{$action.Input.Name | capitalize}}</a></span>
{{if $action.Input.FieldMap}}
Field | Type | Required | Default | Notes
---|---|---|---|---
{{range $key, $value := $action.Input.FieldMap}}{{$key}} | {{$value.TypeURL}} | {{if $value.Required}}Yes{{else}}No{{end}} | {{$value.Default}} | {{$value.Description}}{{end}}<br>{{end}}{{else}}This action has no inputs</span>{{end}}
<br>
{% highlight json %}
curl -u "${{"{"}}RANCHER_ACCESS_KEY{{"}"}}:${{"{"}}RANCHER_SECRET_KEY{{"}"}}" \
-X {{$action.Method}} \
{{if ne $action.Input.InputJSON "{}"}}-H 'Content-Type: application/json' \
-d '{{$action.Input.InputJSON}}' {{end}}'http://${{"{"}}RANCHER_URL{{"}"}}:8080{{$action.ActionURL}}'
{% endhighlight %}
<br>
{{if ne $action.Output "" }}<span class="output"><strong>Output:</strong> An updated copy of the <a href="{{"{{"}}site.baseurl{{"}}"}}/rancher/{{"{{"}}page.version{{"}}"}}/{{"{{"}}page.lang{{"}}"}}/api/api-resources/{{$action.Output}}/">{{$action.Output}}</a> resource</span>{{end}}
</div></div>
{{end}}
{{end}}