{% ckan_extends %}

{% block custom %}
  {{ super() }}

  {% if examples %}
  {% call register_example('curl', 'request_filter_custom') %}
  <pre class="example-curl"><code class="language-bash"
>curl {{ h.url_for('api.action', logic_function='datastore_search', qualified=True) }} \
-H"Authorization:$API_TOKEN" -d '
{
  "resource_id": "{{ resource_id }}",
  "filters": {{ examples.text_column_filters_object | tojson(indent=2) | indent(2) }}
}'</code></pre>
  {% endcall %}

  {% call register_example('curl', 'request_sql_custom') %}
  <pre class="example-curl"><code class="language-bash"
>curl {{ h.url_for('api.action', logic_function='datastore_search_sql', qualified=True) }} \
  -H"Authorization:$API_TOKEN" -d @- &lt;&lt;END
{
  "sql": "SELECT * FROM \"{{ resource_id }}\" WHERE {{ examples.text_column_name_sql }} LIKE 'jones'"
}
END</code></pre>
  {% endcall %}

  {% call register_example('curl', 'request_insert') %}
  <pre class="example-curl"><code class="language-bash"
>curl {{ h.url_for('api.action', logic_function='datastore_upsert', qualified=True) }} \
-H"Authorization:$API_TOKEN" -d '
{
  "resource_id": "{{ resource_id }}",
  "method": "insert",
  "records: [
    {{ examples.insert_record_object | tojson(indent=2) | indent(4) }}
  ]
}'</code></pre>
  {% endcall %}

  {% call register_example('curl', 'request_update') %}
  <pre class="example-curl"><code class="language-bash"
>curl {{ h.url_for('api.action', logic_function='datastore_upsert', qualified=True) }} \
-H"Authorization:$API_TOKEN" -d '
{
  "resource_id": "{{ resource_id }}",
  "method": "update",
  "records: [
    {{ examples.update_record_object | tojson(indent=2) | indent(4) }}
  ]
}'</code></pre>
  {% endcall %}

  {% call register_example('curl', 'request_delete') %}
  <pre class="example-curl"><code class="language-bash"
>curl {{ h.url_for('api.action', logic_function='datastore_records_delete', qualified=True) }} \
-H"Authorization:$API_TOKEN" -d '
{
  "resource_id": "{{ resource_id }}",
  "filters": {{ examples.unique_filter_object | tojson(indent=2) | indent(2) }}
}'</code></pre>
  {% endcall %}
  {% endif %}
{% endblock %}
