You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/share/templates/api/root/rel-contacts.tt

301 lines
10 KiB

<h[% level %] id="[% id %]">
[% IF uri -%]
<a href="[% uri %]" rel="collection">
[% END -%]
[% title %]
[% IF uri -%]
</a>
[% END -%]
</h[% level %]>
<h[% level + 1 %]>Description</h[% level + 1%]>
<p>
The <a href="#rel-contacts">contacts</a> item is used to specify the contact information of <a href="#rel-contracts">contracts</a> for customers, resellers and peering groups.
</p>
<p>
For customer contacts, the item MUST link to a <a href="#rel-resellers">reseller</a>, otherwise it MUST be unset.
</p>
<h[% level + 1 %]>Properties</h[% level + 1%]>
<ul id="[% id %]-props"></ul>
<script>
<![CDATA[
$(function() {
var items = [];
var props = '[% INSERT 'js/api/properties/contacts-item.json' | replace('\'', '\\\'') | replace("\n", ' ') | replace('\\\"', '\\\\\"') -%]';
var jprops = $.parseJSON(props);
for(var key in jprops.properties) {
var prop = jprops.properties[key];
items.push('<li><b>' + key + '</b> (<i>' + prop.type + '</i>): ' + prop.description + '</li>');
}
$('#[% id %]-props').append(items.join(''));
});
]]>
</script>
<h[% level + 1 %]>Relation Links</h[% level + 1%]>
<ul id="[% id %]-links"></ul>
<script>
<![CDATA[
$(function() {
var items = [];
var links = '[% INSERT 'js/api/links/contacts-item.json' | replace('\'', '\\\'') | replace("\n", ' ') | replace('\\\"', '\\\\\"') -%]';
var jlinks = $.parseJSON(links);
for(var key in jlinks._links) {
var link = jlinks._links[key];
items.push('<li><b>' + key + '</b> (<i>href</i>): ' + link.href + '</li>');
}
$('#[% id %]-links').append(items.join(''));
});
]]>
</script>
<p class="alert alert-error">If the contact is going to be used for identifying a reseller or peering (that is, when you create an <a href="#rel-contracts">contracts</a> item), you <b>MUST NOT</b> set the <i>ngcp:resellers</i> relation.</p>
<h[% level + 1 %]>Examples</h[% level + 1 %]>
<div class="examples">
<h[% level + 2 %]>Request available HTTP methods on the URI</h[% level + 2 %]>
<p>
[%
cmd = 'curl -i -X OPTIONS -H \'Connection: close\' --cert NGCP-API-client-certificate-1385650532.pem --cacert ca-cert.pem https://example.org:1443/api/contacts/';
INCLUDE helpers/api_command.tt cmd=cmd level=level+3;
request = [
'OPTIONS /api/contacts/ HTTP/1.1'
];
response = [
'HTTP/1.1 200 OK',
'Allow: GET, HEAD, OPTIONS, POST',
'<a href="#draft-wilde-accept-post">Accept-Post</a>: application/hal+json; profile="http://purl.org/sipwise/ngcp-api/#rel-contacts"',
];
INCLUDE helpers/api_req_res.tt request=request response=response level=level+3;
-%]
</p>
<h[% level + 2 %]>Request the entire <i>contacts</i> collection</h[% level + 2 %]>
<p>
[%
cmd = 'curl -i -X GET -H \'Connection: close\' --cert NGCP-API-client-certificate-1385650532.pem --cacert ca-cert.pem https://example.org:1443/api/contacts/';
INCLUDE helpers/api_command.tt cmd=cmd level=level+3;
request = [
'GET /api/contacts/ HTTP/1.1',
];
response = [
'HTTP/1.1 200 OK
Content-Type: application/hal+json; profile="http://purl.org/sipwise/ngcp-api/#rel-contacts"
ETag: "ni:/sha3-256;JH7uV8gwV5paX1NL1WK0YPo8KgAMUl+UwqW4c1tm9DA"
Last-Modified: Thu, 21 Nov 2013 16:34:07 GMT
Link: &lt;http://example.com/&gt;; <a href="#rfc6906">rel=profile</a>
<a href="#rfc5988">Link</a>: &lt;/api/contacts/&gt;; rel=self
Link: &lt;/api/resellers/?id=1&gt;; rel="http://example.com/#rel-contacts"
Link: &lt;/api/resellers/?id=2&gt;; rel="http://example.com/#rel-contacts"
{
"_embedded" : {
"ngcp:contacts" : [
{
"_links" : {
"collection" : {
"href" : "/api/contacts/"
},
"curies" : {
"href" : "http://example.com/#rel-{rel}",
"name" : "ngcp",
"templated" : true
},
"ngcp:resellers" : {
"href" : "/api/resellers/?id=1"
},
"profile" : {
"href" : "http://example.com/"
},
"self" : {
"href" : "/api/contacts/?id=1"
}
},
"city" : null,
"company" : null,
"country" : null,
"email" : "default-customer@default.invalid",
"firstname" : "Default",
"lastname" : "Contact",
"phonenumber" : null,
"postcode" : null,
"street" : null
},
{
"_links" : {
"collection" : {
"href" : "/api/contacts/"
},
"curies" : {
"href" : "http://example.com/#rel-{rel}",
"name" : "ngcp",
"templated" : true
},
"profile" : {
"href" : "http://example.com/"
},
"self" : {
"href" : "/api/contacts/?id=2"
}
},
"city" : "McMurdo",
"company" : "Internet Widgets",
"country" : "AQ",
"email" : "a.customr@mail.example.net",
"firstname" : "Any",
"lastname" : "Customr",
"phonenumber" : null,
"postcode" : "000045",
"street" : null
}
]
},
"_links" : {
"curies" : {
"href" : "http://example.com/#rel-{rel}",
"name" : "ngcp",
"templated" : true
},
"ngcp:contacts" : [
{
"href" : "/api/resellers/?id=1"
},
{
"href" : "/api/resellers/?id=2"
}
],
"profile" : {
"href" : "http://example.com/"
},
"self" : {
"href" : "/api/contacts/"
}
}
}',
];
INCLUDE helpers/api_req_res.tt request=request response=response level=level+3;
-%]
</p>
<h[% level + 2 %]>Request a specific <i>contacts</i> item</h[% level + 2 %]>
<p>
TODO
</p>
<h[% level + 2 %]>Create a new <i>contacts</i> entry</h[% level + 2 %]>
<p>
[%
cmd = 'curl -i -X POST -H \'Connection: close\' --cert NGCP-API-client-certificate-1385650532.pem --cacert ca-cert.pem https://example.org:1443/api/contacts/ --data-binary \'{ "firstname": "John", "lastname": "Doe", "email": "john.doe@example.org", "city": null, "company": null, "country": null, "phonenumber": null, "postcode": null, "street": null, "_links" : { "http://purl.org/sipwise/ngcp-api/#rel-resellers": { "href": "/api/resellers/?id=1" } } }\' -H \'Content-Type: application/hal+json\'';
INCLUDE helpers/api_command.tt cmd=cmd level=level+3;
request = [
'POST /api/contacts/ HTTP/1.1',
'Content-Type: application/hal+json',
'',
'{
"firstname": "John",
"lastname": "Doe",
"email": "john.doe@example.org",
"city": null,
"company": null,
"country": null,
"phonenumber": null,
"postcode": null,
"street": null,
"_links" : {
"http://purl.org/sipwise/ngcp-api/#rel-resellers": {
"href": "/api/resellers/?id=1"
}
}
}',
];
response = [
'HTTP/1.1 201 Created',
'Location: /api/contacts/?id=10',
];
INCLUDE helpers/api_req_res.tt request=request response=response level=level+3;
-%]
</p>
<h[% level + 2 %]>Update an existing <i>contacts</i> entry</h[% level + 2 %]>
<p>
[%
cmd = 'curl -i -X PUT -H \'Connection: close\' --cert NGCP-API-client-certificate-1385650532.pem --cacert ca-cert.pem https://example.org:1443/api/contacts/?id=10 --data-binary \'{ "firstname": "John", "lastname": "Doe", "email": "john.doe@example.org", "city": null, "company": null, "country": null, "phonenumber": null, "postcode": null, "street": null, "_links" : { "http://purl.org/sipwise/ngcp-api/#rel-resellers": { "href": "/api/resellers/?id=1" } } }\' -H \'Content-Type: application/hal+json\' -H \'If-Match: *\' -H \'Prefer: return=minimal\'';
INCLUDE helpers/api_command.tt cmd=cmd extended=1 level=level+3;
request = [
'PUT /api/contacts/?id=10 HTTP/1.1',
'Content-Type: application/hal+json',
'If-Match: *',
'Prefer: return=minimal',
'',
'{
"firstname": "John",
"lastname": "Doe",
"email": "john.doe@other.example.org",
"city": null,
"company": null,
"country": null,
"phonenumber": null,
"postcode": null,
"street": null,
"_links" : {
"http://purl.org/sipwise/ngcp-api/#rel-resellers": {
"href": "/api/resellers/?id=1"
}
}
}',
];
response = [
'HTTP/1.1 204 No Content',
'Preference-Applied: return=minimal',
];
INCLUDE helpers/api_req_res.tt request=request response=response level=level+3;
-%]
</p>
<h[% level + 2 %]>Update specific fields of an existing <i>contacts</i> entry</h[% level + 2 %]>
<p>
[%
cmd = 'curl -i -X PATCH -H \'Connection: close\' --cert NGCP-API-client-certificate-1385650532.pem --cacert ca-cert.pem https://example.org:1443/api/contacts/?id=10 --data-binary \'[ { "op": "replace", "path": "/email", "value": "other.john.doe@example.org" } ]\' -H \'Content-Type: application/json-patch+json\' -H \'If-Match: *\' -H \'Prefer: return=minimal\'';
INCLUDE helpers/api_command.tt cmd=cmd extended=1 level=level+3;
request = [
'PATCH /api/contacts/?id=10 HTTP/1.1',
'Content-Type: application/json-patch+json',
'If-Match: *',
'Prefer: return=minimal',
'',
'[
{
"op": "replace",
"path": "/email",
"value": "other.john.doe@example.org"
},
{
"op": "replace",
"path": "/street",
"value": "Some Street"
}
]',
];
response = [
'HTTP/1.1 204 No Content',
'Preference-Applied: return=minimal',
];
INCLUDE helpers/api_req_res.tt request=request response=response level=level+3;
-%]
</p>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]