Reorder model routes - Barndoor Documentation

Reorder model routes

cURL

curl --request PUT \
  --url https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "entries": [\
    {\
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",\
      "priority": 123\
    }\
  ]
}
'```

### Python

```python
import requests

url = "https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder"

payload = { "entries": [\
        {\
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",\
            "priority": 123\
        }\
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

JavaScript (Fetch)

const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({entries: [{id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', priority: 123}]})
};

fetch('https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "PUT",\
  CURLOPT_POSTFIELDS => json_encode([\
    'entries' => [\
        [\
                'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',\
                'priority' => 123\
        ]\
    ]\
  ]),\
  CURLOPT_HTTPHEADER => [\
    "Authorization: Bearer <token>",\
    "Content-Type: application/json"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder"

payload := strings.NewReader("{\n  \"entries\": [\n    {\n      \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n      \"priority\": 123\n    }\n  ]\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Java (Unirest)

HttpResponse<String> response = Unirest.put("https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"entries\": [\n    {\n      \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n      \"priority\": 123\n    }\n  ]\n}")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://app.barndoor.ai/api/llm-gateway/admin/model-mappings/reorder")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"entries\": [\n    {\n      \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n      \"priority\": 123\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body

Response

200

{
  "ok": true
}

Authorizations

Authorization
string
header
required
JWT obtained through Barndoor's authentication flow. Pass the token verbatim in Authorization: Bearer <token>. Use the Barndoor SDK's loginInteractive() helper to obtain a token in scripts and notebooks.

Body

entries
object[]
required

Response

200 - application/json
Routes reordered

ok
boolean
Example: true