Skip to content

Commit

Permalink
chore: improve S3Object data structure - part 2 (#259)
Browse files Browse the repository at this point in the history
feat: further enrichment of snapshot.original field with more properties (see JSON below)
feat: further enrichment of snapshot.preview field with more properties (see JSON below)
feat: further enrichment of snapshot.segmentation field with more properties (see JSON below)
feat: further enrichment of snapshot.mosaic field with more properties (see JSON below)
refactor: clients on API microservice look the same like other microservices (preparing for deduplication)
  • Loading branch information
bouassaba authored Aug 10, 2024
1 parent 568d059 commit 8da70ca
Show file tree
Hide file tree
Showing 16 changed files with 327 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the GNU Affero General Public License v3.0 only, included in the file
// licenses/AGPL.txt.

package client
package conversion_client

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the GNU Affero General Public License v3.0 only, included in the file
// licenses/AGPL.txt.

package client
package language_client

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// by the GNU Affero General Public License v3.0 only, included in the file
// licenses/AGPL.txt.

package client
package mosaic_client

import (
"bytes"
Expand All @@ -34,6 +34,12 @@ func NewMosaicClient() *MosaicClient {
}
}

type MosaicCreateOptions struct {
Path string
S3Key string
S3Bucket string
}

type MosaicMetadata struct {
Width int `json:"width"`
Height int `json:"height"`
Expand All @@ -58,12 +64,6 @@ type MosaicTile struct {
LastRowHeight int `json:"lastRowHeight"`
}

type MosaicCreateOptions struct {
Path string
S3Key string
S3Bucket string
}

func (cl *MosaicClient) Create(opts MosaicCreateOptions) (*MosaicMetadata, error) {
file, err := os.Open(opts.Path)
if err != nil {
Expand Down
32 changes: 16 additions & 16 deletions api/docs/index.html

Large diffs are not rendered by default.

184 changes: 98 additions & 86 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,6 @@
basePath: /v2
definitions:
client.InsightsEntity:
properties:
frequency:
type: integer
label:
type: string
text:
type: string
type: object
client.MosaicMetadata:
properties:
extension:
type: string
height:
type: integer
width:
type: integer
zoomLevels:
items:
$ref: '#/definitions/client.MosaicZoomLevel'
type: array
type: object
client.MosaicTile:
properties:
height:
type: integer
lastColWidth:
type: integer
lastRowHeight:
type: integer
width:
type: integer
type: object
client.MosaicZoomLevel:
properties:
cols:
type: integer
height:
type: integer
index:
type: integer
rows:
type: integer
scaleDownPercentage:
type: number
tile:
$ref: '#/definitions/client.MosaicTile'
width:
type: integer
type: object
client.PipelineRunOptions:
conversion_client.PipelineRunOptions:
properties:
bucket:
type: string
Expand Down Expand Up @@ -80,20 +30,37 @@ definitions:
userMessage:
type: string
type: object
language_client.InsightsEntity:
properties:
frequency:
type: integer
label:
type: string
text:
type: string
type: object
model.DocumentProps:
properties:
pages:
type: integer
$ref: '#/definitions/model.PagesProps'
thumbnails:
$ref: '#/definitions/model.ThumbnailsProps'
type: object
model.ImageProps:
properties:
height:
type: integer
width:
type: integer
zoomLevels:
items:
$ref: '#/definitions/model.ZoomLevel'
type: array
type: object
model.PathProps:
model.PagesProps:
properties:
count:
type: integer
extension:
type: string
type: object
Expand All @@ -107,14 +74,82 @@ definitions:
$ref: '#/definitions/model.ImageProps'
key:
type: string
page:
$ref: '#/definitions/model.PathProps'
size:
type: integer
thumbnail:
$ref: '#/definitions/model.PathProps'
type: object
model.ThumbnailsProps:
properties:
extension:
type: string
type: object
model.Tile:
properties:
height:
type: integer
lastColWidth:
type: integer
lastRowHeight:
type: integer
width:
type: integer
type: object
model.ZoomLevel:
properties:
cols:
type: integer
height:
type: integer
index:
type: integer
rows:
type: integer
scaleDownPercentage:
type: number
tile:
$ref: '#/definitions/model.PathProps'
$ref: '#/definitions/model.Tile'
width:
type: integer
type: object
mosaic_client.MosaicMetadata:
properties:
extension:
type: string
height:
type: integer
width:
type: integer
zoomLevels:
items:
$ref: '#/definitions/mosaic_client.MosaicZoomLevel'
type: array
type: object
mosaic_client.MosaicTile:
properties:
height:
type: integer
lastColWidth:
type: integer
lastRowHeight:
type: integer
width:
type: integer
type: object
mosaic_client.MosaicZoomLevel:
properties:
cols:
type: integer
height:
type: integer
index:
type: integer
rows:
type: integer
scaleDownPercentage:
type: number
tile:
$ref: '#/definitions/mosaic_client.MosaicTile'
width:
type: integer
type: object
router.FileGrantGroupPermissionOptions:
properties:
Expand Down Expand Up @@ -232,27 +267,16 @@ definitions:
required:
- storageCapacity
type: object
service.DocumentProps:
properties:
pages:
type: integer
type: object
service.Download:
properties:
document:
$ref: '#/definitions/service.DocumentProps'
$ref: '#/definitions/model.DocumentProps'
extension:
type: string
image:
$ref: '#/definitions/service.ImageProps'
page:
$ref: '#/definitions/service.PathProps'
$ref: '#/definitions/model.ImageProps'
size:
type: integer
thumbnail:
$ref: '#/definitions/service.PathProps'
tile:
$ref: '#/definitions/service.PathProps'
type: object
service.File:
properties:
Expand Down Expand Up @@ -427,13 +451,6 @@ definitions:
permission:
type: string
type: object
service.ImageProps:
properties:
height:
type: integer
width:
type: integer
type: object
service.InsightsCreateOptions:
properties:
languageId:
Expand All @@ -445,7 +462,7 @@ definitions:
properties:
data:
items:
$ref: '#/definitions/client.InsightsEntity'
$ref: '#/definitions/language_client.InsightsEntity'
type: array
page:
type: integer
Expand Down Expand Up @@ -525,7 +542,7 @@ definitions:
isOutdated:
type: boolean
metadata:
$ref: '#/definitions/client.MosaicMetadata'
$ref: '#/definitions/mosaic_client.MosaicMetadata'
snapshot:
$ref: '#/definitions/service.Snapshot'
type: object
Expand Down Expand Up @@ -569,11 +586,6 @@ definitions:
totalPages:
type: integer
type: object
service.PathProps:
properties:
extension:
type: string
type: object
service.Snapshot:
properties:
createTime:
Expand Down Expand Up @@ -651,7 +663,7 @@ definitions:
ocr:
$ref: '#/definitions/model.S3Object'
options:
$ref: '#/definitions/client.PipelineRunOptions'
$ref: '#/definitions/conversion_client.PipelineRunOptions'
original:
$ref: '#/definitions/model.S3Object'
preview:
Expand Down
45 changes: 33 additions & 12 deletions api/model/snapshot_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,50 @@ type Snapshot interface {
}

type S3Object struct {
Bucket string `json:"bucket"`
Key string `json:"key"`
Size *int64 `json:"size,omitempty"`
Image *ImageProps `json:"image,omitempty"`
Document *DocumentProps `json:"document,omitempty"`
Page *PathProps `json:"page,omitempty"`
Thumbnail *PathProps `json:"thumbnail,omitempty"`
Tile *PathProps `json:"tile,omitempty"`
Bucket string `json:"bucket"`
Key string `json:"key"`
Size *int64 `json:"size,omitempty"`
Image *ImageProps `json:"image,omitempty"`
Document *DocumentProps `json:"document,omitempty"`
}

type ImageProps struct {
Width int `json:"width"`
Height int `json:"height"`
Width int `json:"width"`
Height int `json:"height"`
ZoomLevels []ZoomLevel `json:"zoomLevels,omitempty"`
}

type DocumentProps struct {
Pages int `json:"pages"`
Pages *PagesProps `json:"pages,omitempty"`
Thumbnails *ThumbnailsProps `json:"thumbnails,omitempty"`
}

type PathProps struct {
type PagesProps struct {
Count int `json:"count"`
Extension string `json:"extension"`
}

type ThumbnailsProps struct {
Extension string `json:"extension"`
}

type ZoomLevel struct {
Index int `json:"index"`
Width int `json:"width"`
Height int `json:"height"`
Rows int `json:"rows"`
Cols int `json:"cols"`
ScaleDownPercentage float32 `json:"scaleDownPercentage"`
Tile Tile `json:"tile"`
}

type Tile struct {
Width int `json:"width"`
Height int `json:"height"`
LastColWidth int `json:"lastColWidth"`
LastRowHeight int `json:"lastRowHeight"`
}

type S3Reference struct {
Bucket string `json:"bucket"`
Key string `json:"key"`
Expand Down
Loading

0 comments on commit 8da70ca

Please sign in to comment.