CreateBatchFileSegments
Create multiple file segment objects through a batch API call.
POST
/
v1
/
namespaces
/
{tenant_meta.namespace}
/
batch
/
file-segments
CreateBatchFileSegments
curl --request POST \
--url https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments \
--header 'Content-Type: application/json' \
--data '
{
"spec": {
"data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": [
"<string>"
]
},
"meta": {
"name": "<string>",
"annotations": {},
"description": "<string>",
"index_data": {},
"parent_kind": "<string>",
"parent_uuid": "<string>",
"tags": [
"<string>"
]
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": {
"vector": [
123
]
},
"signature": "<string>"
}
]
}
}
]
},
"tenant_meta": {}
}
'import requests
url = "https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments"
payload = {
"spec": { "data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": ["<string>"]
},
"meta": {
"name": "<string>",
"annotations": {},
"description": "<string>",
"index_data": {},
"parent_kind": "<string>",
"parent_uuid": "<string>",
"tags": ["<string>"]
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": { "vector": [123] },
"signature": "<string>"
}
]
}
}
] },
"tenant_meta": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
spec: {
data: [
{
context: {id: '<string>', type: 'CONTEXT_TYPE_UNSPECIFIED', tags: ['<string>']},
meta: {
name: '<string>',
annotations: {},
description: '<string>',
index_data: {},
parent_kind: '<string>',
parent_uuid: '<string>',
tags: ['<string>']
},
spec: {
file_hash: '<string>',
language: 'LANGUAGE_UNSPECIFIED',
project_uuid: '<string>',
scope: 'DEPENDENCY_SCOPE_UNSPECIFIED',
segmenter_version: 123,
segments: [
{
code_size: '<string>',
content_kind: 'SEGMENT_CONTENT_KIND_UNSPECIFIED',
embedding: {vector: [123]},
signature: '<string>'
}
]
}
}
]
},
tenant_meta: {}
})
};
fetch('https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments', 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://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'spec' => [
'data' => [
[
'context' => [
'id' => '<string>',
'type' => 'CONTEXT_TYPE_UNSPECIFIED',
'tags' => [
'<string>'
]
],
'meta' => [
'name' => '<string>',
'annotations' => [
],
'description' => '<string>',
'index_data' => [
],
'parent_kind' => '<string>',
'parent_uuid' => '<string>',
'tags' => [
'<string>'
]
],
'spec' => [
'file_hash' => '<string>',
'language' => 'LANGUAGE_UNSPECIFIED',
'project_uuid' => '<string>',
'scope' => 'DEPENDENCY_SCOPE_UNSPECIFIED',
'segmenter_version' => 123,
'segments' => [
[
'code_size' => '<string>',
'content_kind' => 'SEGMENT_CONTENT_KIND_UNSPECIFIED',
'embedding' => [
'vector' => [
123
]
],
'signature' => '<string>'
]
]
]
]
]
],
'tenant_meta' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments"
payload := strings.NewReader("{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments")
.header("Content-Type", "application/json")
.body("{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"name": "<string>",
"annotations": {},
"create_time": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"description": "<string>",
"index_data": {
"data": [
"<string>"
],
"search_score": 123,
"tenant": "<string>",
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"kind": "<string>",
"parent_kind": "<string>",
"parent_uuid": "<string>",
"references": {},
"tags": [
"<string>"
],
"update_time": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"upsert_time": "2023-11-07T05:31:56Z",
"version": "<string>"
},
"spec": {
"data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": [
"<string>"
],
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"meta": {
"name": "<string>",
"annotations": {},
"create_time": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"description": "<string>",
"index_data": {
"data": [
"<string>"
],
"search_score": 123,
"tenant": "<string>",
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"kind": "<string>",
"parent_kind": "<string>",
"parent_uuid": "<string>",
"references": {},
"tags": [
"<string>"
],
"update_time": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"upsert_time": "2023-11-07T05:31:56Z",
"version": "<string>"
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": {
"vector": [
123
]
},
"signature": "<string>"
}
]
},
"tenant_meta": {
"namespace": "<string>"
},
"uuid": "<string>"
}
]
},
"tenant_meta": {
"namespace": "<string>"
},
"uuid": "<string>"
}{
"code": 123,
"details": [
{
"@type": "<string>"
}
],
"message": "<string>"
}Path Parameters
Namespaces are a way to organize organizational units into virtual groupings of resources. Namespaces must be a fully qualified name, for example, the child namespace of namespace "endor.prod" called "app" is called "endor.prod.app".
Body
application/json
Response
A successful response.
Request used to create or delete multiple file segment objects.
Was this page helpful?
⌘I
CreateBatchFileSegments
curl --request POST \
--url https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments \
--header 'Content-Type: application/json' \
--data '
{
"spec": {
"data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": [
"<string>"
]
},
"meta": {
"name": "<string>",
"annotations": {},
"description": "<string>",
"index_data": {},
"parent_kind": "<string>",
"parent_uuid": "<string>",
"tags": [
"<string>"
]
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": {
"vector": [
123
]
},
"signature": "<string>"
}
]
}
}
]
},
"tenant_meta": {}
}
'import requests
url = "https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments"
payload = {
"spec": { "data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": ["<string>"]
},
"meta": {
"name": "<string>",
"annotations": {},
"description": "<string>",
"index_data": {},
"parent_kind": "<string>",
"parent_uuid": "<string>",
"tags": ["<string>"]
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": { "vector": [123] },
"signature": "<string>"
}
]
}
}
] },
"tenant_meta": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
spec: {
data: [
{
context: {id: '<string>', type: 'CONTEXT_TYPE_UNSPECIFIED', tags: ['<string>']},
meta: {
name: '<string>',
annotations: {},
description: '<string>',
index_data: {},
parent_kind: '<string>',
parent_uuid: '<string>',
tags: ['<string>']
},
spec: {
file_hash: '<string>',
language: 'LANGUAGE_UNSPECIFIED',
project_uuid: '<string>',
scope: 'DEPENDENCY_SCOPE_UNSPECIFIED',
segmenter_version: 123,
segments: [
{
code_size: '<string>',
content_kind: 'SEGMENT_CONTENT_KIND_UNSPECIFIED',
embedding: {vector: [123]},
signature: '<string>'
}
]
}
}
]
},
tenant_meta: {}
})
};
fetch('https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments', 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://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'spec' => [
'data' => [
[
'context' => [
'id' => '<string>',
'type' => 'CONTEXT_TYPE_UNSPECIFIED',
'tags' => [
'<string>'
]
],
'meta' => [
'name' => '<string>',
'annotations' => [
],
'description' => '<string>',
'index_data' => [
],
'parent_kind' => '<string>',
'parent_uuid' => '<string>',
'tags' => [
'<string>'
]
],
'spec' => [
'file_hash' => '<string>',
'language' => 'LANGUAGE_UNSPECIFIED',
'project_uuid' => '<string>',
'scope' => 'DEPENDENCY_SCOPE_UNSPECIFIED',
'segmenter_version' => 123,
'segments' => [
[
'code_size' => '<string>',
'content_kind' => 'SEGMENT_CONTENT_KIND_UNSPECIFIED',
'embedding' => [
'vector' => [
123
]
],
'signature' => '<string>'
]
]
]
]
]
],
'tenant_meta' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments"
payload := strings.NewReader("{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments")
.header("Content-Type", "application/json")
.body("{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/batch/file-segments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"spec\": {\n \"data\": [\n {\n \"context\": {\n \"id\": \"<string>\",\n \"type\": \"CONTEXT_TYPE_UNSPECIFIED\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"meta\": {\n \"name\": \"<string>\",\n \"annotations\": {},\n \"description\": \"<string>\",\n \"index_data\": {},\n \"parent_kind\": \"<string>\",\n \"parent_uuid\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n },\n \"spec\": {\n \"file_hash\": \"<string>\",\n \"language\": \"LANGUAGE_UNSPECIFIED\",\n \"project_uuid\": \"<string>\",\n \"scope\": \"DEPENDENCY_SCOPE_UNSPECIFIED\",\n \"segmenter_version\": 123,\n \"segments\": [\n {\n \"code_size\": \"<string>\",\n \"content_kind\": \"SEGMENT_CONTENT_KIND_UNSPECIFIED\",\n \"embedding\": {\n \"vector\": [\n 123\n ]\n },\n \"signature\": \"<string>\"\n }\n ]\n }\n }\n ]\n },\n \"tenant_meta\": {}\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"name": "<string>",
"annotations": {},
"create_time": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"description": "<string>",
"index_data": {
"data": [
"<string>"
],
"search_score": 123,
"tenant": "<string>",
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"kind": "<string>",
"parent_kind": "<string>",
"parent_uuid": "<string>",
"references": {},
"tags": [
"<string>"
],
"update_time": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"upsert_time": "2023-11-07T05:31:56Z",
"version": "<string>"
},
"spec": {
"data": [
{
"context": {
"id": "<string>",
"type": "CONTEXT_TYPE_UNSPECIFIED",
"tags": [
"<string>"
],
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"meta": {
"name": "<string>",
"annotations": {},
"create_time": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"description": "<string>",
"index_data": {
"data": [
"<string>"
],
"search_score": 123,
"tenant": "<string>",
"will_be_deleted_at": "2023-11-07T05:31:56Z"
},
"kind": "<string>",
"parent_kind": "<string>",
"parent_uuid": "<string>",
"references": {},
"tags": [
"<string>"
],
"update_time": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"upsert_time": "2023-11-07T05:31:56Z",
"version": "<string>"
},
"spec": {
"file_hash": "<string>",
"language": "LANGUAGE_UNSPECIFIED",
"project_uuid": "<string>",
"scope": "DEPENDENCY_SCOPE_UNSPECIFIED",
"segmenter_version": 123,
"segments": [
{
"code_size": "<string>",
"content_kind": "SEGMENT_CONTENT_KIND_UNSPECIFIED",
"embedding": {
"vector": [
123
]
},
"signature": "<string>"
}
]
},
"tenant_meta": {
"namespace": "<string>"
},
"uuid": "<string>"
}
]
},
"tenant_meta": {
"namespace": "<string>"
},
"uuid": "<string>"
}{
"code": 123,
"details": [
{
"@type": "<string>"
}
],
"message": "<string>"
}