Merged in feature/textExtractionsPart3 (pull request #195)
enrich doc responses * enrich doc responses
This commit is contained in:
+129
-20
@@ -574,24 +574,69 @@ type DocClient struct {
|
||||
Name ClientName `json:"name"`
|
||||
}
|
||||
|
||||
// Document The document properties.
|
||||
type Document struct {
|
||||
// DocumentEnriched Enriched document details with additional metadata
|
||||
type DocumentEnriched struct {
|
||||
// ClientId The client external id
|
||||
ClientId ClientID `json:"client_id"`
|
||||
|
||||
// Fields The fields and the value for the document
|
||||
Fields map[string]interface{} `json:"fields"`
|
||||
|
||||
// Filename Original filename of the document
|
||||
Filename *string `json:"filename,omitempty"`
|
||||
|
||||
// FolderId Parent folder ID, null if document is not in a folder
|
||||
FolderId *openapi_types.UUID `json:"folderId,omitempty"`
|
||||
|
||||
// HasTextRecord Whether a text extraction (field extraction) record exists for this document
|
||||
HasTextRecord bool `json:"hasTextRecord"`
|
||||
|
||||
// Hash The document hash
|
||||
Hash Hash `json:"hash"`
|
||||
|
||||
// Id The document id.
|
||||
Id DocumentID `json:"id"`
|
||||
|
||||
// Labels All labels applied to this document
|
||||
Labels []LabelRecord `json:"labels"`
|
||||
|
||||
// OriginalPath Original path provided during upload (immutable)
|
||||
OriginalPath *string `json:"originalPath,omitempty"`
|
||||
|
||||
// TextRecord Field extraction with version information
|
||||
TextRecord *FieldExtractionResponse `json:"textRecord,omitempty"`
|
||||
}
|
||||
|
||||
// DocumentID The document id.
|
||||
type DocumentID = openapi_types.UUID
|
||||
|
||||
// DocumentInFolder Document within a folder with enriched metadata (lighter format, excludes client_id and fields)
|
||||
type DocumentInFolder struct {
|
||||
// Filename Original filename of the document
|
||||
Filename *string `json:"filename,omitempty"`
|
||||
|
||||
// FolderId Parent folder ID
|
||||
FolderId *openapi_types.UUID `json:"folderId,omitempty"`
|
||||
|
||||
// HasTextRecord Whether a text extraction record exists for this document
|
||||
HasTextRecord bool `json:"hasTextRecord"`
|
||||
|
||||
// Hash The document hash
|
||||
Hash Hash `json:"hash"`
|
||||
|
||||
// Id The document id.
|
||||
Id DocumentID `json:"id"`
|
||||
|
||||
// Labels All labels applied to this document
|
||||
Labels []LabelRecord `json:"labels"`
|
||||
|
||||
// OriginalPath Original path provided during upload (immutable)
|
||||
OriginalPath *string `json:"originalPath,omitempty"`
|
||||
|
||||
// TextRecord Field extraction with version information
|
||||
TextRecord *FieldExtractionResponse `json:"textRecord,omitempty"`
|
||||
}
|
||||
|
||||
// DocumentSummary The document summary properties.
|
||||
type DocumentSummary struct {
|
||||
// Hash The document hash
|
||||
@@ -1058,6 +1103,12 @@ type ListClientFoldersParams struct {
|
||||
Metrics *bool `form:"metrics,omitempty" json:"metrics,omitempty"`
|
||||
}
|
||||
|
||||
// GetDocumentParams defines parameters for GetDocument.
|
||||
type GetDocumentParams struct {
|
||||
// TextRecord When true, includes the full text extraction record in the response
|
||||
TextRecord *bool `form:"textRecord,omitempty" json:"textRecord,omitempty"`
|
||||
}
|
||||
|
||||
// GetCurrentFieldExtractionParams defines parameters for GetCurrentFieldExtraction.
|
||||
type GetCurrentFieldExtractionParams struct {
|
||||
// DocumentId The document ID
|
||||
@@ -1079,6 +1130,12 @@ type GetFieldExtractionByVersionParams struct {
|
||||
Version int64 `form:"version" json:"version"`
|
||||
}
|
||||
|
||||
// GetFolderDocumentsParams defines parameters for GetFolderDocuments.
|
||||
type GetFolderDocumentsParams struct {
|
||||
// TextRecord When true, includes the full text extraction record for each document
|
||||
TextRecord *bool `form:"textRecord,omitempty" json:"textRecord,omitempty"`
|
||||
}
|
||||
|
||||
// GetDocumentsByLabelParams defines parameters for GetDocumentsByLabel.
|
||||
type GetDocumentsByLabelParams struct {
|
||||
// ClientId The client ID to filter documents
|
||||
@@ -1294,7 +1351,7 @@ type ClientInterface interface {
|
||||
ListClients(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// GetDocument request
|
||||
GetDocument(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
GetDocument(ctx context.Context, id DocumentID, params *GetDocumentParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// GetDocumentLabels request
|
||||
GetDocumentLabels(ctx context.Context, documentId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
@@ -1332,7 +1389,7 @@ type ClientInterface interface {
|
||||
RenameFolder(ctx context.Context, folderId openapi_types.UUID, body RenameFolderJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// GetFolderDocuments request
|
||||
GetFolderDocuments(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
GetFolderDocuments(ctx context.Context, folderId openapi_types.UUID, params *GetFolderDocumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// GetFolderMetrics request
|
||||
GetFolderMetrics(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
@@ -1722,8 +1779,8 @@ func (c *Client) ListClients(ctx context.Context, reqEditors ...RequestEditorFn)
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *Client) GetDocument(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewGetDocumentRequest(c.Server, id)
|
||||
func (c *Client) GetDocument(ctx context.Context, id DocumentID, params *GetDocumentParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewGetDocumentRequest(c.Server, id, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1890,8 +1947,8 @@ func (c *Client) RenameFolder(ctx context.Context, folderId openapi_types.UUID,
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *Client) GetFolderDocuments(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewGetFolderDocumentsRequest(c.Server, folderId)
|
||||
func (c *Client) GetFolderDocuments(ctx context.Context, folderId openapi_types.UUID, params *GetFolderDocumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewGetFolderDocumentsRequest(c.Server, folderId, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -3101,7 +3158,7 @@ func NewListClientsRequest(server string) (*http.Request, error) {
|
||||
}
|
||||
|
||||
// NewGetDocumentRequest generates requests for GetDocument
|
||||
func NewGetDocumentRequest(server string, id DocumentID) (*http.Request, error) {
|
||||
func NewGetDocumentRequest(server string, id DocumentID, params *GetDocumentParams) (*http.Request, error) {
|
||||
var err error
|
||||
|
||||
var pathParam0 string
|
||||
@@ -3126,6 +3183,28 @@ func NewGetDocumentRequest(server string, id DocumentID) (*http.Request, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if params != nil {
|
||||
queryValues := queryURL.Query()
|
||||
|
||||
if params.TextRecord != nil {
|
||||
|
||||
if queryFrag, err := runtime.StyleParamWithLocation("form", true, "textRecord", runtime.ParamLocationQuery, *params.TextRecord); err != nil {
|
||||
return nil, err
|
||||
} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
for k, v := range parsed {
|
||||
for _, v2 := range v {
|
||||
queryValues.Add(k, v2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
queryURL.RawQuery = queryValues.Encode()
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -3524,7 +3603,7 @@ func NewRenameFolderRequestWithBody(server string, folderId openapi_types.UUID,
|
||||
}
|
||||
|
||||
// NewGetFolderDocumentsRequest generates requests for GetFolderDocuments
|
||||
func NewGetFolderDocumentsRequest(server string, folderId openapi_types.UUID) (*http.Request, error) {
|
||||
func NewGetFolderDocumentsRequest(server string, folderId openapi_types.UUID, params *GetFolderDocumentsParams) (*http.Request, error) {
|
||||
var err error
|
||||
|
||||
var pathParam0 string
|
||||
@@ -3549,6 +3628,28 @@ func NewGetFolderDocumentsRequest(server string, folderId openapi_types.UUID) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if params != nil {
|
||||
queryValues := queryURL.Query()
|
||||
|
||||
if params.TextRecord != nil {
|
||||
|
||||
if queryFrag, err := runtime.StyleParamWithLocation("form", true, "textRecord", runtime.ParamLocationQuery, *params.TextRecord); err != nil {
|
||||
return nil, err
|
||||
} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
for k, v := range parsed {
|
||||
for _, v2 := range v {
|
||||
queryValues.Add(k, v2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
queryURL.RawQuery = queryValues.Encode()
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -4101,7 +4202,7 @@ type ClientWithResponsesInterface interface {
|
||||
ListClientsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListClientsResponse, error)
|
||||
|
||||
// GetDocumentWithResponse request
|
||||
GetDocumentWithResponse(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error)
|
||||
GetDocumentWithResponse(ctx context.Context, id DocumentID, params *GetDocumentParams, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error)
|
||||
|
||||
// GetDocumentLabelsWithResponse request
|
||||
GetDocumentLabelsWithResponse(ctx context.Context, documentId openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentLabelsResponse, error)
|
||||
@@ -4139,7 +4240,7 @@ type ClientWithResponsesInterface interface {
|
||||
RenameFolderWithResponse(ctx context.Context, folderId openapi_types.UUID, body RenameFolderJSONRequestBody, reqEditors ...RequestEditorFn) (*RenameFolderResponse, error)
|
||||
|
||||
// GetFolderDocumentsWithResponse request
|
||||
GetFolderDocumentsWithResponse(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetFolderDocumentsResponse, error)
|
||||
GetFolderDocumentsWithResponse(ctx context.Context, folderId openapi_types.UUID, params *GetFolderDocumentsParams, reqEditors ...RequestEditorFn) (*GetFolderDocumentsResponse, error)
|
||||
|
||||
// GetFolderMetricsWithResponse request
|
||||
GetFolderMetricsWithResponse(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetFolderMetricsResponse, error)
|
||||
@@ -4797,9 +4898,10 @@ func (r ListClientsResponse) StatusCode() int {
|
||||
type GetDocumentResponse struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
JSON200 *Document
|
||||
JSON200 *DocumentEnriched
|
||||
JSON400 *InvalidRequest
|
||||
JSON401 *Unauthorized
|
||||
JSON404 *NotFound
|
||||
JSON429 *TooManyRequests
|
||||
JSON500 *InternalError
|
||||
}
|
||||
@@ -5069,7 +5171,7 @@ type GetFolderDocumentsResponse struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
JSON200 *struct {
|
||||
Documents *[]Document `json:"documents,omitempty"`
|
||||
Documents *[]DocumentInFolder `json:"documents,omitempty"`
|
||||
}
|
||||
JSON400 *InvalidRequest
|
||||
JSON401 *Unauthorized
|
||||
@@ -5634,8 +5736,8 @@ func (c *ClientWithResponses) ListClientsWithResponse(ctx context.Context, reqEd
|
||||
}
|
||||
|
||||
// GetDocumentWithResponse request returning *GetDocumentResponse
|
||||
func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) {
|
||||
rsp, err := c.GetDocument(ctx, id, reqEditors...)
|
||||
func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, id DocumentID, params *GetDocumentParams, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) {
|
||||
rsp, err := c.GetDocument(ctx, id, params, reqEditors...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -5756,8 +5858,8 @@ func (c *ClientWithResponses) RenameFolderWithResponse(ctx context.Context, fold
|
||||
}
|
||||
|
||||
// GetFolderDocumentsWithResponse request returning *GetFolderDocumentsResponse
|
||||
func (c *ClientWithResponses) GetFolderDocumentsWithResponse(ctx context.Context, folderId openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetFolderDocumentsResponse, error) {
|
||||
rsp, err := c.GetFolderDocuments(ctx, folderId, reqEditors...)
|
||||
func (c *ClientWithResponses) GetFolderDocumentsWithResponse(ctx context.Context, folderId openapi_types.UUID, params *GetFolderDocumentsParams, reqEditors ...RequestEditorFn) (*GetFolderDocumentsResponse, error) {
|
||||
rsp, err := c.GetFolderDocuments(ctx, folderId, params, reqEditors...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -7249,7 +7351,7 @@ func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error)
|
||||
|
||||
switch {
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
||||
var dest Document
|
||||
var dest DocumentEnriched
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -7269,6 +7371,13 @@ func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error)
|
||||
}
|
||||
response.JSON401 = &dest
|
||||
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
||||
var dest NotFound
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.JSON404 = &dest
|
||||
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429:
|
||||
var dest TooManyRequests
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
@@ -7843,7 +7952,7 @@ func ParseGetFolderDocumentsResponse(rsp *http.Response) (*GetFolderDocumentsRes
|
||||
switch {
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
||||
var dest struct {
|
||||
Documents *[]Document `json:"documents,omitempty"`
|
||||
Documents *[]DocumentInFolder `json:"documents,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user