# Indexing Jobs ## Create `knowledge_bases.indexing_jobs.create(IndexingJobCreateParams**kwargs) -> IndexingJobCreateResponse` **post** `/v2/gen-ai/indexing_jobs` To start an indexing job for a knowledge base, send a POST request to `/v2/gen-ai/indexing_jobs`. ### Parameters - **data\_source\_uuids:** `List[str]` List of data source ids to index, if none are provided, all data sources will be indexed - **knowledge\_base\_uuid:** `str` Knowledge base id ### Returns - `class IndexingJobCreateResponse` StartKnowledgeBaseIndexingJobOutput description - **job:** `Optional[APIIndexingJob]` IndexingJob description ### Example ```python from gradient import Gradient client = Gradient() indexing_job = client.knowledge_bases.indexing_jobs.create() print(indexing_job.job) ``` ## Retrieve `knowledge_bases.indexing_jobs.retrieve(struuid) -> IndexingJobRetrieveResponse` **get** `/v2/gen-ai/indexing_jobs/{uuid}` To get status of an indexing Job for a knowledge base, send a GET request to `/v2/gen-ai/indexing_jobs/{uuid}`. ### Parameters - **uuid:** `str` ### Returns - `class IndexingJobRetrieveResponse` GetKnowledgeBaseIndexingJobOutput description - **job:** `Optional[APIIndexingJob]` IndexingJob description ### Example ```python from gradient import Gradient client = Gradient() indexing_job = client.knowledge_bases.indexing_jobs.retrieve( "uuid", ) print(indexing_job.job) ``` ## List `knowledge_bases.indexing_jobs.list(IndexingJobListParams**kwargs) -> IndexingJobListResponse` **get** `/v2/gen-ai/indexing_jobs` To list all indexing jobs for a knowledge base, send a GET request to `/v2/gen-ai/indexing_jobs`. ### Parameters - **page:** `int` Page number. - **per\_page:** `int` Items per page. ### Returns - `class IndexingJobListResponse` Indexing jobs - **jobs:** `Optional[List[APIIndexingJob]]` The indexing jobs - **completed\_datasources:** `Optional[int]` Number of datasources indexed completed - **created\_at:** `Optional[datetime]` Creation date / time - **data\_source\_uuids:** `Optional[List[str]]` - **finished\_at:** `Optional[datetime]` - **knowledge\_base\_uuid:** `Optional[str]` Knowledge base id - **phase:** `Optional[Literal["BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", 4 more]]` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - **started\_at:** `Optional[datetime]` - **status:** `Optional[Literal["INDEX_JOB_STATUS_UNKNOWN", "INDEX_JOB_STATUS_PARTIAL", "INDEX_JOB_STATUS_IN_PROGRESS", 4 more]]` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - **tokens:** `Optional[int]` Number of tokens - **total\_datasources:** `Optional[int]` Number of datasources being indexed - **total\_items\_failed:** `Optional[str]` Total Items Failed - **total\_items\_indexed:** `Optional[str]` Total Items Indexed - **total\_items\_skipped:** `Optional[str]` Total Items Skipped - **updated\_at:** `Optional[datetime]` Last modified - **uuid:** `Optional[str]` Unique id - **links:** `Optional[APILinks]` Links to other pages - **meta:** `Optional[APIMeta]` Meta information about the data set ### Example ```python from gradient import Gradient client = Gradient() indexing_jobs = client.knowledge_bases.indexing_jobs.list() print(indexing_jobs.jobs) ``` ## Retrieve Data Sources `knowledge_bases.indexing_jobs.retrieve_data_sources(strindexing_job_uuid) -> IndexingJobRetrieveDataSourcesResponse` **get** `/v2/gen-ai/indexing_jobs/{indexing_job_uuid}/data_sources` To list all datasources for an indexing job, send a GET request to `/v2/gen-ai/indexing_jobs/{indexing_job_uuid}/data_sources`. ### Parameters - **indexing\_job\_uuid:** `str` ### Returns - `class IndexingJobRetrieveDataSourcesResponse` - **indexed\_data\_sources:** `Optional[List[APIIndexedDataSource]]` - **completed\_at:** `Optional[datetime]` Timestamp when data source completed indexing - **data\_source\_uuid:** `Optional[str]` Uuid of the indexed data source - **error\_details:** `Optional[str]` A detailed error description - **error\_msg:** `Optional[str]` A string code provinding a hint which part of the system experienced an error - **failed\_item\_count:** `Optional[str]` Total count of files that have failed - **indexed\_file\_count:** `Optional[str]` Total count of files that have been indexed - **indexed\_item\_count:** `Optional[str]` Total count of files that have been indexed - **removed\_item\_count:** `Optional[str]` Total count of files that have been removed - **skipped\_item\_count:** `Optional[str]` Total count of files that have been skipped - **started\_at:** `Optional[datetime]` Timestamp when data source started indexing - **status:** `Optional[Literal["DATA_SOURCE_STATUS_UNKNOWN", "DATA_SOURCE_STATUS_IN_PROGRESS", "DATA_SOURCE_STATUS_UPDATED", 3 more]]` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - **total\_bytes:** `Optional[str]` Total size of files in data source in bytes - **total\_bytes\_indexed:** `Optional[str]` Total size of files in data source in bytes that have been indexed - **total\_file\_count:** `Optional[str]` Total file count in the data source ### Example ```python from gradient import Gradient client = Gradient() response = client.knowledge_bases.indexing_jobs.retrieve_data_sources( "indexing_job_uuid", ) print(response.indexed_data_sources) ``` ## Update Cancel `knowledge_bases.indexing_jobs.update_cancel(strpath_uuid, IndexingJobUpdateCancelParams**kwargs) -> IndexingJobUpdateCancelResponse` **put** `/v2/gen-ai/indexing_jobs/{uuid}/cancel` To cancel an indexing job for a knowledge base, send a PUT request to `/v2/gen-ai/indexing_jobs/{uuid}/cancel`. ### Parameters - **uuid:** `str` - **uuid:** `str` ### Returns - `class IndexingJobUpdateCancelResponse` CancelKnowledgeBaseIndexingJobOutput description - **job:** `Optional[APIIndexingJob]` IndexingJob description ### Example ```python from gradient import Gradient client = Gradient() response = client.knowledge_bases.indexing_jobs.update_cancel( path_uuid="\"123e4567-e89b-12d3-a456-426614174000\"", ) print(response.job) ``` ## Domain Types ### API Indexed Data Source - `class APIIndexedDataSource` - **completed\_at:** `Optional[datetime]` Timestamp when data source completed indexing - **data\_source\_uuid:** `Optional[str]` Uuid of the indexed data source - **error\_details:** `Optional[str]` A detailed error description - **error\_msg:** `Optional[str]` A string code provinding a hint which part of the system experienced an error - **failed\_item\_count:** `Optional[str]` Total count of files that have failed - **indexed\_file\_count:** `Optional[str]` Total count of files that have been indexed - **indexed\_item\_count:** `Optional[str]` Total count of files that have been indexed - **removed\_item\_count:** `Optional[str]` Total count of files that have been removed - **skipped\_item\_count:** `Optional[str]` Total count of files that have been skipped - **started\_at:** `Optional[datetime]` Timestamp when data source started indexing - **status:** `Optional[Literal["DATA_SOURCE_STATUS_UNKNOWN", "DATA_SOURCE_STATUS_IN_PROGRESS", "DATA_SOURCE_STATUS_UPDATED", 3 more]]` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - **total\_bytes:** `Optional[str]` Total size of files in data source in bytes - **total\_bytes\_indexed:** `Optional[str]` Total size of files in data source in bytes that have been indexed - **total\_file\_count:** `Optional[str]` Total file count in the data source ### API Indexing Job - `class APIIndexingJob` IndexingJob description - **completed\_datasources:** `Optional[int]` Number of datasources indexed completed - **created\_at:** `Optional[datetime]` Creation date / time - **data\_source\_uuids:** `Optional[List[str]]` - **finished\_at:** `Optional[datetime]` - **knowledge\_base\_uuid:** `Optional[str]` Knowledge base id - **phase:** `Optional[Literal["BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING", 4 more]]` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - **started\_at:** `Optional[datetime]` - **status:** `Optional[Literal["INDEX_JOB_STATUS_UNKNOWN", "INDEX_JOB_STATUS_PARTIAL", "INDEX_JOB_STATUS_IN_PROGRESS", 4 more]]` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - **tokens:** `Optional[int]` Number of tokens - **total\_datasources:** `Optional[int]` Number of datasources being indexed - **total\_items\_failed:** `Optional[str]` Total Items Failed - **total\_items\_indexed:** `Optional[str]` Total Items Indexed - **total\_items\_skipped:** `Optional[str]` Total Items Skipped - **updated\_at:** `Optional[datetime]` Last modified - **uuid:** `Optional[str]` Unique id