diff --git a/.gitignore b/.gitignore index ae760c7..9ec0f64 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tmp/ **/__pycache__ **/.openapi-generator **/api/docs/ +cmd/api/api diff --git a/README.md b/README.md index bce1224..5a3dab3 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ # camry -# status: not yet working +# status: in production at my house for ages now -Intended as the spiritual sucessor to [initialed85/cameranator](https://github.com/initialed85/cameranator), built on [initialed85/djangolang](https://github.com/initialed85/djangolang) +Intended as the spiritual sucessor to [initialed85/cameranator](https://github.com/initialed85/cameranator), built on +[initialed85/djangolang](https://github.com/initialed85/djangolang) -## Tasks - -- [TODO] Come up with a more efficient way to use the detections data, probably some sort of aggregation +## Features -## Usage +- Lots of nice caching etc thanks to [initialed85/djangolang](https://github.com/initialed85/djangolang) +- Frontend is a PWA for a good mobile / offline experience +- Uses YOLO for object detection +- See + [initialed85/home-ops/tree/master/applications/camry](https://github.com/initialed85/home-ops/tree/master/applications/camry) + for some inspiration on how to deploy -### Testing +## Tasks -```shell -./run-env.sh full -``` +## Usage ### Development @@ -32,19 +34,16 @@ REDIS_URL=redis://localhost:6379 DJANGOLANG_API_ROOT=/api POSTGRES_DB=camry POST websocat -B 1048576 ws://localhost:7070/api/__stream | jq # shell 5 -curl -X POST http://localhost:7070/api/cameras -d '[{"name": "Driveway", "stream_url": "rtsp://192.168.137.31:554/Streaming/Channels/101"}, {"name": "Front door", "stream_url": "rtsp://192.168.137.32:554/Streaming/Channels/101"}, {"name": "Side gate", "stream_url": "rtsp://192.168.137.33:554/Streaming/Channels/101"}]' | jq +devserver --address 0.0.0.0:6060 # shell 6 -DJANGOLANG_API_ROOT=/api DESTINATION_PATH=media ENABLE_PASSTHROUGH=1 CAMERA_NAME='Driveway' NET_CAM_URL=rtsp://192.168.137.31:554/Streaming/Channels/101 POSTGRES_DB=camry POSTGRES_PASSWORD=NoNVR\!11 go run ./cmd segment_producer +curl -X POST http://localhost:7070/api/cameras -d '[{"name": "Driveway", "stream_url": "rtsp://192.168.137.31:554/Streaming/Channels/101"}, {"name": "Front door", "stream_url": "rtsp://192.168.137.32:554/Streaming/Channels/101"}, {"name": "Side gate", "stream_url": "rtsp://192.168.137.33:554/Streaming/Channels/101"}]' | jq # shell 7 -DJANGOLANG_API_ROOT=/api DESTINATION_PATH=media ENABLE_PASSTHROUGH=1 CAMERA_NAME='Front door' NET_CAM_URL=rtsp://192.168.137.32:554/Streaming/Channels/101 POSTGRES_DB=camry POSTGRES_PASSWORD=NoNVR\!11 go run ./cmd segment_producer +DJANGOLANG_API_ROOT=/api DESTINATION_PATH=media ENABLE_PASSTHROUGH=1 POSTGRES_DB=camry POSTGRES_PASSWORD=NoNVR\!11 go run ./cmd segment_producer # shell 8 -DJANGOLANG_API_ROOT=/api DESTINATION_PATH=media ENABLE_PASSTHROUGH=1 CAMERA_NAME='Side gate' NET_CAM_URL=rtsp://192.168.137.33:554/Streaming/Channels/101 POSTGRES_DB=camry POSTGRES_PASSWORD=NoNVR\!11 go run ./cmd segment_producer - -# shell 9 - +DEBUG=1 API_URL=http://localhost:7070 SOURCE_PATH=media ~/.venv/camry/bin/python3 -m object_detector ``` ### Scratch diff --git a/cmd/api/api b/cmd/api/api deleted file mode 100755 index c84aeec..0000000 Binary files a/cmd/api/api and /dev/null differ diff --git a/cmd/api/main.go b/cmd/api/main.go index fc915ac..90880dd 100755 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -1,161 +1,27 @@ package main import ( - "context" - "fmt" - "log" - "net/http" "os" "strings" - "time" - "github.com/go-chi/chi/v5" - "github.com/initialed85/camry/internal" "github.com/initialed85/camry/pkg/api" "github.com/initialed85/djangolang/pkg/config" - "github.com/initialed85/djangolang/pkg/server" ) -type ClaimRequest struct { - ClaimDurationSeconds float64 `json:"claim_duration_seconds"` -} - -func RunServeWithEnvironment( - httpMiddlewares []server.HTTPMiddleware, - objectMiddlewares []server.ObjectMiddleware, - addCustomHandlers func(chi.Router) error, -) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - port := config.Port() - - db, err := config.GetDBFromEnvironment(ctx) - if err != nil { - log.Fatalf("%v", err) - } - defer func() { - db.Close() - }() - - redisPool, err := config.GetRedisFromEnvironment() - if err != nil { - log.Fatalf("%v", err) - } - defer func() { - _ = redisPool.Close() - }() - - actualAddCustomHandlers := func(r chi.Router) error { - claimVideoForObjectDetectorHandler, err := api.GetHTTPHandler( - http.MethodPatch, - "/custom/claim-video-for-object-detector", - http.StatusOK, - func( - ctx context.Context, - pathParams server.EmptyPathParams, - queryParams server.EmptyQueryParams, - req ClaimRequest, - rawReq any, - ) (*api.Video, error) { - now := time.Now().UTC() - - claimUntil := now.Add(time.Second * time.Duration(req.ClaimDurationSeconds)) - - if claimUntil.Sub(now) <= 0 { - return nil, fmt.Errorf("claim_duration_seconds too short; must result in a claim that expires in the future") - } - - tx, err := db.Begin(ctx) - if err != nil { - return nil, err - } - - defer func() { - _ = tx.Rollback(ctx) - }() - - video := &api.Video{} - - // TODO: this is hacky; wait for as long as other processes are _probably_ claiming for plus some fudge (but not a certainty of course) - err = video.AdvisoryLockWithRetries(ctx, tx, 3, time.Duration(req.ClaimDurationSeconds)+(time.Second*2), time.Second*1) - if err != nil { - return nil, err - } - - videos, _, _, _, _, err := api.SelectVideos( - ctx, - tx, - fmt.Sprintf( - "%v = 'needs detection' AND %v < now()", - api.VideoTableStatusColumn, - api.VideoTableObjectDetectorClaimedUntilColumn, - ), - internal.Ptr(fmt.Sprintf( - "%v DESC", - api.VideoTableStartedAtColumn, - )), - internal.Ptr(1), - nil, - ) - if err != nil { - return nil, err - } - - if len(videos) == 0 { - return nil, nil - } - - if len(videos) > 1 { - return nil, fmt.Errorf("wanted exactly 1 unclaimed video, got %d", len(videos)) - } - - video = videos[0] - - video.ObjectDetectorClaimedUntil = claimUntil - video.ObjectTrackerClaimedUntil = time.Time{} // zero to ensure we don't wipe out an existing value - - err = video.Update(ctx, tx, false) - if err != nil { - return nil, err - } - - err = tx.Commit(ctx) - if err != nil { - return nil, err - } - - return video, nil - }, - ) - if err != nil { - return err - } - - r.Patch("/claim-video-for-object-detector", claimVideoForObjectDetectorHandler.ServeHTTP) - - if addCustomHandlers != nil { - err = addCustomHandlers(r) - if err != nil { - return err - } - } - - return nil - } - - api.RunServeWithArguments(ctx, cancel, port, db, redisPool, nil, nil, actualAddCustomHandlers) -} +var log = api.ThisLogger() func main() { if len(os.Args) < 2 { - log.Fatal("first argument must be command (one of 'serve', 'dump-openapi-json', 'dump-openapi-yaml')") + log.Fatal("first argument must be command (one of 'dump-config', 'dump-openapi-json', 'dump-openapi-yaml' or 'serve')") } command := strings.TrimSpace(strings.ToLower(os.Args[1])) switch command { + case "dump-config": + config.DumpConfig() + case "dump-openapi-json": api.RunDumpOpenAPIJSON() @@ -163,6 +29,6 @@ func main() { api.RunDumpOpenAPIYAML() case "serve": - RunServeWithEnvironment(nil, nil, nil) + api.RunServeWithEnvironment(nil, nil, nil) } } diff --git a/docker-compose.yaml b/docker-compose.yaml index 5fa39e9..6307dfa 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -59,7 +59,7 @@ services: image: swaggerapi/swagger-ui:v5.4.2 environment: - "BASE_URL=/" - - "SWAGGER_JSON_URL=http://host.docker.internal:7070/api/openapi.json" + - "SWAGGER_JSON_URL=http://0.0.0.0:7070/api/openapi.json" ports: - "7071:8080/tcp" diff --git a/frontend/src/api/api.d.ts b/frontend/src/api/api.d.ts index c0dcc54..0ed9476 100644 --- a/frontend/src/api/api.d.ts +++ b/frontend/src/api/api.d.ts @@ -36,7 +36,7 @@ export interface paths { patch: operations["PatchCamera"]; trace?: never; }; - "/api/custom/claim-video-for-object-detector": { + "/api/cameras/{primaryKey}/segment-producer-claim": { parameters: { query?: never; header?: never; @@ -45,11 +45,27 @@ export interface paths { }; get?: never; put?: never; - post?: never; + post: operations["PostCamerasSegmentProducerClaim"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/cameras/{primaryKey}/stream-producer-claim": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostCamerasStreamProducerClaim"]; delete?: never; options?: never; head?: never; - patch: operations["PatchCustomClaimVideoForObjectDetector"]; + patch?: never; trace?: never; }; "/api/detections": { @@ -84,6 +100,70 @@ export interface paths { patch: operations["PatchDetection"]; trace?: never; }; + "/api/object-detector-claim-video": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostObjectDetectorClaimVideos"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/object-tracker-claim-video": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostObjectTrackerClaimVideos"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/segment-producer-claim-camera": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostSegmentProducerClaimCameras"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/stream-producer-claim-camera": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostStreamProducerClaimCameras"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/api/videos": { parameters: { query?: never; @@ -116,6 +196,38 @@ export interface paths { patch: operations["PatchVideo"]; trace?: never; }; + "/api/videos/{primaryKey}/object-detector-claim": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostVideosObjectDetectorClaim"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/videos/{primaryKey}/object-tracker-claim": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post: operations["PostVideosObjectTrackerClaim"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; } export type webhooks = Record; export interface components { @@ -157,9 +269,17 @@ export interface components { /** Format: date-time */ updated_at?: string; }; - ClaimRequest: { + CameraSegmentProducerClaimRequest: { + /** Format: double */ + timeout_seconds?: number; + /** Format: date-time */ + until?: string; + }; + CameraStreamProducerClaimRequest: { /** Format: double */ - claim_duration_seconds?: number; + timeout_seconds?: number; + /** Format: date-time */ + until?: string; }; Detection: { bounding_box?: @@ -284,6 +404,18 @@ export interface components { /** Format: date-time */ updated_at?: string; }; + VideoObjectDetectorClaimRequest: { + /** Format: double */ + timeout_seconds?: number; + /** Format: date-time */ + until?: string; + }; + VideoObjectTrackerClaimRequest: { + /** Format: double */ + timeout_seconds?: number; + /** Format: date-time */ + until?: string; + }; }; responses: never; parameters: never; @@ -800,29 +932,79 @@ export interface operations { }; }; }; - PatchCustomClaimVideoForObjectDetector: { + PostCamerasSegmentProducerClaim: { parameters: { - query?: never; + query?: { + /** @description Query parameter depth */ + depth?: number; + }; header?: never; - path?: never; + path: { + /** @description Path parameter primaryKey */ + primaryKey: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CameraSegmentProducerClaimRequest"]; + }; + }; + responses: { + /** @description PostCamerasSegmentProducerClaim success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfCamera"]; + }; + }; + /** @description PostCamerasSegmentProducerClaim failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; + PostCamerasStreamProducerClaim: { + parameters: { + query?: { + /** @description Query parameter depth */ + depth?: number; + }; + header?: never; + path: { + /** @description Path parameter primaryKey */ + primaryKey: string; + }; cookie?: never; }; requestBody: { content: { - "application/json": components["schemas"]["ClaimRequest"]; + "application/json": components["schemas"]["CameraStreamProducerClaimRequest"]; }; }; responses: { - /** @description PatchCustomClaimVideoForObjectDetector success */ + /** @description PostCamerasStreamProducerClaim success */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["NullableVideo"]; + "application/json": components["schemas"]["ResponseWithGenericOfCamera"]; }; }; - /** @description PatchCustomClaimVideoForObjectDetector failure */ + /** @description PostCamerasStreamProducerClaim failure */ default: { headers: { [name: string]: unknown; @@ -1377,6 +1559,158 @@ export interface operations { }; }; }; + PostObjectDetectorClaimVideos: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["VideoObjectDetectorClaimRequest"]; + }; + }; + responses: { + /** @description PostObjectDetectorClaimVideos success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfVideo"]; + }; + }; + /** @description PostObjectDetectorClaimVideos failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; + PostObjectTrackerClaimVideos: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["VideoObjectTrackerClaimRequest"]; + }; + }; + responses: { + /** @description PostObjectTrackerClaimVideos success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfVideo"]; + }; + }; + /** @description PostObjectTrackerClaimVideos failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; + PostSegmentProducerClaimCameras: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CameraSegmentProducerClaimRequest"]; + }; + }; + responses: { + /** @description PostSegmentProducerClaimCameras success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfCamera"]; + }; + }; + /** @description PostSegmentProducerClaimCameras failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; + PostStreamProducerClaimCameras: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CameraStreamProducerClaimRequest"]; + }; + }; + responses: { + /** @description PostStreamProducerClaimCameras success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfCamera"]; + }; + }; + /** @description PostStreamProducerClaimCameras failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; GetVideos: { parameters: { query?: { @@ -2036,4 +2370,92 @@ export interface operations { }; }; }; + PostVideosObjectDetectorClaim: { + parameters: { + query?: { + /** @description Query parameter depth */ + depth?: number; + }; + header?: never; + path: { + /** @description Path parameter primaryKey */ + primaryKey: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["VideoObjectDetectorClaimRequest"]; + }; + }; + responses: { + /** @description PostVideosObjectDetectorClaim success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfVideo"]; + }; + }; + /** @description PostVideosObjectDetectorClaim failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; + PostVideosObjectTrackerClaim: { + parameters: { + query?: { + /** @description Query parameter depth */ + depth?: number; + }; + header?: never; + path: { + /** @description Path parameter primaryKey */ + primaryKey: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["VideoObjectTrackerClaimRequest"]; + }; + }; + responses: { + /** @description PostVideosObjectTrackerClaim success */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ResponseWithGenericOfVideo"]; + }; + }; + /** @description PostVideosObjectTrackerClaim failure */ + default: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + error: string[]; + /** Format: int32 */ + status: number; + success: boolean; + }; + }; + }; + }; + }; } diff --git a/go.mod b/go.mod index 4a9212f..e04ace9 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,9 @@ require ( github.com/go-chi/chi/v5 v5.2.0 github.com/gomodule/redigo v1.9.2 github.com/google/uuid v1.6.0 - github.com/initialed85/djangolang v0.1.12 + github.com/initialed85/djangolang v0.1.26 github.com/jackc/pgx/v5 v5.7.2 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 gopkg.in/yaml.v2 v2.4.0 ) @@ -27,6 +26,7 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/paulmach/orb v0.11.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index ea5863f..d636f6a 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/initialed85/djangolang v0.1.12 h1:eucaeH74AeZ6rYv/Tk14GUw5qk5bk1z9SoexLFA8oSs= -github.com/initialed85/djangolang v0.1.12/go.mod h1:YgEMMI0LlieGttGd2OGgnVo2LqFSx9jWchDiNeUznRI= +github.com/initialed85/djangolang v0.1.26 h1:4xP8AEHeYqQciwr+nqG36bkkfedbe70nL0iBHOSmWwM= +github.com/initialed85/djangolang v0.1.26/go.mod h1:YgEMMI0LlieGttGd2OGgnVo2LqFSx9jWchDiNeUznRI= github.com/initialed85/structmeta v0.0.0-20240923104310-4adf4f5a7354 h1:J2ax29IYAhlqMinMit2I+uOPCcTkTmHsZzwAlPY2Rjs= github.com/initialed85/structmeta v0.0.0-20240923104310-4adf4f5a7354/go.mod h1:hTGWTsfgy6Um+L8e3Qcj8/pBkHGcIGxEpZAKziWhQfc= github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= @@ -253,8 +253,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= +golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329 h1:9kj3STMvgqy3YA4VQXBrN7925ICMxD5wzMRcgA30588= +golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= diff --git a/object_detector/api/openapi_client/__init__.py b/object_detector/api/openapi_client/__init__.py index 76cb006..4760f09 100644 --- a/object_detector/api/openapi_client/__init__.py +++ b/object_detector/api/openapi_client/__init__.py @@ -18,8 +18,11 @@ # import apis into sdk package from openapi_client.api.camera_api import CameraApi -from openapi_client.api.custom_api import CustomApi from openapi_client.api.detection_api import DetectionApi +from openapi_client.api.object_detector_claim_video_api import ObjectDetectorClaimVideoApi +from openapi_client.api.object_tracker_claim_video_api import ObjectTrackerClaimVideoApi +from openapi_client.api.segment_producer_claim_camera_api import SegmentProducerClaimCameraApi +from openapi_client.api.stream_producer_claim_camera_api import StreamProducerClaimCameraApi from openapi_client.api.video_api import VideoApi # import ApiClient @@ -36,7 +39,8 @@ # import models into sdk package from openapi_client.models.array_of_vec2_inner import ArrayOfVec2Inner from openapi_client.models.camera import Camera -from openapi_client.models.claim_request import ClaimRequest +from openapi_client.models.camera_segment_producer_claim_request import CameraSegmentProducerClaimRequest +from openapi_client.models.camera_stream_producer_claim_request import CameraStreamProducerClaimRequest from openapi_client.models.detection import Detection from openapi_client.models.get_cameras_default_response import GetCamerasDefaultResponse from openapi_client.models.response_with_generic_of_camera import ResponseWithGenericOfCamera @@ -44,3 +48,5 @@ from openapi_client.models.response_with_generic_of_video import ResponseWithGenericOfVideo from openapi_client.models.vec2 import Vec2 from openapi_client.models.video import Video +from openapi_client.models.video_object_detector_claim_request import VideoObjectDetectorClaimRequest +from openapi_client.models.video_object_tracker_claim_request import VideoObjectTrackerClaimRequest diff --git a/object_detector/api/openapi_client/api/__init__.py b/object_detector/api/openapi_client/api/__init__.py index b3e483b..8036161 100644 --- a/object_detector/api/openapi_client/api/__init__.py +++ b/object_detector/api/openapi_client/api/__init__.py @@ -2,7 +2,10 @@ # import apis into api package from openapi_client.api.camera_api import CameraApi -from openapi_client.api.custom_api import CustomApi from openapi_client.api.detection_api import DetectionApi +from openapi_client.api.object_detector_claim_video_api import ObjectDetectorClaimVideoApi +from openapi_client.api.object_tracker_claim_video_api import ObjectTrackerClaimVideoApi +from openapi_client.api.segment_producer_claim_camera_api import SegmentProducerClaimCameraApi +from openapi_client.api.stream_producer_claim_camera_api import StreamProducerClaimCameraApi from openapi_client.api.video_api import VideoApi diff --git a/object_detector/api/openapi_client/api/camera_api.py b/object_detector/api/openapi_client/api/camera_api.py index b922209..b56623f 100644 --- a/object_detector/api/openapi_client/api/camera_api.py +++ b/object_detector/api/openapi_client/api/camera_api.py @@ -21,6 +21,8 @@ from typing import Any, List, Optional from typing_extensions import Annotated from openapi_client.models.camera import Camera +from openapi_client.models.camera_segment_producer_claim_request import CameraSegmentProducerClaimRequest +from openapi_client.models.camera_stream_producer_claim_request import CameraStreamProducerClaimRequest from openapi_client.models.response_with_generic_of_camera import ResponseWithGenericOfCamera from openapi_client.api_client import ApiClient, RequestSerialized @@ -4827,3 +4829,603 @@ def _post_cameras_serialize( ) + + + @validate_call + def post_cameras_segment_producer_claim( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfCamera: + """post_cameras_segment_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_segment_producer_claim_serialize( + primary_key=primary_key, + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_cameras_segment_producer_claim_with_http_info( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfCamera]: + """post_cameras_segment_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_segment_producer_claim_serialize( + primary_key=primary_key, + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_cameras_segment_producer_claim_without_preload_content( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_cameras_segment_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_segment_producer_claim_serialize( + primary_key=primary_key, + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_cameras_segment_producer_claim_serialize( + self, + primary_key, + camera_segment_producer_claim_request, + depth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if primary_key is not None: + _path_params['primaryKey'] = primary_key + # process the query parameters + if depth is not None: + + _query_params.append(('depth', depth)) + + # process the header parameters + # process the form parameters + # process the body parameter + if camera_segment_producer_claim_request is not None: + _body_params = camera_segment_producer_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/cameras/{primaryKey}/segment-producer-claim', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_cameras_stream_producer_claim( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfCamera: + """post_cameras_stream_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_stream_producer_claim_serialize( + primary_key=primary_key, + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_cameras_stream_producer_claim_with_http_info( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfCamera]: + """post_cameras_stream_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_stream_producer_claim_serialize( + primary_key=primary_key, + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_cameras_stream_producer_claim_without_preload_content( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_cameras_stream_producer_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cameras_stream_producer_claim_serialize( + primary_key=primary_key, + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_cameras_stream_producer_claim_serialize( + self, + primary_key, + camera_stream_producer_claim_request, + depth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if primary_key is not None: + _path_params['primaryKey'] = primary_key + # process the query parameters + if depth is not None: + + _query_params.append(('depth', depth)) + + # process the header parameters + # process the form parameters + # process the body parameter + if camera_stream_producer_claim_request is not None: + _body_params = camera_stream_producer_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/cameras/{primaryKey}/stream-producer-claim', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/object_detector/api/openapi_client/api/object_detector_claim_video_api.py b/object_detector/api/openapi_client/api/object_detector_claim_video_api.py new file mode 100644 index 0000000..814d89c --- /dev/null +++ b/object_detector/api/openapi_client/api/object_detector_claim_video_api.py @@ -0,0 +1,305 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from openapi_client.models.response_with_generic_of_video import ResponseWithGenericOfVideo +from openapi_client.models.video_object_detector_claim_request import VideoObjectDetectorClaimRequest + +from openapi_client.api_client import ApiClient, RequestSerialized +from openapi_client.api_response import ApiResponse +from openapi_client.rest import RESTResponseType + + +class ObjectDetectorClaimVideoApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def post_object_detector_claim_videos( + self, + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfVideo: + """post_object_detector_claim_videos + + + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_object_detector_claim_videos_serialize( + video_object_detector_claim_request=video_object_detector_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_object_detector_claim_videos_with_http_info( + self, + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfVideo]: + """post_object_detector_claim_videos + + + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_object_detector_claim_videos_serialize( + video_object_detector_claim_request=video_object_detector_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_object_detector_claim_videos_without_preload_content( + self, + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_object_detector_claim_videos + + + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_object_detector_claim_videos_serialize( + video_object_detector_claim_request=video_object_detector_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_object_detector_claim_videos_serialize( + self, + video_object_detector_claim_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if video_object_detector_claim_request is not None: + _body_params = video_object_detector_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/object-detector-claim-video', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/object_detector/api/openapi_client/api/custom_api.py b/object_detector/api/openapi_client/api/object_tracker_claim_video_api.py similarity index 82% rename from object_detector/api/openapi_client/api/custom_api.py rename to object_detector/api/openapi_client/api/object_tracker_claim_video_api.py index fca94d2..e9a1ecd 100644 --- a/object_detector/api/openapi_client/api/custom_api.py +++ b/object_detector/api/openapi_client/api/object_tracker_claim_video_api.py @@ -16,15 +16,15 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from openapi_client.models.claim_request import ClaimRequest -from openapi_client.models.video import Video +from openapi_client.models.response_with_generic_of_video import ResponseWithGenericOfVideo +from openapi_client.models.video_object_tracker_claim_request import VideoObjectTrackerClaimRequest from openapi_client.api_client import ApiClient, RequestSerialized from openapi_client.api_response import ApiResponse from openapi_client.rest import RESTResponseType -class CustomApi: +class ObjectTrackerClaimVideoApi: """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech @@ -38,9 +38,9 @@ def __init__(self, api_client=None) -> None: @validate_call - def patch_custom_claim_video_for_object_detector( + def post_object_tracker_claim_videos( self, - claim_request: ClaimRequest, + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -53,12 +53,12 @@ def patch_custom_claim_video_for_object_detector( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Video: - """patch_custom_claim_video_for_object_detector + ) -> ResponseWithGenericOfVideo: + """post_object_tracker_claim_videos - :param claim_request: (required) - :type claim_request: ClaimRequest + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -81,8 +81,8 @@ def patch_custom_claim_video_for_object_detector( :return: Returns the result object. """ # noqa: E501 - _param = self._patch_custom_claim_video_for_object_detector_serialize( - claim_request=claim_request, + _param = self._post_object_tracker_claim_videos_serialize( + video_object_tracker_claim_request=video_object_tracker_claim_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -90,7 +90,7 @@ def patch_custom_claim_video_for_object_detector( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Video", + '200': "ResponseWithGenericOfVideo", } response_data = self.api_client.call_api( *_param, @@ -104,9 +104,9 @@ def patch_custom_claim_video_for_object_detector( @validate_call - def patch_custom_claim_video_for_object_detector_with_http_info( + def post_object_tracker_claim_videos_with_http_info( self, - claim_request: ClaimRequest, + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -119,12 +119,12 @@ def patch_custom_claim_video_for_object_detector_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[Video]: - """patch_custom_claim_video_for_object_detector + ) -> ApiResponse[ResponseWithGenericOfVideo]: + """post_object_tracker_claim_videos - :param claim_request: (required) - :type claim_request: ClaimRequest + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -147,8 +147,8 @@ def patch_custom_claim_video_for_object_detector_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._patch_custom_claim_video_for_object_detector_serialize( - claim_request=claim_request, + _param = self._post_object_tracker_claim_videos_serialize( + video_object_tracker_claim_request=video_object_tracker_claim_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -156,7 +156,7 @@ def patch_custom_claim_video_for_object_detector_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Video", + '200': "ResponseWithGenericOfVideo", } response_data = self.api_client.call_api( *_param, @@ -170,9 +170,9 @@ def patch_custom_claim_video_for_object_detector_with_http_info( @validate_call - def patch_custom_claim_video_for_object_detector_without_preload_content( + def post_object_tracker_claim_videos_without_preload_content( self, - claim_request: ClaimRequest, + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -186,11 +186,11 @@ def patch_custom_claim_video_for_object_detector_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """patch_custom_claim_video_for_object_detector + """post_object_tracker_claim_videos - :param claim_request: (required) - :type claim_request: ClaimRequest + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -213,8 +213,8 @@ def patch_custom_claim_video_for_object_detector_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._patch_custom_claim_video_for_object_detector_serialize( - claim_request=claim_request, + _param = self._post_object_tracker_claim_videos_serialize( + video_object_tracker_claim_request=video_object_tracker_claim_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -222,7 +222,7 @@ def patch_custom_claim_video_for_object_detector_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Video", + '200': "ResponseWithGenericOfVideo", } response_data = self.api_client.call_api( *_param, @@ -231,9 +231,9 @@ def patch_custom_claim_video_for_object_detector_without_preload_content( return response_data.response - def _patch_custom_claim_video_for_object_detector_serialize( + def _post_object_tracker_claim_videos_serialize( self, - claim_request, + video_object_tracker_claim_request, _request_auth, _content_type, _headers, @@ -257,8 +257,8 @@ def _patch_custom_claim_video_for_object_detector_serialize( # process the header parameters # process the form parameters # process the body parameter - if claim_request is not None: - _body_params = claim_request + if video_object_tracker_claim_request is not None: + _body_params = video_object_tracker_claim_request # set the HTTP header `Accept` @@ -288,8 +288,8 @@ def _patch_custom_claim_video_for_object_detector_serialize( ] return self.api_client.param_serialize( - method='PATCH', - resource_path='/api/custom/claim-video-for-object-detector', + method='POST', + resource_path='/api/object-tracker-claim-video', path_params=_path_params, query_params=_query_params, header_params=_header_params, diff --git a/object_detector/api/openapi_client/api/segment_producer_claim_camera_api.py b/object_detector/api/openapi_client/api/segment_producer_claim_camera_api.py new file mode 100644 index 0000000..e28e03b --- /dev/null +++ b/object_detector/api/openapi_client/api/segment_producer_claim_camera_api.py @@ -0,0 +1,305 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from openapi_client.models.camera_segment_producer_claim_request import CameraSegmentProducerClaimRequest +from openapi_client.models.response_with_generic_of_camera import ResponseWithGenericOfCamera + +from openapi_client.api_client import ApiClient, RequestSerialized +from openapi_client.api_response import ApiResponse +from openapi_client.rest import RESTResponseType + + +class SegmentProducerClaimCameraApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def post_segment_producer_claim_cameras( + self, + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfCamera: + """post_segment_producer_claim_cameras + + + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_segment_producer_claim_cameras_serialize( + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_segment_producer_claim_cameras_with_http_info( + self, + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfCamera]: + """post_segment_producer_claim_cameras + + + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_segment_producer_claim_cameras_serialize( + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_segment_producer_claim_cameras_without_preload_content( + self, + camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_segment_producer_claim_cameras + + + :param camera_segment_producer_claim_request: (required) + :type camera_segment_producer_claim_request: CameraSegmentProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_segment_producer_claim_cameras_serialize( + camera_segment_producer_claim_request=camera_segment_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_segment_producer_claim_cameras_serialize( + self, + camera_segment_producer_claim_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if camera_segment_producer_claim_request is not None: + _body_params = camera_segment_producer_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/segment-producer-claim-camera', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/object_detector/api/openapi_client/api/stream_producer_claim_camera_api.py b/object_detector/api/openapi_client/api/stream_producer_claim_camera_api.py new file mode 100644 index 0000000..e0b10aa --- /dev/null +++ b/object_detector/api/openapi_client/api/stream_producer_claim_camera_api.py @@ -0,0 +1,305 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from openapi_client.models.camera_stream_producer_claim_request import CameraStreamProducerClaimRequest +from openapi_client.models.response_with_generic_of_camera import ResponseWithGenericOfCamera + +from openapi_client.api_client import ApiClient, RequestSerialized +from openapi_client.api_response import ApiResponse +from openapi_client.rest import RESTResponseType + + +class StreamProducerClaimCameraApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def post_stream_producer_claim_cameras( + self, + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfCamera: + """post_stream_producer_claim_cameras + + + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_stream_producer_claim_cameras_serialize( + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_stream_producer_claim_cameras_with_http_info( + self, + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfCamera]: + """post_stream_producer_claim_cameras + + + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_stream_producer_claim_cameras_serialize( + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_stream_producer_claim_cameras_without_preload_content( + self, + camera_stream_producer_claim_request: CameraStreamProducerClaimRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_stream_producer_claim_cameras + + + :param camera_stream_producer_claim_request: (required) + :type camera_stream_producer_claim_request: CameraStreamProducerClaimRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_stream_producer_claim_cameras_serialize( + camera_stream_producer_claim_request=camera_stream_producer_claim_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfCamera", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_stream_producer_claim_cameras_serialize( + self, + camera_stream_producer_claim_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if camera_stream_producer_claim_request is not None: + _body_params = camera_stream_producer_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/stream-producer-claim-camera', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/object_detector/api/openapi_client/api/video_api.py b/object_detector/api/openapi_client/api/video_api.py index bbda2cc..ed40669 100644 --- a/object_detector/api/openapi_client/api/video_api.py +++ b/object_detector/api/openapi_client/api/video_api.py @@ -22,6 +22,8 @@ from typing_extensions import Annotated from openapi_client.models.response_with_generic_of_video import ResponseWithGenericOfVideo from openapi_client.models.video import Video +from openapi_client.models.video_object_detector_claim_request import VideoObjectDetectorClaimRequest +from openapi_client.models.video_object_tracker_claim_request import VideoObjectTrackerClaimRequest from openapi_client.api_client import ApiClient, RequestSerialized from openapi_client.api_response import ApiResponse @@ -6245,3 +6247,603 @@ def _post_videos_serialize( ) + + + @validate_call + def post_videos_object_detector_claim( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfVideo: + """post_videos_object_detector_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_detector_claim_serialize( + primary_key=primary_key, + video_object_detector_claim_request=video_object_detector_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_videos_object_detector_claim_with_http_info( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfVideo]: + """post_videos_object_detector_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_detector_claim_serialize( + primary_key=primary_key, + video_object_detector_claim_request=video_object_detector_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_videos_object_detector_claim_without_preload_content( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_detector_claim_request: VideoObjectDetectorClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_videos_object_detector_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_detector_claim_request: (required) + :type video_object_detector_claim_request: VideoObjectDetectorClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_detector_claim_serialize( + primary_key=primary_key, + video_object_detector_claim_request=video_object_detector_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_videos_object_detector_claim_serialize( + self, + primary_key, + video_object_detector_claim_request, + depth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if primary_key is not None: + _path_params['primaryKey'] = primary_key + # process the query parameters + if depth is not None: + + _query_params.append(('depth', depth)) + + # process the header parameters + # process the form parameters + # process the body parameter + if video_object_detector_claim_request is not None: + _body_params = video_object_detector_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/videos/{primaryKey}/object-detector-claim', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_videos_object_tracker_claim( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResponseWithGenericOfVideo: + """post_videos_object_tracker_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_tracker_claim_serialize( + primary_key=primary_key, + video_object_tracker_claim_request=video_object_tracker_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_videos_object_tracker_claim_with_http_info( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResponseWithGenericOfVideo]: + """post_videos_object_tracker_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_tracker_claim_serialize( + primary_key=primary_key, + video_object_tracker_claim_request=video_object_tracker_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_videos_object_tracker_claim_without_preload_content( + self, + primary_key: Annotated[StrictStr, Field(description="Path parameter primaryKey")], + video_object_tracker_claim_request: VideoObjectTrackerClaimRequest, + depth: Annotated[Optional[StrictInt], Field(description="Query parameter depth")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """post_videos_object_tracker_claim + + + :param primary_key: Path parameter primaryKey (required) + :type primary_key: str + :param video_object_tracker_claim_request: (required) + :type video_object_tracker_claim_request: VideoObjectTrackerClaimRequest + :param depth: Query parameter depth + :type depth: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_videos_object_tracker_claim_serialize( + primary_key=primary_key, + video_object_tracker_claim_request=video_object_tracker_claim_request, + depth=depth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResponseWithGenericOfVideo", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_videos_object_tracker_claim_serialize( + self, + primary_key, + video_object_tracker_claim_request, + depth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if primary_key is not None: + _path_params['primaryKey'] = primary_key + # process the query parameters + if depth is not None: + + _query_params.append(('depth', depth)) + + # process the header parameters + # process the form parameters + # process the body parameter + if video_object_tracker_claim_request is not None: + _body_params = video_object_tracker_claim_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/videos/{primaryKey}/object-tracker-claim', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/object_detector/api/openapi_client/models/__init__.py b/object_detector/api/openapi_client/models/__init__.py index b16a764..772acf3 100644 --- a/object_detector/api/openapi_client/models/__init__.py +++ b/object_detector/api/openapi_client/models/__init__.py @@ -16,7 +16,8 @@ # import models into model package from openapi_client.models.array_of_vec2_inner import ArrayOfVec2Inner from openapi_client.models.camera import Camera -from openapi_client.models.claim_request import ClaimRequest +from openapi_client.models.camera_segment_producer_claim_request import CameraSegmentProducerClaimRequest +from openapi_client.models.camera_stream_producer_claim_request import CameraStreamProducerClaimRequest from openapi_client.models.detection import Detection from openapi_client.models.get_cameras_default_response import GetCamerasDefaultResponse from openapi_client.models.response_with_generic_of_camera import ResponseWithGenericOfCamera @@ -24,3 +25,5 @@ from openapi_client.models.response_with_generic_of_video import ResponseWithGenericOfVideo from openapi_client.models.vec2 import Vec2 from openapi_client.models.video import Video +from openapi_client.models.video_object_detector_claim_request import VideoObjectDetectorClaimRequest +from openapi_client.models.video_object_tracker_claim_request import VideoObjectTrackerClaimRequest diff --git a/object_detector/api/openapi_client/models/camera_segment_producer_claim_request.py b/object_detector/api/openapi_client/models/camera_segment_producer_claim_request.py new file mode 100644 index 0000000..6cb2b77 --- /dev/null +++ b/object_detector/api/openapi_client/models/camera_segment_producer_claim_request.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class CameraSegmentProducerClaimRequest(BaseModel): + """ + CameraSegmentProducerClaimRequest + """ # noqa: E501 + timeout_seconds: Optional[Union[StrictFloat, StrictInt]] = None + until: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["timeout_seconds", "until"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CameraSegmentProducerClaimRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CameraSegmentProducerClaimRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timeout_seconds": obj.get("timeout_seconds"), + "until": obj.get("until") + }) + return _obj + + diff --git a/object_detector/api/openapi_client/models/camera_stream_producer_claim_request.py b/object_detector/api/openapi_client/models/camera_stream_producer_claim_request.py new file mode 100644 index 0000000..2a8b9c3 --- /dev/null +++ b/object_detector/api/openapi_client/models/camera_stream_producer_claim_request.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class CameraStreamProducerClaimRequest(BaseModel): + """ + CameraStreamProducerClaimRequest + """ # noqa: E501 + timeout_seconds: Optional[Union[StrictFloat, StrictInt]] = None + until: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["timeout_seconds", "until"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CameraStreamProducerClaimRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CameraStreamProducerClaimRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timeout_seconds": obj.get("timeout_seconds"), + "until": obj.get("until") + }) + return _obj + + diff --git a/object_detector/api/openapi_client/models/video_object_detector_claim_request.py b/object_detector/api/openapi_client/models/video_object_detector_claim_request.py new file mode 100644 index 0000000..3c6a7f5 --- /dev/null +++ b/object_detector/api/openapi_client/models/video_object_detector_claim_request.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Djangolang + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class VideoObjectDetectorClaimRequest(BaseModel): + """ + VideoObjectDetectorClaimRequest + """ # noqa: E501 + timeout_seconds: Optional[Union[StrictFloat, StrictInt]] = None + until: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["timeout_seconds", "until"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of VideoObjectDetectorClaimRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of VideoObjectDetectorClaimRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timeout_seconds": obj.get("timeout_seconds"), + "until": obj.get("until") + }) + return _obj + + diff --git a/object_detector/api/openapi_client/models/claim_request.py b/object_detector/api/openapi_client/models/video_object_tracker_claim_request.py similarity index 80% rename from object_detector/api/openapi_client/models/claim_request.py rename to object_detector/api/openapi_client/models/video_object_tracker_claim_request.py index 2680a86..4befa16 100644 --- a/object_detector/api/openapi_client/models/claim_request.py +++ b/object_detector/api/openapi_client/models/video_object_tracker_claim_request.py @@ -17,17 +17,19 @@ import re # noqa: F401 import json +from datetime import datetime from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set from typing_extensions import Self -class ClaimRequest(BaseModel): +class VideoObjectTrackerClaimRequest(BaseModel): """ - ClaimRequest + VideoObjectTrackerClaimRequest """ # noqa: E501 - claim_duration_seconds: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["claim_duration_seconds"] + timeout_seconds: Optional[Union[StrictFloat, StrictInt]] = None + until: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["timeout_seconds", "until"] model_config = ConfigDict( populate_by_name=True, @@ -47,7 +49,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ClaimRequest from a JSON string""" + """Create an instance of VideoObjectTrackerClaimRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -72,7 +74,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ClaimRequest from a dict""" + """Create an instance of VideoObjectTrackerClaimRequest from a dict""" if obj is None: return None @@ -80,7 +82,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "claim_duration_seconds": obj.get("claim_duration_seconds") + "timeout_seconds": obj.get("timeout_seconds"), + "until": obj.get("until") }) return _obj diff --git a/object_detector/object_detector.py b/object_detector/object_detector.py index 6180e0b..05e833e 100644 --- a/object_detector/object_detector.py +++ b/object_detector/object_detector.py @@ -18,8 +18,8 @@ DetectionApi, Detection, ArrayOfVec2Inner as DetectionBoundingBoxInner, - CustomApi, - ClaimRequest, + ObjectDetectorClaimVideoApi, + VideoObjectDetectorClaimRequest, ) @@ -35,7 +35,7 @@ def cleanup(): def do( video_api: VideoApi, detection_api: DetectionApi, - custom_api: CustomApi, + object_detector_claim_video_api: ObjectDetectorClaimVideoApi, source_path: str, one_shot_video_file_name: str | None = None, ): @@ -52,13 +52,15 @@ def do( else: print("waiting to claim a video... ", end="") + until = (datetime.datetime.utcnow() + datetime.timedelta(seconds=60)).replace(tzinfo=UTC) + try: # TODO: inject this as an env var - video = custom_api.patch_custom_claim_video_for_object_detector( - claim_request=ClaimRequest(claim_duration_seconds=60), + resp = object_detector_claim_video_api.post_object_detector_claim_videos( + video_object_detector_claim_request=VideoObjectDetectorClaimRequest(until=until, timeout_seconds=10), _request_timeout=70, ) - videos = [video] + videos = resp.objects except Exception as e: if "wanted exactly 1 unclaimed video, got 0" in str(e): print("no videos available to claim.") @@ -324,7 +326,7 @@ def run(): api_client = ApiClient(configuration) video_api = VideoApi(api_client) detection_api = DetectionApi(api_client) - custom_api = CustomApi(api_client) + custom_api = ObjectDetectorClaimVideoApi(api_client) while 1: try: diff --git a/pkg/api/0_meta.go b/pkg/api/0_meta.go index 7660260..78be2c0 100755 --- a/pkg/api/0_meta.go +++ b/pkg/api/0_meta.go @@ -32,6 +32,7 @@ var patternsAndMutateRouterFns = make([]patternAndMutateRouterFn, 0) var allObjects = make([]any, 0) var openApi *types.OpenAPI var profile = config.Profile() +var schema = "public" var httpHandlerSummaries []server.HTTPHandlerSummary = make([]server.HTTPHandlerSummary, 0) @@ -1084,17 +1085,18 @@ func init() { func RunServer( ctx context.Context, - changes chan server.Change, + changes chan *server.Change, addr string, db *pgxpool.Pool, redisPool *redis.Pool, httpMiddlewares []server.HTTPMiddleware, objectMiddlewares []server.ObjectMiddleware, addCustomHandlers func(chi.Router) error, + nodeNames ...string, ) error { mu.Lock() thisTableByName := tableByName mu.Unlock() - return server.RunServer(ctx, changes, addr, NewFromItem, MutateRouter, db, redisPool, httpMiddlewares, objectMiddlewares, addCustomHandlers, thisTableByName) + return server.RunServer(ctx, changes, addr, NewFromItem, MutateRouter, db, redisPool, httpMiddlewares, objectMiddlewares, addCustomHandlers, thisTableByName, nodeNames...) } diff --git a/pkg/api/bin/api b/pkg/api/bin/api index 67c49d8..f910f13 100755 Binary files a/pkg/api/bin/api and b/pkg/api/bin/api differ diff --git a/pkg/api/camera.go b/pkg/api/camera.go index e94253a..3074100 100755 --- a/pkg/api/camera.go +++ b/pkg/api/camera.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "maps" "math" "net/http" "net/netip" @@ -27,7 +28,6 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgxpool" - "golang.org/x/exp/maps" ) type Camera struct { @@ -46,6 +46,8 @@ type Camera struct { var CameraTable = "camera" +var CameraTableWithSchema = fmt.Sprintf("%s.%s", schema, CameraTable) + var CameraTableNamespaceID int32 = 1337 + 1 var ( @@ -123,9 +125,13 @@ type CameraLoadQueryParams struct { Depth *int `json:"depth"` } -type CameraClaimRequest struct { +type CameraSegmentProducerClaimRequest struct { + Until time.Time `json:"until"` + TimeoutSeconds float64 `json:"timeout_seconds"` +} + +type CameraStreamProducerClaimRequest struct { Until time.Time `json:"until"` - By uuid.UUID `json:"by"` TimeoutSeconds float64 `json:"timeout_seconds"` } @@ -357,6 +363,22 @@ func (m *Camera) FromItem(item map[string]any) error { return nil } +func (m *Camera) ToItem() map[string]any { + item := make(map[string]any) + + b, err := json.Marshal(m) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate marshal to JSON: %s", m, err)) + } + + err = json.Unmarshal(b, &item) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate unmarshal from JSON: %s", m, err)) + } + + return item +} + func (m *Camera) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bool) error { extraWhere := "" if len(includeDeleteds) > 0 && includeDeleteds[0] { @@ -395,7 +417,7 @@ func (m *Camera) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bool) return nil } -func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { +func (m *Camera) GetColumnsAndValues(setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]string, []any, error) { columns := make([]string, 0) values := make([]any, 0) @@ -404,7 +426,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatUUID(m.ID) if err != nil { - return fmt.Errorf("failed to handle m.ID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ID; %v", err) } values = append(values, v) @@ -415,7 +437,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.CreatedAt) if err != nil { - return fmt.Errorf("failed to handle m.CreatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.CreatedAt; %v", err) } values = append(values, v) @@ -426,7 +448,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.UpdatedAt) if err != nil { - return fmt.Errorf("failed to handle m.UpdatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.UpdatedAt; %v", err) } values = append(values, v) @@ -437,7 +459,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.DeletedAt) if err != nil { - return fmt.Errorf("failed to handle m.DeletedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.DeletedAt; %v", err) } values = append(values, v) @@ -448,7 +470,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatString(m.Name) if err != nil { - return fmt.Errorf("failed to handle m.Name; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.Name; %v", err) } values = append(values, v) @@ -459,7 +481,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatString(m.StreamURL) if err != nil { - return fmt.Errorf("failed to handle m.StreamURL; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.StreamURL; %v", err) } values = append(values, v) @@ -470,7 +492,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.LastSeen) if err != nil { - return fmt.Errorf("failed to handle m.LastSeen; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.LastSeen; %v", err) } values = append(values, v) @@ -481,7 +503,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.SegmentProducerClaimedUntil) if err != nil { - return fmt.Errorf("failed to handle m.SegmentProducerClaimedUntil; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.SegmentProducerClaimedUntil; %v", err) } values = append(values, v) @@ -492,12 +514,21 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ v, err := types.FormatTime(m.StreamProducerClaimedUntil) if err != nil { - return fmt.Errorf("failed to handle m.StreamProducerClaimedUntil; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.StreamProducerClaimedUntil; %v", err) } values = append(values, v) } + return columns, values, nil +} + +func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { + columns, values, err := m.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return fmt.Errorf("failed to get columns and values to insert %#+v; %v", m, err) + } + ctx, cleanup := query.WithQueryID(ctx) defer cleanup() @@ -506,7 +537,7 @@ func (m *Camera) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZ item, err := query.Insert( ctx, tx, - CameraTable, + CameraTableWithSchema, columns, nil, false, @@ -659,7 +690,7 @@ func (m *Camera) Update(ctx context.Context, tx pgx.Tx, setZeroValues bool, forc _, err = query.Update( ctx, tx, - CameraTable, + CameraTableWithSchema, columns, fmt.Sprintf("%v = $$??", CameraTableIDColumn), CameraTableColumns, @@ -707,7 +738,7 @@ func (m *Camera) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) err err = query.Delete( ctx, tx, - CameraTable, + CameraTableWithSchema, fmt.Sprintf("%v = $$??", CameraTableIDColumn), values..., ) @@ -721,11 +752,11 @@ func (m *Camera) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) err } func (m *Camera) LockTable(ctx context.Context, tx pgx.Tx, timeouts ...time.Duration) error { - return query.LockTable(ctx, tx, CameraTable, timeouts...) + return query.LockTable(ctx, tx, CameraTableWithSchema, timeouts...) } func (m *Camera) LockTableWithRetries(ctx context.Context, tx pgx.Tx, overallTimeout time.Duration, individualAttempttimeout time.Duration) error { - return query.LockTableWithRetries(ctx, tx, CameraTable, overallTimeout, individualAttempttimeout) + return query.LockTableWithRetries(ctx, tx, CameraTableWithSchema, overallTimeout, individualAttempttimeout) } func (m *Camera) AdvisoryLock(ctx context.Context, tx pgx.Tx, key int32, timeouts ...time.Duration) error { @@ -736,34 +767,55 @@ func (m *Camera) AdvisoryLockWithRetries(ctx context.Context, tx pgx.Tx, key int return query.AdvisoryLockWithRetries(ctx, tx, CameraTableNamespaceID, key, overallTimeout, individualAttempttimeout) } -func (m *Camera) Claim(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration) error { - if !(slices.Contains(CameraTableColumns, "claimed_until") && slices.Contains(CameraTableColumns, "claimed_by")) { - return fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") +func (m *Camera) SegmentProducerClaim(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration) error { + err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) + if err != nil { + return fmt.Errorf("failed to claim (advisory lock): %s", err.Error()) + } + + _, _, _, _, _, err = SelectCamera( + ctx, + tx, + fmt.Sprintf( + "%s = $$?? AND (segment_producer_claimed_until IS null OR segment_producer_claimed_until < now())", + CameraTablePrimaryKeyColumn, + ), + m.GetPrimaryKeyValue(), + ) + if err != nil { + return fmt.Errorf("failed to claim (select): %s", err.Error()) + } + + m.SegmentProducerClaimedUntil = until + + err = m.Update(ctx, tx, false) + if err != nil { + return fmt.Errorf("failed to claim (update): %s", err.Error()) } + return nil +} + +func (m *Camera) StreamProducerClaim(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration) error { err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) if err != nil { return fmt.Errorf("failed to claim (advisory lock): %s", err.Error()) } - x, _, _, _, _, err := SelectCamera( + _, _, _, _, _, err = SelectCamera( ctx, tx, fmt.Sprintf( - "%s = $$?? AND (claimed_by = $$?? OR (claimed_until IS null OR claimed_until < now()))", + "%s = $$?? AND (stream_producer_claimed_until IS null OR stream_producer_claimed_until < now())", CameraTablePrimaryKeyColumn, ), m.GetPrimaryKeyValue(), - by, ) if err != nil { return fmt.Errorf("failed to claim (select): %s", err.Error()) } - _ = x - - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ + m.StreamProducerClaimedUntil = until err = m.Update(ctx, tx, false) if err != nil { @@ -810,29 +862,57 @@ func SelectCameras(ctx context.Context, tx pgx.Tx, where string, orderBy *string return []*Camera{}, 0, 0, 0, 0, nil } - items, count, totalCount, page, totalPages, err := query.Select( - ctx, - tx, - CameraTableColumnsWithTypeCasts, - CameraTable, - where, - orderBy, - limit, - offset, - values..., - ) - if err != nil { - return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectCameras; %v", err) + var items *[]map[string]any + var count int64 + var totalCount int64 + var page int64 + var totalPages int64 + var err error + + useInstead, shouldSkip := query.ShouldSkip[Camera](ctx) + if !shouldSkip { + items, count, totalCount, page, totalPages, err = query.Select( + ctx, + tx, + CameraTableColumnsWithTypeCasts, + CameraTableWithSchema, + where, + orderBy, + limit, + offset, + values..., + ) + if err != nil { + return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectCameras; %v", err) + } + } else { + ctx = query.WithoutSkip(ctx) + count = 1 + totalCount = 1 + page = 1 + totalPages = 1 + items = &[]map[string]any{ + nil, + } } objects := make([]*Camera, 0) for _, item := range *items { - object := &Camera{} + var object *Camera - err = object.FromItem(item) - if err != nil { - return nil, 0, 0, 0, 0, err + if !shouldSkip { + object = &Camera{} + err = object.FromItem(item) + if err != nil { + return nil, 0, 0, 0, 0, err + } + } else { + object = useInstead + } + + if object == nil { + return nil, 0, 0, 0, 0, fmt.Errorf("assertion failed: object unexpectedly nil") } err = func() error { @@ -952,11 +1032,73 @@ func SelectCamera(ctx context.Context, tx pgx.Tx, where string, values ...any) ( return object, count, totalCount, page, totalPages, nil } -func ClaimCamera(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration, wheres ...string) (*Camera, error) { - if !(slices.Contains(CameraTableColumns, "claimed_until") && slices.Contains(CameraTableColumns, "claimed_by")) { - return nil, fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") +func InsertCameras(ctx context.Context, tx pgx.Tx, objects []*Camera, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]*Camera, error) { + var columns []string + values := make([]any, 0) + + for i, object := range objects { + thisColumns, thisValues, err := object.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return nil, err + } + + if columns == nil { + columns = thisColumns + } else { + if len(columns) != len(thisColumns) { + return nil, fmt.Errorf( + "assertion failed: call 1 of object.GetColumnsAndValues() gave %d columns but call %d gave %d columns", + len(columns), + i+1, + len(thisColumns), + ) + } + } + + values = append(values, thisValues...) + } + + ctx, cleanup := query.WithQueryID(ctx) + defer cleanup() + + ctx = query.WithMaxDepth(ctx, nil) + + items, err := query.BulkInsert( + ctx, + tx, + CameraTableWithSchema, + columns, + nil, + false, + false, + CameraTableColumns, + values..., + ) + if err != nil { + return nil, fmt.Errorf("failed to bulk insert %d objects; %v", len(objects), err) + } + + returnedObjects := make([]*Camera, 0) + + for _, item := range items { + v := &Camera{} + err = v.FromItem(*item) + if err != nil { + return nil, fmt.Errorf("failed %T.FromItem for %#+v; %v", *item, *item, err) + } + + err = v.Reload(query.WithSkip(ctx, v), tx) + if err != nil { + return nil, fmt.Errorf("failed %T.Reload for %#+v; %v", *item, *item, err) + } + + returnedObjects = append(returnedObjects, v) } + return returnedObjects, nil +} + +func SegmentProducerClaimCamera(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration, where string, values ...any) (*Camera, error) { m := &Camera{} err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) @@ -964,23 +1106,67 @@ func ClaimCamera(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, return nil, fmt.Errorf("failed to claim: %s", err.Error()) } - extraWhere := "" - if len(wheres) > 0 { - extraWhere = fmt.Sprintf("AND %s", extraWhere) + if strings.TrimSpace(where) != "" { + where += " AND\n" } + where += " (segment_producer_claimed_until IS null OR segment_producer_claimed_until < now())" + ms, _, _, _, _, err := SelectCameras( ctx, tx, - fmt.Sprintf( - "(claimed_until IS null OR claimed_until < now())%s", - extraWhere, + where, + helpers.Ptr( + "segment_producer_claimed_until ASC", ), + helpers.Ptr(1), + nil, + values..., + ) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + if len(ms) == 0 { + return nil, nil + } + + m = ms[0] + + m.SegmentProducerClaimedUntil = until + + err = m.Update(ctx, tx, false) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + return m, nil +} + +func StreamProducerClaimCamera(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration, where string, values ...any) (*Camera, error) { + m := &Camera{} + + err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + if strings.TrimSpace(where) != "" { + where += " AND\n" + } + + where += " (stream_producer_claimed_until IS null OR stream_producer_claimed_until < now())" + + ms, _, _, _, _, err := SelectCameras( + ctx, + tx, + where, helpers.Ptr( - "claimed_until ASC", + "stream_producer_claimed_until ASC", ), helpers.Ptr(1), nil, + values..., ) if err != nil { return nil, fmt.Errorf("failed to claim: %s", err.Error()) @@ -992,8 +1178,7 @@ func ClaimCamera(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, m = ms[0] - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ + m.StreamProducerClaimedUntil = until err = m.Update(ctx, tx, false) if err != nil { @@ -1049,7 +1234,7 @@ func handleGetCamera(arguments *server.SelectOneArguments, db *pgxpool.Pool, pri return []*Camera{object}, count, totalCount, page, totalPages, nil } -func handlePostCameras(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Camera, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Camera, int64, int64, int64, int64, error) { +func handlePostCamera(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Camera, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Camera, int64, int64, int64, int64, error) { tx, err := db.Begin(arguments.Ctx) if err != nil { err = fmt.Errorf("failed to begin DB transaction; %v", err) @@ -1065,18 +1250,23 @@ func handlePostCameras(arguments *server.LoadArguments, db *pgxpool.Pool, waitFo err = fmt.Errorf("failed to get xid; %v", err) return nil, 0, 0, 0, 0, err } - _ = xid - for i, object := range objects { - err = object.Insert(arguments.Ctx, tx, false, false, forceSetValuesForFieldsByObjectIndex[i]...) - if err != nil { - err = fmt.Errorf("failed to insert %#+v; %v", object, err) - return nil, 0, 0, 0, 0, err + /* TODO: problematic- basically the bulks insert insists all rows have the same schema, which they usually should */ + forceSetValuesForFieldsByObjectIndexMaximal := make(map[string]struct{}) + for _, forceSetforceSetValuesForFields := range forceSetValuesForFieldsByObjectIndex { + for _, field := range forceSetforceSetValuesForFields { + forceSetValuesForFieldsByObjectIndexMaximal[field] = struct{}{} } + } - objects[i] = object + returnedObjects, err := InsertCameras(arguments.Ctx, tx, objects, false, false, slices.Collect(maps.Keys(forceSetValuesForFieldsByObjectIndexMaximal))...) + if err != nil { + err = fmt.Errorf("failed to insert %d objects; %v", len(objects), err) + return nil, 0, 0, 0, 0, err } + copy(objects, returnedObjects) + errs := make(chan error, 1) go func() { _, err := waitForChange(arguments.Ctx, []stream.Action{stream.INSERT}, CameraTable, xid) @@ -1289,172 +1479,336 @@ func handleDeleteCamera(arguments *server.LoadArguments, db *pgxpool.Pool, waitF } func MutateRouterForCamera(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, objectMiddlewares []server.ObjectMiddleware, waitForChange server.WaitForChange) { - if slices.Contains(CameraTableColumns, "claimed_until") && slices.Contains(CameraTableColumns, "claimed_by") { - func() { - postHandlerForClaim, err := getHTTPHandler( - http.MethodPost, - "/claim-camera", - http.StatusOK, - func( - ctx context.Context, - pathParams server.EmptyPathParams, - queryParams server.EmptyQueryParams, - req CameraClaimRequest, - rawReq any, - ) (server.Response[Camera], error) { - tx, err := db.Begin(ctx) - if err != nil { - return server.Response[Camera]{}, err - } - - defer func() { - _ = tx.Rollback(ctx) - }() - object, err := ClaimCamera(ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return server.Response[Camera]{}, err - } + func() { + postHandlerForSegmentProducerClaim, err := getHTTPHandler( + http.MethodPost, + "/segment-producer-claim-camera", + http.StatusOK, + func( + ctx context.Context, + pathParams server.EmptyPathParams, + queryParams server.EmptyQueryParams, + req CameraSegmentProducerClaimRequest, + rawReq any, + ) (server.Response[Camera], error) { + tx, err := db.Begin(ctx) + if err != nil { + return server.Response[Camera]{}, err + } - count := int64(0) + defer func() { + _ = tx.Rollback(ctx) + }() - totalCount := int64(0) + object, err := SegmentProducerClaimCamera(ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000), "") + if err != nil { + return server.Response[Camera]{}, err + } - limit := int64(0) + count := int64(0) - offset := int64(0) + totalCount := int64(0) - if object == nil { - return server.Response[Camera]{ - Status: http.StatusOK, - Success: true, - Error: nil, - Objects: []*Camera{}, - Count: count, - TotalCount: totalCount, - Limit: limit, - Offset: offset, - }, nil - } + limit := int64(0) - err = tx.Commit(ctx) - if err != nil { - return server.Response[Camera]{}, err - } + offset := int64(0) + if object == nil { return server.Response[Camera]{ Status: http.StatusOK, Success: true, Error: nil, - Objects: []*Camera{object}, + Objects: []*Camera{}, Count: count, TotalCount: totalCount, Limit: limit, Offset: offset, }, nil - }, - Camera{}, - CameraIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaim.FullPath, postHandlerForClaim.ServeHTTP) - - postHandlerForClaimOne, err := getHTTPHandler( - http.MethodPost, - "/cameras/{primaryKey}/claim", - http.StatusOK, - func( - ctx context.Context, - pathParams CameraOnePathParams, - queryParams CameraLoadQueryParams, - req CameraClaimRequest, - rawReq any, - ) (server.Response[Camera], error) { - before := time.Now() - - redisConn := redisPool.Get() + } + + err = tx.Commit(ctx) + if err != nil { + return server.Response[Camera]{}, err + } + + return server.Response[Camera]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Camera{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + }, nil + }, + Camera{}, + CameraIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForSegmentProducerClaim.FullPath, postHandlerForSegmentProducerClaim.ServeHTTP) + + postHandlerForSegmentProducerClaimOne, err := getHTTPHandler( + http.MethodPost, + "/cameras/{primaryKey}/segment-producer-claim", + http.StatusOK, + func( + ctx context.Context, + pathParams CameraOnePathParams, + queryParams CameraLoadQueryParams, + req CameraSegmentProducerClaimRequest, + rawReq any, + ) (server.Response[Camera], error) { + before := time.Now() + + redisConn := redisPool.Get() + defer func() { + _ = redisConn.Close() + }() + + arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, CameraIntrospectedTable, pathParams.PrimaryKey, nil, nil) + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) + } + + return server.Response[Camera]{}, err + } + + /* note: deliberately no attempt at a cache hit */ + + var object *Camera + var count int64 + var totalCount int64 + + err = func() error { + tx, err := db.Begin(arguments.Ctx) + if err != nil { + return err + } + defer func() { - _ = redisConn.Close() + _ = tx.Rollback(arguments.Ctx) }() - arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, CameraIntrospectedTable, pathParams.PrimaryKey, nil, nil) + object, count, totalCount, _, _, err = SelectCamera(arguments.Ctx, tx, arguments.Where, arguments.Values...) if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } + return fmt.Errorf("failed to select object to claim: %s", err.Error()) + } - return server.Response[Camera]{}, err + err = object.SegmentProducerClaim(arguments.Ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) + if err != nil { + return err + } + + err = tx.Commit(arguments.Ctx) + if err != nil { + return err + } + + return nil + }() + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) } - /* note: deliberately no attempt at a cache hit */ + return server.Response[Camera]{}, err + } - var object *Camera - var count int64 - var totalCount int64 + limit := int64(0) - err = func() error { - tx, err := db.Begin(arguments.Ctx) - if err != nil { - return err - } + offset := int64(0) - defer func() { - _ = tx.Rollback(arguments.Ctx) - }() + response := server.Response[Camera]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Camera{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + } - object, count, totalCount, _, _, err = SelectCamera(arguments.Ctx, tx, arguments.Where, arguments.Values...) - if err != nil { - return fmt.Errorf("failed to select object to claim: %s", err.Error()) - } + return response, nil + }, + Camera{}, + CameraIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForSegmentProducerClaimOne.FullPath, postHandlerForSegmentProducerClaimOne.ServeHTTP) + }() - err = object.Claim(arguments.Ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return err - } + func() { + postHandlerForStreamProducerClaim, err := getHTTPHandler( + http.MethodPost, + "/stream-producer-claim-camera", + http.StatusOK, + func( + ctx context.Context, + pathParams server.EmptyPathParams, + queryParams server.EmptyQueryParams, + req CameraStreamProducerClaimRequest, + rawReq any, + ) (server.Response[Camera], error) { + tx, err := db.Begin(ctx) + if err != nil { + return server.Response[Camera]{}, err + } - err = tx.Commit(arguments.Ctx) - if err != nil { - return err - } + defer func() { + _ = tx.Rollback(ctx) + }() - return nil - }() - if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } + object, err := StreamProducerClaimCamera(ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000), "") + if err != nil { + return server.Response[Camera]{}, err + } - return server.Response[Camera]{}, err - } + count := int64(0) + + totalCount := int64(0) - limit := int64(0) + limit := int64(0) - offset := int64(0) + offset := int64(0) - response := server.Response[Camera]{ + if object == nil { + return server.Response[Camera]{ Status: http.StatusOK, Success: true, Error: nil, - Objects: []*Camera{object}, + Objects: []*Camera{}, Count: count, TotalCount: totalCount, Limit: limit, Offset: offset, + }, nil + } + + err = tx.Commit(ctx) + if err != nil { + return server.Response[Camera]{}, err + } + + return server.Response[Camera]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Camera{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + }, nil + }, + Camera{}, + CameraIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForStreamProducerClaim.FullPath, postHandlerForStreamProducerClaim.ServeHTTP) + + postHandlerForStreamProducerClaimOne, err := getHTTPHandler( + http.MethodPost, + "/cameras/{primaryKey}/stream-producer-claim", + http.StatusOK, + func( + ctx context.Context, + pathParams CameraOnePathParams, + queryParams CameraLoadQueryParams, + req CameraStreamProducerClaimRequest, + rawReq any, + ) (server.Response[Camera], error) { + before := time.Now() + + redisConn := redisPool.Get() + defer func() { + _ = redisConn.Close() + }() + + arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, CameraIntrospectedTable, pathParams.PrimaryKey, nil, nil) + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) } - return response, nil - }, - Camera{}, - CameraIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaimOne.FullPath, postHandlerForClaimOne.ServeHTTP) - }() - } + return server.Response[Camera]{}, err + } + + /* note: deliberately no attempt at a cache hit */ + + var object *Camera + var count int64 + var totalCount int64 + + err = func() error { + tx, err := db.Begin(arguments.Ctx) + if err != nil { + return err + } + + defer func() { + _ = tx.Rollback(arguments.Ctx) + }() + + object, count, totalCount, _, _, err = SelectCamera(arguments.Ctx, tx, arguments.Where, arguments.Values...) + if err != nil { + return fmt.Errorf("failed to select object to claim: %s", err.Error()) + } + + err = object.StreamProducerClaim(arguments.Ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) + if err != nil { + return err + } + + err = tx.Commit(arguments.Ctx) + if err != nil { + return err + } + + return nil + }() + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) + } + + return server.Response[Camera]{}, err + } + + limit := int64(0) + + offset := int64(0) + + response := server.Response[Camera]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Camera{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + } + + return response, nil + }, + Camera{}, + CameraIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForStreamProducerClaimOne.FullPath, postHandlerForStreamProducerClaimOne.ServeHTTP) + }() func() { getManyHandler, err := getHTTPHandler( @@ -1714,7 +2068,7 @@ func MutateRouterForCamera(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool forceSetValuesForFieldsByObjectIndex := make([][]string, 0) for _, item := range allItems { forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(CameraTableColumns, possibleField) { continue } @@ -1729,7 +2083,7 @@ func MutateRouterForCamera(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool return server.Response[Camera]{}, err } - objects, count, totalCount, _, _, err := handlePostCameras(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) + objects, count, totalCount, _, _, err := handlePostCamera(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) if err != nil { return server.Response[Camera]{}, err } @@ -1830,7 +2184,7 @@ func MutateRouterForCamera(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool } forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(CameraTableColumns, possibleField) { continue } diff --git a/pkg/api/detection.go b/pkg/api/detection.go index b7d71a9..462c97d 100755 --- a/pkg/api/detection.go +++ b/pkg/api/detection.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - "math" + "maps" "net/http" "net/netip" "slices" @@ -27,7 +27,6 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgxpool" - "golang.org/x/exp/maps" ) type Detection struct { @@ -49,6 +48,8 @@ type Detection struct { var DetectionTable = "detection" +var DetectionTableWithSchema = fmt.Sprintf("%s.%s", schema, DetectionTable) + var DetectionTableNamespaceID int32 = 1337 + 2 var ( @@ -138,12 +139,6 @@ type DetectionLoadQueryParams struct { Depth *int `json:"depth"` } -type DetectionClaimRequest struct { - Until time.Time `json:"until"` - By uuid.UUID `json:"by"` - TimeoutSeconds float64 `json:"timeout_seconds"` -} - /* TODO: find a way to not need this- there is a piece in the templating logic that uses goimports but pending where the code is built, it may resolve @@ -429,6 +424,22 @@ func (m *Detection) FromItem(item map[string]any) error { return nil } +func (m *Detection) ToItem() map[string]any { + item := make(map[string]any) + + b, err := json.Marshal(m) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate marshal to JSON: %s", m, err)) + } + + err = json.Unmarshal(b, &item) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate unmarshal from JSON: %s", m, err)) + } + + return item +} + func (m *Detection) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bool) error { extraWhere := "" if len(includeDeleteds) > 0 && includeDeleteds[0] { @@ -470,7 +481,7 @@ func (m *Detection) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bo return nil } -func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { +func (m *Detection) GetColumnsAndValues(setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]string, []any, error) { columns := make([]string, 0) values := make([]any, 0) @@ -479,7 +490,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatUUID(m.ID) if err != nil { - return fmt.Errorf("failed to handle m.ID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ID; %v", err) } values = append(values, v) @@ -490,7 +501,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatTime(m.CreatedAt) if err != nil { - return fmt.Errorf("failed to handle m.CreatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.CreatedAt; %v", err) } values = append(values, v) @@ -501,7 +512,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatTime(m.UpdatedAt) if err != nil { - return fmt.Errorf("failed to handle m.UpdatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.UpdatedAt; %v", err) } values = append(values, v) @@ -512,7 +523,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatTime(m.DeletedAt) if err != nil { - return fmt.Errorf("failed to handle m.DeletedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.DeletedAt; %v", err) } values = append(values, v) @@ -523,7 +534,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatTime(m.SeenAt) if err != nil { - return fmt.Errorf("failed to handle m.SeenAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.SeenAt; %v", err) } values = append(values, v) @@ -534,7 +545,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatInt(m.ClassID) if err != nil { - return fmt.Errorf("failed to handle m.ClassID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ClassID; %v", err) } values = append(values, v) @@ -545,7 +556,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatString(m.ClassName) if err != nil { - return fmt.Errorf("failed to handle m.ClassName; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ClassName; %v", err) } values = append(values, v) @@ -556,7 +567,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatFloat(m.Score) if err != nil { - return fmt.Errorf("failed to handle m.Score; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.Score; %v", err) } values = append(values, v) @@ -567,7 +578,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatPoint(m.Centroid) if err != nil { - return fmt.Errorf("failed to handle m.Centroid; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.Centroid; %v", err) } values = append(values, v) @@ -578,7 +589,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatPolygon(m.BoundingBox) if err != nil { - return fmt.Errorf("failed to handle m.BoundingBox; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.BoundingBox; %v", err) } values = append(values, v) @@ -589,7 +600,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatUUID(m.VideoID) if err != nil { - return fmt.Errorf("failed to handle m.VideoID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.VideoID; %v", err) } values = append(values, v) @@ -600,12 +611,21 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s v, err := types.FormatUUID(m.CameraID) if err != nil { - return fmt.Errorf("failed to handle m.CameraID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.CameraID; %v", err) } values = append(values, v) } + return columns, values, nil +} + +func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { + columns, values, err := m.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return fmt.Errorf("failed to get columns and values to insert %#+v; %v", m, err) + } + ctx, cleanup := query.WithQueryID(ctx) defer cleanup() @@ -614,7 +634,7 @@ func (m *Detection) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, s item, err := query.Insert( ctx, tx, - DetectionTable, + DetectionTableWithSchema, columns, nil, false, @@ -800,7 +820,7 @@ func (m *Detection) Update(ctx context.Context, tx pgx.Tx, setZeroValues bool, f _, err = query.Update( ctx, tx, - DetectionTable, + DetectionTableWithSchema, columns, fmt.Sprintf("%v = $$??", DetectionTableIDColumn), DetectionTableColumns, @@ -848,7 +868,7 @@ func (m *Detection) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) err = query.Delete( ctx, tx, - DetectionTable, + DetectionTableWithSchema, fmt.Sprintf("%v = $$??", DetectionTableIDColumn), values..., ) @@ -862,11 +882,11 @@ func (m *Detection) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) } func (m *Detection) LockTable(ctx context.Context, tx pgx.Tx, timeouts ...time.Duration) error { - return query.LockTable(ctx, tx, DetectionTable, timeouts...) + return query.LockTable(ctx, tx, DetectionTableWithSchema, timeouts...) } func (m *Detection) LockTableWithRetries(ctx context.Context, tx pgx.Tx, overallTimeout time.Duration, individualAttempttimeout time.Duration) error { - return query.LockTableWithRetries(ctx, tx, DetectionTable, overallTimeout, individualAttempttimeout) + return query.LockTableWithRetries(ctx, tx, DetectionTableWithSchema, overallTimeout, individualAttempttimeout) } func (m *Detection) AdvisoryLock(ctx context.Context, tx pgx.Tx, key int32, timeouts ...time.Duration) error { @@ -877,43 +897,6 @@ func (m *Detection) AdvisoryLockWithRetries(ctx context.Context, tx pgx.Tx, key return query.AdvisoryLockWithRetries(ctx, tx, DetectionTableNamespaceID, key, overallTimeout, individualAttempttimeout) } -func (m *Detection) Claim(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration) error { - if !(slices.Contains(DetectionTableColumns, "claimed_until") && slices.Contains(DetectionTableColumns, "claimed_by")) { - return fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") - } - - err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) - if err != nil { - return fmt.Errorf("failed to claim (advisory lock): %s", err.Error()) - } - - x, _, _, _, _, err := SelectDetection( - ctx, - tx, - fmt.Sprintf( - "%s = $$?? AND (claimed_by = $$?? OR (claimed_until IS null OR claimed_until < now()))", - DetectionTablePrimaryKeyColumn, - ), - m.GetPrimaryKeyValue(), - by, - ) - if err != nil { - return fmt.Errorf("failed to claim (select): %s", err.Error()) - } - - _ = x - - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ - - err = m.Update(ctx, tx, false) - if err != nil { - return fmt.Errorf("failed to claim (update): %s", err.Error()) - } - - return nil -} - func SelectDetections(ctx context.Context, tx pgx.Tx, where string, orderBy *string, limit *int, offset *int, values ...any) ([]*Detection, int64, int64, int64, int64, error) { before := time.Now() @@ -951,29 +934,57 @@ func SelectDetections(ctx context.Context, tx pgx.Tx, where string, orderBy *str return []*Detection{}, 0, 0, 0, 0, nil } - items, count, totalCount, page, totalPages, err := query.Select( - ctx, - tx, - DetectionTableColumnsWithTypeCasts, - DetectionTable, - where, - orderBy, - limit, - offset, - values..., - ) - if err != nil { - return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectDetections; %v", err) + var items *[]map[string]any + var count int64 + var totalCount int64 + var page int64 + var totalPages int64 + var err error + + useInstead, shouldSkip := query.ShouldSkip[Detection](ctx) + if !shouldSkip { + items, count, totalCount, page, totalPages, err = query.Select( + ctx, + tx, + DetectionTableColumnsWithTypeCasts, + DetectionTableWithSchema, + where, + orderBy, + limit, + offset, + values..., + ) + if err != nil { + return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectDetections; %v", err) + } + } else { + ctx = query.WithoutSkip(ctx) + count = 1 + totalCount = 1 + page = 1 + totalPages = 1 + items = &[]map[string]any{ + nil, + } } objects := make([]*Detection, 0) for _, item := range *items { - object := &Detection{} + var object *Detection - err = object.FromItem(item) - if err != nil { - return nil, 0, 0, 0, 0, err + if !shouldSkip { + object = &Detection{} + err = object.FromItem(item) + if err != nil { + return nil, 0, 0, 0, 0, err + } + } else { + object = useInstead + } + + if object == nil { + return nil, 0, 0, 0, 0, fmt.Errorf("assertion failed: object unexpectedly nil") } if !types.IsZeroUUID(object.VideoID) { @@ -1075,55 +1086,70 @@ func SelectDetection(ctx context.Context, tx pgx.Tx, where string, values ...any return object, count, totalCount, page, totalPages, nil } -func ClaimDetection(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration, wheres ...string) (*Detection, error) { - if !(slices.Contains(DetectionTableColumns, "claimed_until") && slices.Contains(DetectionTableColumns, "claimed_by")) { - return nil, fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") - } +func InsertDetections(ctx context.Context, tx pgx.Tx, objects []*Detection, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]*Detection, error) { + var columns []string + values := make([]any, 0) - m := &Detection{} + for i, object := range objects { + thisColumns, thisValues, err := object.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return nil, err + } - err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) - if err != nil { - return nil, fmt.Errorf("failed to claim: %s", err.Error()) - } + if columns == nil { + columns = thisColumns + } else { + if len(columns) != len(thisColumns) { + return nil, fmt.Errorf( + "assertion failed: call 1 of object.GetColumnsAndValues() gave %d columns but call %d gave %d columns", + len(columns), + i+1, + len(thisColumns), + ) + } + } - extraWhere := "" - if len(wheres) > 0 { - extraWhere = fmt.Sprintf("AND %s", extraWhere) + values = append(values, thisValues...) } - ms, _, _, _, _, err := SelectDetections( + ctx, cleanup := query.WithQueryID(ctx) + defer cleanup() + + ctx = query.WithMaxDepth(ctx, nil) + + items, err := query.BulkInsert( ctx, tx, - fmt.Sprintf( - "(claimed_until IS null OR claimed_until < now())%s", - extraWhere, - ), - helpers.Ptr( - "claimed_until ASC", - ), - helpers.Ptr(1), + DetectionTableWithSchema, + columns, nil, + false, + false, + DetectionTableColumns, + values..., ) if err != nil { - return nil, fmt.Errorf("failed to claim: %s", err.Error()) + return nil, fmt.Errorf("failed to bulk insert %d objects; %v", len(objects), err) } - if len(ms) == 0 { - return nil, nil - } + returnedObjects := make([]*Detection, 0) - m = ms[0] + for _, item := range items { + v := &Detection{} + err = v.FromItem(*item) + if err != nil { + return nil, fmt.Errorf("failed %T.FromItem for %#+v; %v", *item, *item, err) + } - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ + err = v.Reload(query.WithSkip(ctx, v), tx) + if err != nil { + return nil, fmt.Errorf("failed %T.Reload for %#+v; %v", *item, *item, err) + } - err = m.Update(ctx, tx, false) - if err != nil { - return nil, fmt.Errorf("failed to claim: %s", err.Error()) + returnedObjects = append(returnedObjects, v) } - return m, nil + return returnedObjects, nil } func handleGetDetections(arguments *server.SelectManyArguments, db *pgxpool.Pool) ([]*Detection, int64, int64, int64, int64, error) { @@ -1172,7 +1198,7 @@ func handleGetDetection(arguments *server.SelectOneArguments, db *pgxpool.Pool, return []*Detection{object}, count, totalCount, page, totalPages, nil } -func handlePostDetections(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Detection, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Detection, int64, int64, int64, int64, error) { +func handlePostDetection(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Detection, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Detection, int64, int64, int64, int64, error) { tx, err := db.Begin(arguments.Ctx) if err != nil { err = fmt.Errorf("failed to begin DB transaction; %v", err) @@ -1188,18 +1214,23 @@ func handlePostDetections(arguments *server.LoadArguments, db *pgxpool.Pool, wai err = fmt.Errorf("failed to get xid; %v", err) return nil, 0, 0, 0, 0, err } - _ = xid - for i, object := range objects { - err = object.Insert(arguments.Ctx, tx, false, false, forceSetValuesForFieldsByObjectIndex[i]...) - if err != nil { - err = fmt.Errorf("failed to insert %#+v; %v", object, err) - return nil, 0, 0, 0, 0, err + /* TODO: problematic- basically the bulks insert insists all rows have the same schema, which they usually should */ + forceSetValuesForFieldsByObjectIndexMaximal := make(map[string]struct{}) + for _, forceSetforceSetValuesForFields := range forceSetValuesForFieldsByObjectIndex { + for _, field := range forceSetforceSetValuesForFields { + forceSetValuesForFieldsByObjectIndexMaximal[field] = struct{}{} } + } - objects[i] = object + returnedObjects, err := InsertDetections(arguments.Ctx, tx, objects, false, false, slices.Collect(maps.Keys(forceSetValuesForFieldsByObjectIndexMaximal))...) + if err != nil { + err = fmt.Errorf("failed to insert %d objects; %v", len(objects), err) + return nil, 0, 0, 0, 0, err } + copy(objects, returnedObjects) + errs := make(chan error, 1) go func() { _, err := waitForChange(arguments.Ctx, []stream.Action{stream.INSERT}, DetectionTable, xid) @@ -1412,172 +1443,6 @@ func handleDeleteDetection(arguments *server.LoadArguments, db *pgxpool.Pool, wa } func MutateRouterForDetection(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, objectMiddlewares []server.ObjectMiddleware, waitForChange server.WaitForChange) { - if slices.Contains(DetectionTableColumns, "claimed_until") && slices.Contains(DetectionTableColumns, "claimed_by") { - func() { - postHandlerForClaim, err := getHTTPHandler( - http.MethodPost, - "/claim-detection", - http.StatusOK, - func( - ctx context.Context, - pathParams server.EmptyPathParams, - queryParams server.EmptyQueryParams, - req DetectionClaimRequest, - rawReq any, - ) (server.Response[Detection], error) { - tx, err := db.Begin(ctx) - if err != nil { - return server.Response[Detection]{}, err - } - - defer func() { - _ = tx.Rollback(ctx) - }() - - object, err := ClaimDetection(ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return server.Response[Detection]{}, err - } - - count := int64(0) - - totalCount := int64(0) - - limit := int64(0) - - offset := int64(0) - - if object == nil { - return server.Response[Detection]{ - Status: http.StatusOK, - Success: true, - Error: nil, - Objects: []*Detection{}, - Count: count, - TotalCount: totalCount, - Limit: limit, - Offset: offset, - }, nil - } - - err = tx.Commit(ctx) - if err != nil { - return server.Response[Detection]{}, err - } - - return server.Response[Detection]{ - Status: http.StatusOK, - Success: true, - Error: nil, - Objects: []*Detection{object}, - Count: count, - TotalCount: totalCount, - Limit: limit, - Offset: offset, - }, nil - }, - Detection{}, - DetectionIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaim.FullPath, postHandlerForClaim.ServeHTTP) - - postHandlerForClaimOne, err := getHTTPHandler( - http.MethodPost, - "/detections/{primaryKey}/claim", - http.StatusOK, - func( - ctx context.Context, - pathParams DetectionOnePathParams, - queryParams DetectionLoadQueryParams, - req DetectionClaimRequest, - rawReq any, - ) (server.Response[Detection], error) { - before := time.Now() - - redisConn := redisPool.Get() - defer func() { - _ = redisConn.Close() - }() - - arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, DetectionIntrospectedTable, pathParams.PrimaryKey, nil, nil) - if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } - - return server.Response[Detection]{}, err - } - - /* note: deliberately no attempt at a cache hit */ - - var object *Detection - var count int64 - var totalCount int64 - - err = func() error { - tx, err := db.Begin(arguments.Ctx) - if err != nil { - return err - } - - defer func() { - _ = tx.Rollback(arguments.Ctx) - }() - - object, count, totalCount, _, _, err = SelectDetection(arguments.Ctx, tx, arguments.Where, arguments.Values...) - if err != nil { - return fmt.Errorf("failed to select object to claim: %s", err.Error()) - } - - err = object.Claim(arguments.Ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return err - } - - err = tx.Commit(arguments.Ctx) - if err != nil { - return err - } - - return nil - }() - if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } - - return server.Response[Detection]{}, err - } - - limit := int64(0) - - offset := int64(0) - - response := server.Response[Detection]{ - Status: http.StatusOK, - Success: true, - Error: nil, - Objects: []*Detection{object}, - Count: count, - TotalCount: totalCount, - Limit: limit, - Offset: offset, - } - - return response, nil - }, - Detection{}, - DetectionIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaimOne.FullPath, postHandlerForClaimOne.ServeHTTP) - }() - } func() { getManyHandler, err := getHTTPHandler( @@ -1837,7 +1702,7 @@ func MutateRouterForDetection(r chi.Router, db *pgxpool.Pool, redisPool *redis.P forceSetValuesForFieldsByObjectIndex := make([][]string, 0) for _, item := range allItems { forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(DetectionTableColumns, possibleField) { continue } @@ -1852,7 +1717,7 @@ func MutateRouterForDetection(r chi.Router, db *pgxpool.Pool, redisPool *redis.P return server.Response[Detection]{}, err } - objects, count, totalCount, _, _, err := handlePostDetections(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) + objects, count, totalCount, _, _, err := handlePostDetection(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) if err != nil { return server.Response[Detection]{}, err } @@ -1953,7 +1818,7 @@ func MutateRouterForDetection(r chi.Router, db *pgxpool.Pool, redisPool *redis.P } forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(DetectionTableColumns, possibleField) { continue } diff --git a/pkg/api/video.go b/pkg/api/video.go index 75397db..5e92285 100755 --- a/pkg/api/video.go +++ b/pkg/api/video.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "maps" "math" "net/http" "net/netip" @@ -27,7 +28,6 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgxpool" - "golang.org/x/exp/maps" ) type Video struct { @@ -52,6 +52,8 @@ type Video struct { var VideoTable = "video" +var VideoTableWithSchema = fmt.Sprintf("%s.%s", schema, VideoTable) + var VideoTableNamespaceID int32 = 1337 + 4 var ( @@ -153,9 +155,13 @@ type VideoLoadQueryParams struct { Depth *int `json:"depth"` } -type VideoClaimRequest struct { +type VideoObjectDetectorClaimRequest struct { + Until time.Time `json:"until"` + TimeoutSeconds float64 `json:"timeout_seconds"` +} + +type VideoObjectTrackerClaimRequest struct { Until time.Time `json:"until"` - By uuid.UUID `json:"by"` TimeoutSeconds float64 `json:"timeout_seconds"` } @@ -501,6 +507,22 @@ func (m *Video) FromItem(item map[string]any) error { return nil } +func (m *Video) ToItem() map[string]any { + item := make(map[string]any) + + b, err := json.Marshal(m) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate marshal to JSON: %s", m, err)) + } + + err = json.Unmarshal(b, &item) + if err != nil { + panic(fmt.Sprintf("%T.ToItem() failed intermediate unmarshal from JSON: %s", m, err)) + } + + return item +} + func (m *Video) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bool) error { extraWhere := "" if len(includeDeleteds) > 0 && includeDeleteds[0] { @@ -545,7 +567,7 @@ func (m *Video) Reload(ctx context.Context, tx pgx.Tx, includeDeleteds ...bool) return nil } -func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { +func (m *Video) GetColumnsAndValues(setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]string, []any, error) { columns := make([]string, 0) values := make([]any, 0) @@ -554,7 +576,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatUUID(m.ID) if err != nil { - return fmt.Errorf("failed to handle m.ID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ID; %v", err) } values = append(values, v) @@ -565,7 +587,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.CreatedAt) if err != nil { - return fmt.Errorf("failed to handle m.CreatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.CreatedAt; %v", err) } values = append(values, v) @@ -576,7 +598,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.UpdatedAt) if err != nil { - return fmt.Errorf("failed to handle m.UpdatedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.UpdatedAt; %v", err) } values = append(values, v) @@ -587,7 +609,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.DeletedAt) if err != nil { - return fmt.Errorf("failed to handle m.DeletedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.DeletedAt; %v", err) } values = append(values, v) @@ -598,7 +620,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatString(m.FileName) if err != nil { - return fmt.Errorf("failed to handle m.FileName; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.FileName; %v", err) } values = append(values, v) @@ -609,7 +631,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.StartedAt) if err != nil { - return fmt.Errorf("failed to handle m.StartedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.StartedAt; %v", err) } values = append(values, v) @@ -620,7 +642,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.EndedAt) if err != nil { - return fmt.Errorf("failed to handle m.EndedAt; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.EndedAt; %v", err) } values = append(values, v) @@ -631,7 +653,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatDuration(m.Duration) if err != nil { - return fmt.Errorf("failed to handle m.Duration; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.Duration; %v", err) } values = append(values, v) @@ -642,7 +664,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatFloat(m.FileSize) if err != nil { - return fmt.Errorf("failed to handle m.FileSize; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.FileSize; %v", err) } values = append(values, v) @@ -653,7 +675,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatString(m.ThumbnailName) if err != nil { - return fmt.Errorf("failed to handle m.ThumbnailName; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ThumbnailName; %v", err) } values = append(values, v) @@ -664,7 +686,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatString(m.Status) if err != nil { - return fmt.Errorf("failed to handle m.Status; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.Status; %v", err) } values = append(values, v) @@ -675,7 +697,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.ObjectDetectorClaimedUntil) if err != nil { - return fmt.Errorf("failed to handle m.ObjectDetectorClaimedUntil; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ObjectDetectorClaimedUntil; %v", err) } values = append(values, v) @@ -686,7 +708,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatTime(m.ObjectTrackerClaimedUntil) if err != nil { - return fmt.Errorf("failed to handle m.ObjectTrackerClaimedUntil; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.ObjectTrackerClaimedUntil; %v", err) } values = append(values, v) @@ -697,7 +719,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatUUID(m.CameraID) if err != nil { - return fmt.Errorf("failed to handle m.CameraID; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.CameraID; %v", err) } values = append(values, v) @@ -708,12 +730,21 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe v, err := types.FormatJSON(m.DetectionSummary) if err != nil { - return fmt.Errorf("failed to handle m.DetectionSummary; %v", err) + return nil, nil, fmt.Errorf("failed to handle m.DetectionSummary; %v", err) } values = append(values, v) } + return columns, values, nil +} + +func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) error { + columns, values, err := m.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return fmt.Errorf("failed to get columns and values to insert %#+v; %v", m, err) + } + ctx, cleanup := query.WithQueryID(ctx) defer cleanup() @@ -722,7 +753,7 @@ func (m *Video) Insert(ctx context.Context, tx pgx.Tx, setPrimaryKey bool, setZe item, err := query.Insert( ctx, tx, - VideoTable, + VideoTableWithSchema, columns, nil, false, @@ -941,7 +972,7 @@ func (m *Video) Update(ctx context.Context, tx pgx.Tx, setZeroValues bool, force _, err = query.Update( ctx, tx, - VideoTable, + VideoTableWithSchema, columns, fmt.Sprintf("%v = $$??", VideoTableIDColumn), VideoTableColumns, @@ -989,7 +1020,7 @@ func (m *Video) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) erro err = query.Delete( ctx, tx, - VideoTable, + VideoTableWithSchema, fmt.Sprintf("%v = $$??", VideoTableIDColumn), values..., ) @@ -1003,11 +1034,11 @@ func (m *Video) Delete(ctx context.Context, tx pgx.Tx, hardDeletes ...bool) erro } func (m *Video) LockTable(ctx context.Context, tx pgx.Tx, timeouts ...time.Duration) error { - return query.LockTable(ctx, tx, VideoTable, timeouts...) + return query.LockTable(ctx, tx, VideoTableWithSchema, timeouts...) } func (m *Video) LockTableWithRetries(ctx context.Context, tx pgx.Tx, overallTimeout time.Duration, individualAttempttimeout time.Duration) error { - return query.LockTableWithRetries(ctx, tx, VideoTable, overallTimeout, individualAttempttimeout) + return query.LockTableWithRetries(ctx, tx, VideoTableWithSchema, overallTimeout, individualAttempttimeout) } func (m *Video) AdvisoryLock(ctx context.Context, tx pgx.Tx, key int32, timeouts ...time.Duration) error { @@ -1018,34 +1049,55 @@ func (m *Video) AdvisoryLockWithRetries(ctx context.Context, tx pgx.Tx, key int3 return query.AdvisoryLockWithRetries(ctx, tx, VideoTableNamespaceID, key, overallTimeout, individualAttempttimeout) } -func (m *Video) Claim(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration) error { - if !(slices.Contains(VideoTableColumns, "claimed_until") && slices.Contains(VideoTableColumns, "claimed_by")) { - return fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") +func (m *Video) ObjectDetectorClaim(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration) error { + err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) + if err != nil { + return fmt.Errorf("failed to claim (advisory lock): %s", err.Error()) + } + + _, _, _, _, _, err = SelectVideo( + ctx, + tx, + fmt.Sprintf( + "%s = $$?? AND (object_detector_claimed_until IS null OR object_detector_claimed_until < now())", + VideoTablePrimaryKeyColumn, + ), + m.GetPrimaryKeyValue(), + ) + if err != nil { + return fmt.Errorf("failed to claim (select): %s", err.Error()) + } + + m.ObjectDetectorClaimedUntil = until + + err = m.Update(ctx, tx, false) + if err != nil { + return fmt.Errorf("failed to claim (update): %s", err.Error()) } + return nil +} + +func (m *Video) ObjectTrackerClaim(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration) error { err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) if err != nil { return fmt.Errorf("failed to claim (advisory lock): %s", err.Error()) } - x, _, _, _, _, err := SelectVideo( + _, _, _, _, _, err = SelectVideo( ctx, tx, fmt.Sprintf( - "%s = $$?? AND (claimed_by = $$?? OR (claimed_until IS null OR claimed_until < now()))", + "%s = $$?? AND (object_tracker_claimed_until IS null OR object_tracker_claimed_until < now())", VideoTablePrimaryKeyColumn, ), m.GetPrimaryKeyValue(), - by, ) if err != nil { return fmt.Errorf("failed to claim (select): %s", err.Error()) } - _ = x - - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ + m.ObjectTrackerClaimedUntil = until err = m.Update(ctx, tx, false) if err != nil { @@ -1092,29 +1144,57 @@ func SelectVideos(ctx context.Context, tx pgx.Tx, where string, orderBy *string, return []*Video{}, 0, 0, 0, 0, nil } - items, count, totalCount, page, totalPages, err := query.Select( - ctx, - tx, - VideoTableColumnsWithTypeCasts, - VideoTable, - where, - orderBy, - limit, - offset, - values..., - ) - if err != nil { - return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectVideos; %v", err) + var items *[]map[string]any + var count int64 + var totalCount int64 + var page int64 + var totalPages int64 + var err error + + useInstead, shouldSkip := query.ShouldSkip[Video](ctx) + if !shouldSkip { + items, count, totalCount, page, totalPages, err = query.Select( + ctx, + tx, + VideoTableColumnsWithTypeCasts, + VideoTableWithSchema, + where, + orderBy, + limit, + offset, + values..., + ) + if err != nil { + return nil, 0, 0, 0, 0, fmt.Errorf("failed to call SelectVideos; %v", err) + } + } else { + ctx = query.WithoutSkip(ctx) + count = 1 + totalCount = 1 + page = 1 + totalPages = 1 + items = &[]map[string]any{ + nil, + } } objects := make([]*Video, 0) for _, item := range *items { - object := &Video{} + var object *Video - err = object.FromItem(item) - if err != nil { - return nil, 0, 0, 0, 0, err + if !shouldSkip { + object = &Video{} + err = object.FromItem(item) + if err != nil { + return nil, 0, 0, 0, 0, err + } + } else { + object = useInstead + } + + if object == nil { + return nil, 0, 0, 0, 0, fmt.Errorf("assertion failed: object unexpectedly nil") } if !types.IsZeroUUID(object.CameraID) { @@ -1225,11 +1305,73 @@ func SelectVideo(ctx context.Context, tx pgx.Tx, where string, values ...any) (* return object, count, totalCount, page, totalPages, nil } -func ClaimVideo(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, timeout time.Duration, wheres ...string) (*Video, error) { - if !(slices.Contains(VideoTableColumns, "claimed_until") && slices.Contains(VideoTableColumns, "claimed_by")) { - return nil, fmt.Errorf("can only invoke Claim for tables with 'claimed_until' and 'claimed_by' columns") +func InsertVideos(ctx context.Context, tx pgx.Tx, objects []*Video, setPrimaryKey bool, setZeroValues bool, forceSetValuesForFields ...string) ([]*Video, error) { + var columns []string + values := make([]any, 0) + + for i, object := range objects { + thisColumns, thisValues, err := object.GetColumnsAndValues(setPrimaryKey, setZeroValues, forceSetValuesForFields...) + if err != nil { + return nil, err + } + + if columns == nil { + columns = thisColumns + } else { + if len(columns) != len(thisColumns) { + return nil, fmt.Errorf( + "assertion failed: call 1 of object.GetColumnsAndValues() gave %d columns but call %d gave %d columns", + len(columns), + i+1, + len(thisColumns), + ) + } + } + + values = append(values, thisValues...) + } + + ctx, cleanup := query.WithQueryID(ctx) + defer cleanup() + + ctx = query.WithMaxDepth(ctx, nil) + + items, err := query.BulkInsert( + ctx, + tx, + VideoTableWithSchema, + columns, + nil, + false, + false, + VideoTableColumns, + values..., + ) + if err != nil { + return nil, fmt.Errorf("failed to bulk insert %d objects; %v", len(objects), err) } + returnedObjects := make([]*Video, 0) + + for _, item := range items { + v := &Video{} + err = v.FromItem(*item) + if err != nil { + return nil, fmt.Errorf("failed %T.FromItem for %#+v; %v", *item, *item, err) + } + + err = v.Reload(query.WithSkip(ctx, v), tx) + if err != nil { + return nil, fmt.Errorf("failed %T.Reload for %#+v; %v", *item, *item, err) + } + + returnedObjects = append(returnedObjects, v) + } + + return returnedObjects, nil +} + +func ObjectDetectorClaimVideo(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration, where string, values ...any) (*Video, error) { m := &Video{} err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) @@ -1237,23 +1379,67 @@ func ClaimVideo(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, t return nil, fmt.Errorf("failed to claim: %s", err.Error()) } - extraWhere := "" - if len(wheres) > 0 { - extraWhere = fmt.Sprintf("AND %s", extraWhere) + if strings.TrimSpace(where) != "" { + where += " AND\n" } + where += " (object_detector_claimed_until IS null OR object_detector_claimed_until < now())" + ms, _, _, _, _, err := SelectVideos( ctx, tx, - fmt.Sprintf( - "(claimed_until IS null OR claimed_until < now())%s", - extraWhere, + where, + helpers.Ptr( + "object_detector_claimed_until ASC", ), + helpers.Ptr(1), + nil, + values..., + ) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + if len(ms) == 0 { + return nil, nil + } + + m = ms[0] + + m.ObjectDetectorClaimedUntil = until + + err = m.Update(ctx, tx, false) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + return m, nil +} + +func ObjectTrackerClaimVideo(ctx context.Context, tx pgx.Tx, until time.Time, timeout time.Duration, where string, values ...any) (*Video, error) { + m := &Video{} + + err := m.AdvisoryLockWithRetries(ctx, tx, math.MinInt32, timeout, time.Second*1) + if err != nil { + return nil, fmt.Errorf("failed to claim: %s", err.Error()) + } + + if strings.TrimSpace(where) != "" { + where += " AND\n" + } + + where += " (object_tracker_claimed_until IS null OR object_tracker_claimed_until < now())" + + ms, _, _, _, _, err := SelectVideos( + ctx, + tx, + where, helpers.Ptr( - "claimed_until ASC", + "object_tracker_claimed_until ASC", ), helpers.Ptr(1), nil, + values..., ) if err != nil { return nil, fmt.Errorf("failed to claim: %s", err.Error()) @@ -1265,8 +1451,7 @@ func ClaimVideo(ctx context.Context, tx pgx.Tx, until time.Time, by uuid.UUID, t m = ms[0] - /* m.ClaimedUntil = &until */ - /* m.ClaimedBy = &by */ + m.ObjectTrackerClaimedUntil = until err = m.Update(ctx, tx, false) if err != nil { @@ -1322,7 +1507,7 @@ func handleGetVideo(arguments *server.SelectOneArguments, db *pgxpool.Pool, prim return []*Video{object}, count, totalCount, page, totalPages, nil } -func handlePostVideos(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Video, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Video, int64, int64, int64, int64, error) { +func handlePostVideo(arguments *server.LoadArguments, db *pgxpool.Pool, waitForChange server.WaitForChange, objects []*Video, forceSetValuesForFieldsByObjectIndex [][]string) ([]*Video, int64, int64, int64, int64, error) { tx, err := db.Begin(arguments.Ctx) if err != nil { err = fmt.Errorf("failed to begin DB transaction; %v", err) @@ -1338,18 +1523,23 @@ func handlePostVideos(arguments *server.LoadArguments, db *pgxpool.Pool, waitFor err = fmt.Errorf("failed to get xid; %v", err) return nil, 0, 0, 0, 0, err } - _ = xid - for i, object := range objects { - err = object.Insert(arguments.Ctx, tx, false, false, forceSetValuesForFieldsByObjectIndex[i]...) - if err != nil { - err = fmt.Errorf("failed to insert %#+v; %v", object, err) - return nil, 0, 0, 0, 0, err + /* TODO: problematic- basically the bulks insert insists all rows have the same schema, which they usually should */ + forceSetValuesForFieldsByObjectIndexMaximal := make(map[string]struct{}) + for _, forceSetforceSetValuesForFields := range forceSetValuesForFieldsByObjectIndex { + for _, field := range forceSetforceSetValuesForFields { + forceSetValuesForFieldsByObjectIndexMaximal[field] = struct{}{} } + } - objects[i] = object + returnedObjects, err := InsertVideos(arguments.Ctx, tx, objects, false, false, slices.Collect(maps.Keys(forceSetValuesForFieldsByObjectIndexMaximal))...) + if err != nil { + err = fmt.Errorf("failed to insert %d objects; %v", len(objects), err) + return nil, 0, 0, 0, 0, err } + copy(objects, returnedObjects) + errs := make(chan error, 1) go func() { _, err := waitForChange(arguments.Ctx, []stream.Action{stream.INSERT}, VideoTable, xid) @@ -1562,172 +1752,336 @@ func handleDeleteVideo(arguments *server.LoadArguments, db *pgxpool.Pool, waitFo } func MutateRouterForVideo(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, objectMiddlewares []server.ObjectMiddleware, waitForChange server.WaitForChange) { - if slices.Contains(VideoTableColumns, "claimed_until") && slices.Contains(VideoTableColumns, "claimed_by") { - func() { - postHandlerForClaim, err := getHTTPHandler( - http.MethodPost, - "/claim-video", - http.StatusOK, - func( - ctx context.Context, - pathParams server.EmptyPathParams, - queryParams server.EmptyQueryParams, - req VideoClaimRequest, - rawReq any, - ) (server.Response[Video], error) { - tx, err := db.Begin(ctx) - if err != nil { - return server.Response[Video]{}, err - } - - defer func() { - _ = tx.Rollback(ctx) - }() - object, err := ClaimVideo(ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return server.Response[Video]{}, err - } + func() { + postHandlerForObjectDetectorClaim, err := getHTTPHandler( + http.MethodPost, + "/object-detector-claim-video", + http.StatusOK, + func( + ctx context.Context, + pathParams server.EmptyPathParams, + queryParams server.EmptyQueryParams, + req VideoObjectDetectorClaimRequest, + rawReq any, + ) (server.Response[Video], error) { + tx, err := db.Begin(ctx) + if err != nil { + return server.Response[Video]{}, err + } - count := int64(0) + defer func() { + _ = tx.Rollback(ctx) + }() - totalCount := int64(0) + object, err := ObjectDetectorClaimVideo(ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000), "") + if err != nil { + return server.Response[Video]{}, err + } - limit := int64(0) + count := int64(0) - offset := int64(0) + totalCount := int64(0) - if object == nil { - return server.Response[Video]{ - Status: http.StatusOK, - Success: true, - Error: nil, - Objects: []*Video{}, - Count: count, - TotalCount: totalCount, - Limit: limit, - Offset: offset, - }, nil - } + limit := int64(0) - err = tx.Commit(ctx) - if err != nil { - return server.Response[Video]{}, err - } + offset := int64(0) + if object == nil { return server.Response[Video]{ Status: http.StatusOK, Success: true, Error: nil, - Objects: []*Video{object}, + Objects: []*Video{}, Count: count, TotalCount: totalCount, Limit: limit, Offset: offset, }, nil - }, - Video{}, - VideoIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaim.FullPath, postHandlerForClaim.ServeHTTP) - - postHandlerForClaimOne, err := getHTTPHandler( - http.MethodPost, - "/videos/{primaryKey}/claim", - http.StatusOK, - func( - ctx context.Context, - pathParams VideoOnePathParams, - queryParams VideoLoadQueryParams, - req VideoClaimRequest, - rawReq any, - ) (server.Response[Video], error) { - before := time.Now() - - redisConn := redisPool.Get() + } + + err = tx.Commit(ctx) + if err != nil { + return server.Response[Video]{}, err + } + + return server.Response[Video]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Video{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + }, nil + }, + Video{}, + VideoIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForObjectDetectorClaim.FullPath, postHandlerForObjectDetectorClaim.ServeHTTP) + + postHandlerForObjectDetectorClaimOne, err := getHTTPHandler( + http.MethodPost, + "/videos/{primaryKey}/object-detector-claim", + http.StatusOK, + func( + ctx context.Context, + pathParams VideoOnePathParams, + queryParams VideoLoadQueryParams, + req VideoObjectDetectorClaimRequest, + rawReq any, + ) (server.Response[Video], error) { + before := time.Now() + + redisConn := redisPool.Get() + defer func() { + _ = redisConn.Close() + }() + + arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, VideoIntrospectedTable, pathParams.PrimaryKey, nil, nil) + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) + } + + return server.Response[Video]{}, err + } + + /* note: deliberately no attempt at a cache hit */ + + var object *Video + var count int64 + var totalCount int64 + + err = func() error { + tx, err := db.Begin(arguments.Ctx) + if err != nil { + return err + } + defer func() { - _ = redisConn.Close() + _ = tx.Rollback(arguments.Ctx) }() - arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, VideoIntrospectedTable, pathParams.PrimaryKey, nil, nil) + object, count, totalCount, _, _, err = SelectVideo(arguments.Ctx, tx, arguments.Where, arguments.Values...) if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } + return fmt.Errorf("failed to select object to claim: %s", err.Error()) + } - return server.Response[Video]{}, err + err = object.ObjectDetectorClaim(arguments.Ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) + if err != nil { + return err + } + + err = tx.Commit(arguments.Ctx) + if err != nil { + return err } - /* note: deliberately no attempt at a cache hit */ + return nil + }() + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) + } - var object *Video - var count int64 - var totalCount int64 + return server.Response[Video]{}, err + } - err = func() error { - tx, err := db.Begin(arguments.Ctx) - if err != nil { - return err - } + limit := int64(0) - defer func() { - _ = tx.Rollback(arguments.Ctx) - }() + offset := int64(0) - object, count, totalCount, _, _, err = SelectVideo(arguments.Ctx, tx, arguments.Where, arguments.Values...) - if err != nil { - return fmt.Errorf("failed to select object to claim: %s", err.Error()) - } + response := server.Response[Video]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Video{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + } - err = object.Claim(arguments.Ctx, tx, req.Until, req.By, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) - if err != nil { - return err - } + return response, nil + }, + Video{}, + VideoIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForObjectDetectorClaimOne.FullPath, postHandlerForObjectDetectorClaimOne.ServeHTTP) + }() - err = tx.Commit(arguments.Ctx) - if err != nil { - return err - } + func() { + postHandlerForObjectTrackerClaim, err := getHTTPHandler( + http.MethodPost, + "/object-tracker-claim-video", + http.StatusOK, + func( + ctx context.Context, + pathParams server.EmptyPathParams, + queryParams server.EmptyQueryParams, + req VideoObjectTrackerClaimRequest, + rawReq any, + ) (server.Response[Video], error) { + tx, err := db.Begin(ctx) + if err != nil { + return server.Response[Video]{}, err + } - return nil - }() - if err != nil { - if config.Debug() { - log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) - } + defer func() { + _ = tx.Rollback(ctx) + }() - return server.Response[Video]{}, err - } + object, err := ObjectTrackerClaimVideo(ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000), "") + if err != nil { + return server.Response[Video]{}, err + } - limit := int64(0) + count := int64(0) - offset := int64(0) + totalCount := int64(0) - response := server.Response[Video]{ + limit := int64(0) + + offset := int64(0) + + if object == nil { + return server.Response[Video]{ Status: http.StatusOK, Success: true, Error: nil, - Objects: []*Video{object}, + Objects: []*Video{}, Count: count, TotalCount: totalCount, Limit: limit, Offset: offset, + }, nil + } + + err = tx.Commit(ctx) + if err != nil { + return server.Response[Video]{}, err + } + + return server.Response[Video]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Video{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + }, nil + }, + Video{}, + VideoIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForObjectTrackerClaim.FullPath, postHandlerForObjectTrackerClaim.ServeHTTP) + + postHandlerForObjectTrackerClaimOne, err := getHTTPHandler( + http.MethodPost, + "/videos/{primaryKey}/object-tracker-claim", + http.StatusOK, + func( + ctx context.Context, + pathParams VideoOnePathParams, + queryParams VideoLoadQueryParams, + req VideoObjectTrackerClaimRequest, + rawReq any, + ) (server.Response[Video], error) { + before := time.Now() + + redisConn := redisPool.Get() + defer func() { + _ = redisConn.Close() + }() + + arguments, err := server.GetSelectOneArguments(ctx, queryParams.Depth, VideoIntrospectedTable, pathParams.PrimaryKey, nil, nil) + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) } - return response, nil - }, - Video{}, - VideoIntrospectedTable, - ) - if err != nil { - panic(err) - } - r.Post(postHandlerForClaimOne.FullPath, postHandlerForClaimOne.ServeHTTP) - }() - } + return server.Response[Video]{}, err + } + + /* note: deliberately no attempt at a cache hit */ + + var object *Video + var count int64 + var totalCount int64 + + err = func() error { + tx, err := db.Begin(arguments.Ctx) + if err != nil { + return err + } + + defer func() { + _ = tx.Rollback(arguments.Ctx) + }() + + object, count, totalCount, _, _, err = SelectVideo(arguments.Ctx, tx, arguments.Where, arguments.Values...) + if err != nil { + return fmt.Errorf("failed to select object to claim: %s", err.Error()) + } + + err = object.ObjectTrackerClaim(arguments.Ctx, tx, req.Until, time.Millisecond*time.Duration(req.TimeoutSeconds*1000)) + if err != nil { + return err + } + + err = tx.Commit(arguments.Ctx) + if err != nil { + return err + } + + return nil + }() + if err != nil { + if config.Debug() { + log.Printf("request failed in %s %s path: %#+v query: %#+v req: %#+v", time.Since(before), http.MethodGet, pathParams, queryParams, req) + } + + return server.Response[Video]{}, err + } + + limit := int64(0) + + offset := int64(0) + + response := server.Response[Video]{ + Status: http.StatusOK, + Success: true, + Error: nil, + Objects: []*Video{object}, + Count: count, + TotalCount: totalCount, + Limit: limit, + Offset: offset, + } + + return response, nil + }, + Video{}, + VideoIntrospectedTable, + ) + if err != nil { + panic(err) + } + r.Post(postHandlerForObjectTrackerClaimOne.FullPath, postHandlerForObjectTrackerClaimOne.ServeHTTP) + }() func() { getManyHandler, err := getHTTPHandler( @@ -1987,7 +2341,7 @@ func MutateRouterForVideo(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, forceSetValuesForFieldsByObjectIndex := make([][]string, 0) for _, item := range allItems { forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(VideoTableColumns, possibleField) { continue } @@ -2002,7 +2356,7 @@ func MutateRouterForVideo(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, return server.Response[Video]{}, err } - objects, count, totalCount, _, _, err := handlePostVideos(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) + objects, count, totalCount, _, _, err := handlePostVideo(arguments, db, waitForChange, req, forceSetValuesForFieldsByObjectIndex) if err != nil { return server.Response[Video]{}, err } @@ -2103,7 +2457,7 @@ func MutateRouterForVideo(r chi.Router, db *pgxpool.Pool, redisPool *redis.Pool, } forceSetValuesForFields := make([]string, 0) - for _, possibleField := range maps.Keys(item) { + for _, possibleField := range slices.Collect(maps.Keys(item)) { if !slices.Contains(VideoTableColumns, possibleField) { continue } diff --git a/pkg/api_client/README.md b/pkg/api_client/README.md index 6bc2e0d..18bdf4b 100644 --- a/pkg/api_client/README.md +++ b/pkg/api_client/README.md @@ -83,24 +83,32 @@ Class | Method | HTTP request | Description *CameraAPI* | [**GetCameras**](docs/CameraAPI.md#getcameras) | **Get** /api/cameras | *CameraAPI* | [**PatchCamera**](docs/CameraAPI.md#patchcamera) | **Patch** /api/cameras/{primaryKey} | *CameraAPI* | [**PostCameras**](docs/CameraAPI.md#postcameras) | **Post** /api/cameras | -*CustomAPI* | [**PatchCustomClaimVideoForObjectDetector**](docs/CustomAPI.md#patchcustomclaimvideoforobjectdetector) | **Patch** /api/custom/claim-video-for-object-detector | +*CameraAPI* | [**PostCamerasSegmentProducerClaim**](docs/CameraAPI.md#postcamerassegmentproducerclaim) | **Post** /api/cameras/{primaryKey}/segment-producer-claim | +*CameraAPI* | [**PostCamerasStreamProducerClaim**](docs/CameraAPI.md#postcamerasstreamproducerclaim) | **Post** /api/cameras/{primaryKey}/stream-producer-claim | *DetectionAPI* | [**DeleteDetection**](docs/DetectionAPI.md#deletedetection) | **Delete** /api/detections/{primaryKey} | *DetectionAPI* | [**GetDetection**](docs/DetectionAPI.md#getdetection) | **Get** /api/detections/{primaryKey} | *DetectionAPI* | [**GetDetections**](docs/DetectionAPI.md#getdetections) | **Get** /api/detections | *DetectionAPI* | [**PatchDetection**](docs/DetectionAPI.md#patchdetection) | **Patch** /api/detections/{primaryKey} | *DetectionAPI* | [**PostDetections**](docs/DetectionAPI.md#postdetections) | **Post** /api/detections | +*ObjectDetectorClaimVideoAPI* | [**PostObjectDetectorClaimVideos**](docs/ObjectDetectorClaimVideoAPI.md#postobjectdetectorclaimvideos) | **Post** /api/object-detector-claim-video | +*ObjectTrackerClaimVideoAPI* | [**PostObjectTrackerClaimVideos**](docs/ObjectTrackerClaimVideoAPI.md#postobjecttrackerclaimvideos) | **Post** /api/object-tracker-claim-video | +*SegmentProducerClaimCameraAPI* | [**PostSegmentProducerClaimCameras**](docs/SegmentProducerClaimCameraAPI.md#postsegmentproducerclaimcameras) | **Post** /api/segment-producer-claim-camera | +*StreamProducerClaimCameraAPI* | [**PostStreamProducerClaimCameras**](docs/StreamProducerClaimCameraAPI.md#poststreamproducerclaimcameras) | **Post** /api/stream-producer-claim-camera | *VideoAPI* | [**DeleteVideo**](docs/VideoAPI.md#deletevideo) | **Delete** /api/videos/{primaryKey} | *VideoAPI* | [**GetVideo**](docs/VideoAPI.md#getvideo) | **Get** /api/videos/{primaryKey} | *VideoAPI* | [**GetVideos**](docs/VideoAPI.md#getvideos) | **Get** /api/videos | *VideoAPI* | [**PatchVideo**](docs/VideoAPI.md#patchvideo) | **Patch** /api/videos/{primaryKey} | *VideoAPI* | [**PostVideos**](docs/VideoAPI.md#postvideos) | **Post** /api/videos | +*VideoAPI* | [**PostVideosObjectDetectorClaim**](docs/VideoAPI.md#postvideosobjectdetectorclaim) | **Post** /api/videos/{primaryKey}/object-detector-claim | +*VideoAPI* | [**PostVideosObjectTrackerClaim**](docs/VideoAPI.md#postvideosobjecttrackerclaim) | **Post** /api/videos/{primaryKey}/object-tracker-claim | ## Documentation For Models - [ArrayOfVec2Inner](docs/ArrayOfVec2Inner.md) - [Camera](docs/Camera.md) - - [ClaimRequest](docs/ClaimRequest.md) + - [CameraSegmentProducerClaimRequest](docs/CameraSegmentProducerClaimRequest.md) + - [CameraStreamProducerClaimRequest](docs/CameraStreamProducerClaimRequest.md) - [Detection](docs/Detection.md) - [GetCamerasDefaultResponse](docs/GetCamerasDefaultResponse.md) - [ResponseWithGenericOfCamera](docs/ResponseWithGenericOfCamera.md) @@ -108,6 +116,8 @@ Class | Method | HTTP request | Description - [ResponseWithGenericOfVideo](docs/ResponseWithGenericOfVideo.md) - [Vec2](docs/Vec2.md) - [Video](docs/Video.md) + - [VideoObjectDetectorClaimRequest](docs/VideoObjectDetectorClaimRequest.md) + - [VideoObjectTrackerClaimRequest](docs/VideoObjectTrackerClaimRequest.md) ## Documentation For Authorization diff --git a/pkg/api_client/api/openapi.yaml b/pkg/api_client/api/openapi.yaml index 1cb5170..38abb65 100644 --- a/pkg/api_client/api/openapi.yaml +++ b/pkg/api_client/api/openapi.yaml @@ -1579,30 +1579,92 @@ paths: description: PatchCamera failure tags: - Camera - /api/custom/claim-video-for-object-detector: - patch: - operationId: PatchCustomClaimVideoForObjectDetector + /api/cameras/{primaryKey}/segment-producer-claim: + post: + operationId: PostCamerasSegmentProducerClaim + parameters: + - description: Path parameter primaryKey + explode: false + in: path + name: primaryKey + required: true + schema: + format: uuid + type: string + style: simple + - description: Query parameter depth + explode: true + in: query + name: depth + required: false + schema: + format: int64 + type: integer + style: form requestBody: content: application/json: schema: - $ref: '#/components/schemas/ClaimRequest' + $ref: '#/components/schemas/CameraSegmentProducerClaimRequest' required: true responses: "200": content: application/json: schema: - $ref: '#/components/schemas/NullableVideo' - description: PatchCustomClaimVideoForObjectDetector success + $ref: '#/components/schemas/ResponseWithGenericOfCamera' + description: PostCamerasSegmentProducerClaim success default: content: application/json: schema: $ref: '#/components/schemas/GetCameras_default_response' - description: PatchCustomClaimVideoForObjectDetector failure + description: PostCamerasSegmentProducerClaim failure tags: - - Custom + - Camera + /api/cameras/{primaryKey}/stream-producer-claim: + post: + operationId: PostCamerasStreamProducerClaim + parameters: + - description: Path parameter primaryKey + explode: false + in: path + name: primaryKey + required: true + schema: + format: uuid + type: string + style: simple + - description: Query parameter depth + explode: true + in: query + name: depth + required: false + schema: + format: int64 + type: integer + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CameraStreamProducerClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfCamera' + description: PostCamerasStreamProducerClaim success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostCamerasStreamProducerClaim failure + tags: + - Camera /api/detections: get: operationId: GetDetections @@ -3323,6 +3385,102 @@ paths: description: PatchDetection failure tags: - Detection + /api/object-detector-claim-video: + post: + operationId: PostObjectDetectorClaimVideos + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VideoObjectDetectorClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfVideo' + description: PostObjectDetectorClaimVideos success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostObjectDetectorClaimVideos failure + tags: + - ObjectDetectorClaimVideo + /api/object-tracker-claim-video: + post: + operationId: PostObjectTrackerClaimVideos + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VideoObjectTrackerClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfVideo' + description: PostObjectTrackerClaimVideos success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostObjectTrackerClaimVideos failure + tags: + - ObjectTrackerClaimVideo + /api/segment-producer-claim-camera: + post: + operationId: PostSegmentProducerClaimCameras + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CameraSegmentProducerClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfCamera' + description: PostSegmentProducerClaimCameras success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostSegmentProducerClaimCameras failure + tags: + - SegmentProducerClaimCamera + /api/stream-producer-claim-camera: + post: + operationId: PostStreamProducerClaimCameras + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CameraStreamProducerClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfCamera' + description: PostStreamProducerClaimCameras success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostStreamProducerClaimCameras failure + tags: + - StreamProducerClaimCamera /api/videos: get: operationId: GetVideos @@ -5575,6 +5733,92 @@ paths: description: PatchVideo failure tags: - Video + /api/videos/{primaryKey}/object-detector-claim: + post: + operationId: PostVideosObjectDetectorClaim + parameters: + - description: Path parameter primaryKey + explode: false + in: path + name: primaryKey + required: true + schema: + format: uuid + type: string + style: simple + - description: Query parameter depth + explode: true + in: query + name: depth + required: false + schema: + format: int64 + type: integer + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VideoObjectDetectorClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfVideo' + description: PostVideosObjectDetectorClaim success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostVideosObjectDetectorClaim failure + tags: + - Video + /api/videos/{primaryKey}/object-tracker-claim: + post: + operationId: PostVideosObjectTrackerClaim + parameters: + - description: Path parameter primaryKey + explode: false + in: path + name: primaryKey + required: true + schema: + format: uuid + type: string + style: simple + - description: Query parameter depth + explode: true + in: query + name: depth + required: false + schema: + format: int64 + type: integer + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VideoObjectTrackerClaimRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ResponseWithGenericOfVideo' + description: PostVideosObjectTrackerClaim success + default: + content: + application/json: + schema: + $ref: '#/components/schemas/GetCameras_default_response' + description: PostVideosObjectTrackerClaim failure + tags: + - Video components: schemas: Any: {} @@ -5768,13 +6012,28 @@ components: updated_at: format: date-time type: string - ClaimRequest: + CameraSegmentProducerClaimRequest: + example: + until: 2000-01-23T04:56:07.000+00:00 + timeout_seconds: 0.8008281904610115 + properties: + timeout_seconds: + format: double + type: number + until: + format: date-time + type: string + CameraStreamProducerClaimRequest: example: - claim_duration_seconds: 0.8008281904610115 + until: 2000-01-23T04:56:07.000+00:00 + timeout_seconds: 0.8008281904610115 properties: - claim_duration_seconds: + timeout_seconds: format: double type: number + until: + format: date-time + type: string Detection: example: camera_id_object: null @@ -6430,6 +6689,28 @@ components: updated_at: format: date-time type: string + VideoObjectDetectorClaimRequest: + example: + until: 2000-01-23T04:56:07.000+00:00 + timeout_seconds: 0.8008281904610115 + properties: + timeout_seconds: + format: double + type: number + until: + format: date-time + type: string + VideoObjectTrackerClaimRequest: + example: + until: 2000-01-23T04:56:07.000+00:00 + timeout_seconds: 0.8008281904610115 + properties: + timeout_seconds: + format: double + type: number + until: + format: date-time + type: string GetCameras_default_response: example: success: true diff --git a/pkg/api_client/api_camera.go b/pkg/api_client/api_camera.go index 3aed473..74889ed 100644 --- a/pkg/api_client/api_camera.go +++ b/pkg/api_client/api_camera.go @@ -2173,3 +2173,263 @@ func (a *CameraAPIService) PostCamerasExecute(r ApiPostCamerasRequest) (*Respons return localVarReturnValue, localVarHTTPResponse, nil } + +type ApiPostCamerasSegmentProducerClaimRequest struct { + ctx context.Context + ApiService *CameraAPIService + primaryKey string + cameraSegmentProducerClaimRequest *CameraSegmentProducerClaimRequest + depth *int64 +} + +func (r ApiPostCamerasSegmentProducerClaimRequest) CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest CameraSegmentProducerClaimRequest) ApiPostCamerasSegmentProducerClaimRequest { + r.cameraSegmentProducerClaimRequest = &cameraSegmentProducerClaimRequest + return r +} + +// Query parameter depth +func (r ApiPostCamerasSegmentProducerClaimRequest) Depth(depth int64) ApiPostCamerasSegmentProducerClaimRequest { + r.depth = &depth + return r +} + +func (r ApiPostCamerasSegmentProducerClaimRequest) Execute() (*ResponseWithGenericOfCamera, *http.Response, error) { + return r.ApiService.PostCamerasSegmentProducerClaimExecute(r) +} + +/* +PostCamerasSegmentProducerClaim Method for PostCamerasSegmentProducerClaim + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param primaryKey Path parameter primaryKey + @return ApiPostCamerasSegmentProducerClaimRequest +*/ +func (a *CameraAPIService) PostCamerasSegmentProducerClaim(ctx context.Context, primaryKey string) ApiPostCamerasSegmentProducerClaimRequest { + return ApiPostCamerasSegmentProducerClaimRequest{ + ApiService: a, + ctx: ctx, + primaryKey: primaryKey, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfCamera +func (a *CameraAPIService) PostCamerasSegmentProducerClaimExecute(r ApiPostCamerasSegmentProducerClaimRequest) (*ResponseWithGenericOfCamera, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfCamera + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CameraAPIService.PostCamerasSegmentProducerClaim") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/cameras/{primaryKey}/segment-producer-claim" + localVarPath = strings.Replace(localVarPath, "{"+"primaryKey"+"}", url.PathEscape(parameterValueToString(r.primaryKey, "primaryKey")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.cameraSegmentProducerClaimRequest == nil { + return localVarReturnValue, nil, reportError("cameraSegmentProducerClaimRequest is required and must be specified") + } + + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.cameraSegmentProducerClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPostCamerasStreamProducerClaimRequest struct { + ctx context.Context + ApiService *CameraAPIService + primaryKey string + cameraStreamProducerClaimRequest *CameraStreamProducerClaimRequest + depth *int64 +} + +func (r ApiPostCamerasStreamProducerClaimRequest) CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest CameraStreamProducerClaimRequest) ApiPostCamerasStreamProducerClaimRequest { + r.cameraStreamProducerClaimRequest = &cameraStreamProducerClaimRequest + return r +} + +// Query parameter depth +func (r ApiPostCamerasStreamProducerClaimRequest) Depth(depth int64) ApiPostCamerasStreamProducerClaimRequest { + r.depth = &depth + return r +} + +func (r ApiPostCamerasStreamProducerClaimRequest) Execute() (*ResponseWithGenericOfCamera, *http.Response, error) { + return r.ApiService.PostCamerasStreamProducerClaimExecute(r) +} + +/* +PostCamerasStreamProducerClaim Method for PostCamerasStreamProducerClaim + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param primaryKey Path parameter primaryKey + @return ApiPostCamerasStreamProducerClaimRequest +*/ +func (a *CameraAPIService) PostCamerasStreamProducerClaim(ctx context.Context, primaryKey string) ApiPostCamerasStreamProducerClaimRequest { + return ApiPostCamerasStreamProducerClaimRequest{ + ApiService: a, + ctx: ctx, + primaryKey: primaryKey, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfCamera +func (a *CameraAPIService) PostCamerasStreamProducerClaimExecute(r ApiPostCamerasStreamProducerClaimRequest) (*ResponseWithGenericOfCamera, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfCamera + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CameraAPIService.PostCamerasStreamProducerClaim") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/cameras/{primaryKey}/stream-producer-claim" + localVarPath = strings.Replace(localVarPath, "{"+"primaryKey"+"}", url.PathEscape(parameterValueToString(r.primaryKey, "primaryKey")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.cameraStreamProducerClaimRequest == nil { + return localVarReturnValue, nil, reportError("cameraStreamProducerClaimRequest is required and must be specified") + } + + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.cameraStreamProducerClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/api_client/api_object_detector_claim_video.go b/pkg/api_client/api_object_detector_claim_video.go new file mode 100644 index 0000000..9142bb3 --- /dev/null +++ b/pkg/api_client/api_object_detector_claim_video.go @@ -0,0 +1,139 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +) + + +// ObjectDetectorClaimVideoAPIService ObjectDetectorClaimVideoAPI service +type ObjectDetectorClaimVideoAPIService service + +type ApiPostObjectDetectorClaimVideosRequest struct { + ctx context.Context + ApiService *ObjectDetectorClaimVideoAPIService + videoObjectDetectorClaimRequest *VideoObjectDetectorClaimRequest +} + +func (r ApiPostObjectDetectorClaimVideosRequest) VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest VideoObjectDetectorClaimRequest) ApiPostObjectDetectorClaimVideosRequest { + r.videoObjectDetectorClaimRequest = &videoObjectDetectorClaimRequest + return r +} + +func (r ApiPostObjectDetectorClaimVideosRequest) Execute() (*ResponseWithGenericOfVideo, *http.Response, error) { + return r.ApiService.PostObjectDetectorClaimVideosExecute(r) +} + +/* +PostObjectDetectorClaimVideos Method for PostObjectDetectorClaimVideos + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiPostObjectDetectorClaimVideosRequest +*/ +func (a *ObjectDetectorClaimVideoAPIService) PostObjectDetectorClaimVideos(ctx context.Context) ApiPostObjectDetectorClaimVideosRequest { + return ApiPostObjectDetectorClaimVideosRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfVideo +func (a *ObjectDetectorClaimVideoAPIService) PostObjectDetectorClaimVideosExecute(r ApiPostObjectDetectorClaimVideosRequest) (*ResponseWithGenericOfVideo, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfVideo + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ObjectDetectorClaimVideoAPIService.PostObjectDetectorClaimVideos") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/object-detector-claim-video" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.videoObjectDetectorClaimRequest == nil { + return localVarReturnValue, nil, reportError("videoObjectDetectorClaimRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.videoObjectDetectorClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/api_client/api_custom.go b/pkg/api_client/api_object_tracker_claim_video.go similarity index 64% rename from pkg/api_client/api_custom.go rename to pkg/api_client/api_object_tracker_claim_video.go index a00e12b..b24bb6b 100644 --- a/pkg/api_client/api_custom.go +++ b/pkg/api_client/api_object_tracker_claim_video.go @@ -19,59 +19,59 @@ import ( ) -// CustomAPIService CustomAPI service -type CustomAPIService service +// ObjectTrackerClaimVideoAPIService ObjectTrackerClaimVideoAPI service +type ObjectTrackerClaimVideoAPIService service -type ApiPatchCustomClaimVideoForObjectDetectorRequest struct { +type ApiPostObjectTrackerClaimVideosRequest struct { ctx context.Context - ApiService *CustomAPIService - claimRequest *ClaimRequest + ApiService *ObjectTrackerClaimVideoAPIService + videoObjectTrackerClaimRequest *VideoObjectTrackerClaimRequest } -func (r ApiPatchCustomClaimVideoForObjectDetectorRequest) ClaimRequest(claimRequest ClaimRequest) ApiPatchCustomClaimVideoForObjectDetectorRequest { - r.claimRequest = &claimRequest +func (r ApiPostObjectTrackerClaimVideosRequest) VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest VideoObjectTrackerClaimRequest) ApiPostObjectTrackerClaimVideosRequest { + r.videoObjectTrackerClaimRequest = &videoObjectTrackerClaimRequest return r } -func (r ApiPatchCustomClaimVideoForObjectDetectorRequest) Execute() (*Video, *http.Response, error) { - return r.ApiService.PatchCustomClaimVideoForObjectDetectorExecute(r) +func (r ApiPostObjectTrackerClaimVideosRequest) Execute() (*ResponseWithGenericOfVideo, *http.Response, error) { + return r.ApiService.PostObjectTrackerClaimVideosExecute(r) } /* -PatchCustomClaimVideoForObjectDetector Method for PatchCustomClaimVideoForObjectDetector +PostObjectTrackerClaimVideos Method for PostObjectTrackerClaimVideos @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiPatchCustomClaimVideoForObjectDetectorRequest + @return ApiPostObjectTrackerClaimVideosRequest */ -func (a *CustomAPIService) PatchCustomClaimVideoForObjectDetector(ctx context.Context) ApiPatchCustomClaimVideoForObjectDetectorRequest { - return ApiPatchCustomClaimVideoForObjectDetectorRequest{ +func (a *ObjectTrackerClaimVideoAPIService) PostObjectTrackerClaimVideos(ctx context.Context) ApiPostObjectTrackerClaimVideosRequest { + return ApiPostObjectTrackerClaimVideosRequest{ ApiService: a, ctx: ctx, } } // Execute executes the request -// @return Video -func (a *CustomAPIService) PatchCustomClaimVideoForObjectDetectorExecute(r ApiPatchCustomClaimVideoForObjectDetectorRequest) (*Video, *http.Response, error) { +// @return ResponseWithGenericOfVideo +func (a *ObjectTrackerClaimVideoAPIService) PostObjectTrackerClaimVideosExecute(r ApiPostObjectTrackerClaimVideosRequest) (*ResponseWithGenericOfVideo, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPatch + localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile - localVarReturnValue *Video + localVarReturnValue *ResponseWithGenericOfVideo ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CustomAPIService.PatchCustomClaimVideoForObjectDetector") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ObjectTrackerClaimVideoAPIService.PostObjectTrackerClaimVideos") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/custom/claim-video-for-object-detector" + localVarPath := localBasePath + "/api/object-tracker-claim-video" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if r.claimRequest == nil { - return localVarReturnValue, nil, reportError("claimRequest is required and must be specified") + if r.videoObjectTrackerClaimRequest == nil { + return localVarReturnValue, nil, reportError("videoObjectTrackerClaimRequest is required and must be specified") } // to determine the Content-Type header @@ -92,7 +92,7 @@ func (a *CustomAPIService) PatchCustomClaimVideoForObjectDetectorExecute(r ApiPa localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params - localVarPostBody = r.claimRequest + localVarPostBody = r.videoObjectTrackerClaimRequest req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return localVarReturnValue, nil, err diff --git a/pkg/api_client/api_segment_producer_claim_camera.go b/pkg/api_client/api_segment_producer_claim_camera.go new file mode 100644 index 0000000..1140ae1 --- /dev/null +++ b/pkg/api_client/api_segment_producer_claim_camera.go @@ -0,0 +1,139 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +) + + +// SegmentProducerClaimCameraAPIService SegmentProducerClaimCameraAPI service +type SegmentProducerClaimCameraAPIService service + +type ApiPostSegmentProducerClaimCamerasRequest struct { + ctx context.Context + ApiService *SegmentProducerClaimCameraAPIService + cameraSegmentProducerClaimRequest *CameraSegmentProducerClaimRequest +} + +func (r ApiPostSegmentProducerClaimCamerasRequest) CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest CameraSegmentProducerClaimRequest) ApiPostSegmentProducerClaimCamerasRequest { + r.cameraSegmentProducerClaimRequest = &cameraSegmentProducerClaimRequest + return r +} + +func (r ApiPostSegmentProducerClaimCamerasRequest) Execute() (*ResponseWithGenericOfCamera, *http.Response, error) { + return r.ApiService.PostSegmentProducerClaimCamerasExecute(r) +} + +/* +PostSegmentProducerClaimCameras Method for PostSegmentProducerClaimCameras + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiPostSegmentProducerClaimCamerasRequest +*/ +func (a *SegmentProducerClaimCameraAPIService) PostSegmentProducerClaimCameras(ctx context.Context) ApiPostSegmentProducerClaimCamerasRequest { + return ApiPostSegmentProducerClaimCamerasRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfCamera +func (a *SegmentProducerClaimCameraAPIService) PostSegmentProducerClaimCamerasExecute(r ApiPostSegmentProducerClaimCamerasRequest) (*ResponseWithGenericOfCamera, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfCamera + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SegmentProducerClaimCameraAPIService.PostSegmentProducerClaimCameras") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/segment-producer-claim-camera" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.cameraSegmentProducerClaimRequest == nil { + return localVarReturnValue, nil, reportError("cameraSegmentProducerClaimRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.cameraSegmentProducerClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/api_client/api_stream_producer_claim_camera.go b/pkg/api_client/api_stream_producer_claim_camera.go new file mode 100644 index 0000000..469f733 --- /dev/null +++ b/pkg/api_client/api_stream_producer_claim_camera.go @@ -0,0 +1,139 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +) + + +// StreamProducerClaimCameraAPIService StreamProducerClaimCameraAPI service +type StreamProducerClaimCameraAPIService service + +type ApiPostStreamProducerClaimCamerasRequest struct { + ctx context.Context + ApiService *StreamProducerClaimCameraAPIService + cameraStreamProducerClaimRequest *CameraStreamProducerClaimRequest +} + +func (r ApiPostStreamProducerClaimCamerasRequest) CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest CameraStreamProducerClaimRequest) ApiPostStreamProducerClaimCamerasRequest { + r.cameraStreamProducerClaimRequest = &cameraStreamProducerClaimRequest + return r +} + +func (r ApiPostStreamProducerClaimCamerasRequest) Execute() (*ResponseWithGenericOfCamera, *http.Response, error) { + return r.ApiService.PostStreamProducerClaimCamerasExecute(r) +} + +/* +PostStreamProducerClaimCameras Method for PostStreamProducerClaimCameras + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiPostStreamProducerClaimCamerasRequest +*/ +func (a *StreamProducerClaimCameraAPIService) PostStreamProducerClaimCameras(ctx context.Context) ApiPostStreamProducerClaimCamerasRequest { + return ApiPostStreamProducerClaimCamerasRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfCamera +func (a *StreamProducerClaimCameraAPIService) PostStreamProducerClaimCamerasExecute(r ApiPostStreamProducerClaimCamerasRequest) (*ResponseWithGenericOfCamera, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfCamera + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StreamProducerClaimCameraAPIService.PostStreamProducerClaimCameras") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/stream-producer-claim-camera" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.cameraStreamProducerClaimRequest == nil { + return localVarReturnValue, nil, reportError("cameraStreamProducerClaimRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.cameraStreamProducerClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/api_client/api_video.go b/pkg/api_client/api_video.go index 5e1d3ea..dd24896 100644 --- a/pkg/api_client/api_video.go +++ b/pkg/api_client/api_video.go @@ -2933,3 +2933,263 @@ func (a *VideoAPIService) PostVideosExecute(r ApiPostVideosRequest) (*ResponseWi return localVarReturnValue, localVarHTTPResponse, nil } + +type ApiPostVideosObjectDetectorClaimRequest struct { + ctx context.Context + ApiService *VideoAPIService + primaryKey string + videoObjectDetectorClaimRequest *VideoObjectDetectorClaimRequest + depth *int64 +} + +func (r ApiPostVideosObjectDetectorClaimRequest) VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest VideoObjectDetectorClaimRequest) ApiPostVideosObjectDetectorClaimRequest { + r.videoObjectDetectorClaimRequest = &videoObjectDetectorClaimRequest + return r +} + +// Query parameter depth +func (r ApiPostVideosObjectDetectorClaimRequest) Depth(depth int64) ApiPostVideosObjectDetectorClaimRequest { + r.depth = &depth + return r +} + +func (r ApiPostVideosObjectDetectorClaimRequest) Execute() (*ResponseWithGenericOfVideo, *http.Response, error) { + return r.ApiService.PostVideosObjectDetectorClaimExecute(r) +} + +/* +PostVideosObjectDetectorClaim Method for PostVideosObjectDetectorClaim + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param primaryKey Path parameter primaryKey + @return ApiPostVideosObjectDetectorClaimRequest +*/ +func (a *VideoAPIService) PostVideosObjectDetectorClaim(ctx context.Context, primaryKey string) ApiPostVideosObjectDetectorClaimRequest { + return ApiPostVideosObjectDetectorClaimRequest{ + ApiService: a, + ctx: ctx, + primaryKey: primaryKey, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfVideo +func (a *VideoAPIService) PostVideosObjectDetectorClaimExecute(r ApiPostVideosObjectDetectorClaimRequest) (*ResponseWithGenericOfVideo, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfVideo + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "VideoAPIService.PostVideosObjectDetectorClaim") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/videos/{primaryKey}/object-detector-claim" + localVarPath = strings.Replace(localVarPath, "{"+"primaryKey"+"}", url.PathEscape(parameterValueToString(r.primaryKey, "primaryKey")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.videoObjectDetectorClaimRequest == nil { + return localVarReturnValue, nil, reportError("videoObjectDetectorClaimRequest is required and must be specified") + } + + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.videoObjectDetectorClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPostVideosObjectTrackerClaimRequest struct { + ctx context.Context + ApiService *VideoAPIService + primaryKey string + videoObjectTrackerClaimRequest *VideoObjectTrackerClaimRequest + depth *int64 +} + +func (r ApiPostVideosObjectTrackerClaimRequest) VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest VideoObjectTrackerClaimRequest) ApiPostVideosObjectTrackerClaimRequest { + r.videoObjectTrackerClaimRequest = &videoObjectTrackerClaimRequest + return r +} + +// Query parameter depth +func (r ApiPostVideosObjectTrackerClaimRequest) Depth(depth int64) ApiPostVideosObjectTrackerClaimRequest { + r.depth = &depth + return r +} + +func (r ApiPostVideosObjectTrackerClaimRequest) Execute() (*ResponseWithGenericOfVideo, *http.Response, error) { + return r.ApiService.PostVideosObjectTrackerClaimExecute(r) +} + +/* +PostVideosObjectTrackerClaim Method for PostVideosObjectTrackerClaim + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param primaryKey Path parameter primaryKey + @return ApiPostVideosObjectTrackerClaimRequest +*/ +func (a *VideoAPIService) PostVideosObjectTrackerClaim(ctx context.Context, primaryKey string) ApiPostVideosObjectTrackerClaimRequest { + return ApiPostVideosObjectTrackerClaimRequest{ + ApiService: a, + ctx: ctx, + primaryKey: primaryKey, + } +} + +// Execute executes the request +// @return ResponseWithGenericOfVideo +func (a *VideoAPIService) PostVideosObjectTrackerClaimExecute(r ApiPostVideosObjectTrackerClaimRequest) (*ResponseWithGenericOfVideo, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ResponseWithGenericOfVideo + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "VideoAPIService.PostVideosObjectTrackerClaim") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/videos/{primaryKey}/object-tracker-claim" + localVarPath = strings.Replace(localVarPath, "{"+"primaryKey"+"}", url.PathEscape(parameterValueToString(r.primaryKey, "primaryKey")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.videoObjectTrackerClaimRequest == nil { + return localVarReturnValue, nil, reportError("videoObjectTrackerClaimRequest is required and must be specified") + } + + if r.depth != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "depth", r.depth, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.videoObjectTrackerClaimRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v GetCamerasDefaultResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/api_client/client.go b/pkg/api_client/client.go index b83934f..1a51f92 100644 --- a/pkg/api_client/client.go +++ b/pkg/api_client/client.go @@ -51,10 +51,16 @@ type APIClient struct { CameraAPI *CameraAPIService - CustomAPI *CustomAPIService - DetectionAPI *DetectionAPIService + ObjectDetectorClaimVideoAPI *ObjectDetectorClaimVideoAPIService + + ObjectTrackerClaimVideoAPI *ObjectTrackerClaimVideoAPIService + + SegmentProducerClaimCameraAPI *SegmentProducerClaimCameraAPIService + + StreamProducerClaimCameraAPI *StreamProducerClaimCameraAPIService + VideoAPI *VideoAPIService } @@ -75,8 +81,11 @@ func NewAPIClient(cfg *Configuration) *APIClient { // API Services c.CameraAPI = (*CameraAPIService)(&c.common) - c.CustomAPI = (*CustomAPIService)(&c.common) c.DetectionAPI = (*DetectionAPIService)(&c.common) + c.ObjectDetectorClaimVideoAPI = (*ObjectDetectorClaimVideoAPIService)(&c.common) + c.ObjectTrackerClaimVideoAPI = (*ObjectTrackerClaimVideoAPIService)(&c.common) + c.SegmentProducerClaimCameraAPI = (*SegmentProducerClaimCameraAPIService)(&c.common) + c.StreamProducerClaimCameraAPI = (*StreamProducerClaimCameraAPIService)(&c.common) c.VideoAPI = (*VideoAPIService)(&c.common) return c diff --git a/pkg/api_client/docs/CameraAPI.md b/pkg/api_client/docs/CameraAPI.md index cf8d0d4..ea5f183 100644 --- a/pkg/api_client/docs/CameraAPI.md +++ b/pkg/api_client/docs/CameraAPI.md @@ -9,6 +9,8 @@ Method | HTTP request | Description [**GetCameras**](CameraAPI.md#GetCameras) | **Get** /api/cameras | [**PatchCamera**](CameraAPI.md#PatchCamera) | **Patch** /api/cameras/{primaryKey} | [**PostCameras**](CameraAPI.md#PostCameras) | **Post** /api/cameras | +[**PostCamerasSegmentProducerClaim**](CameraAPI.md#PostCamerasSegmentProducerClaim) | **Post** /api/cameras/{primaryKey}/segment-producer-claim | +[**PostCamerasStreamProducerClaim**](CameraAPI.md#PostCamerasStreamProducerClaim) | **Post** /api/cameras/{primaryKey}/stream-producer-claim | @@ -664,3 +666,147 @@ No authorization required [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## PostCamerasSegmentProducerClaim + +> ResponseWithGenericOfCamera PostCamerasSegmentProducerClaim(ctx, primaryKey).CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest).Depth(depth).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + primaryKey := "38400000-8cf0-11bd-b23e-10b96e4ef00d" // string | Path parameter primaryKey + cameraSegmentProducerClaimRequest := *openapiclient.NewCameraSegmentProducerClaimRequest() // CameraSegmentProducerClaimRequest | + depth := int64(789) // int64 | Query parameter depth (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.CameraAPI.PostCamerasSegmentProducerClaim(context.Background(), primaryKey).CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest).Depth(depth).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CameraAPI.PostCamerasSegmentProducerClaim``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostCamerasSegmentProducerClaim`: ResponseWithGenericOfCamera + fmt.Fprintf(os.Stdout, "Response from `CameraAPI.PostCamerasSegmentProducerClaim`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**primaryKey** | **string** | Path parameter primaryKey | + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostCamerasSegmentProducerClaimRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **cameraSegmentProducerClaimRequest** | [**CameraSegmentProducerClaimRequest**](CameraSegmentProducerClaimRequest.md) | | + **depth** | **int64** | Query parameter depth | + +### Return type + +[**ResponseWithGenericOfCamera**](ResponseWithGenericOfCamera.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## PostCamerasStreamProducerClaim + +> ResponseWithGenericOfCamera PostCamerasStreamProducerClaim(ctx, primaryKey).CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest).Depth(depth).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + primaryKey := "38400000-8cf0-11bd-b23e-10b96e4ef00d" // string | Path parameter primaryKey + cameraStreamProducerClaimRequest := *openapiclient.NewCameraStreamProducerClaimRequest() // CameraStreamProducerClaimRequest | + depth := int64(789) // int64 | Query parameter depth (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.CameraAPI.PostCamerasStreamProducerClaim(context.Background(), primaryKey).CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest).Depth(depth).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CameraAPI.PostCamerasStreamProducerClaim``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostCamerasStreamProducerClaim`: ResponseWithGenericOfCamera + fmt.Fprintf(os.Stdout, "Response from `CameraAPI.PostCamerasStreamProducerClaim`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**primaryKey** | **string** | Path parameter primaryKey | + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostCamerasStreamProducerClaimRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **cameraStreamProducerClaimRequest** | [**CameraStreamProducerClaimRequest**](CameraStreamProducerClaimRequest.md) | | + **depth** | **int64** | Query parameter depth | + +### Return type + +[**ResponseWithGenericOfCamera**](ResponseWithGenericOfCamera.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/CameraSegmentProducerClaimRequest.md b/pkg/api_client/docs/CameraSegmentProducerClaimRequest.md new file mode 100644 index 0000000..39056a3 --- /dev/null +++ b/pkg/api_client/docs/CameraSegmentProducerClaimRequest.md @@ -0,0 +1,82 @@ +# CameraSegmentProducerClaimRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TimeoutSeconds** | Pointer to **float64** | | [optional] +**Until** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewCameraSegmentProducerClaimRequest + +`func NewCameraSegmentProducerClaimRequest() *CameraSegmentProducerClaimRequest` + +NewCameraSegmentProducerClaimRequest instantiates a new CameraSegmentProducerClaimRequest object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewCameraSegmentProducerClaimRequestWithDefaults + +`func NewCameraSegmentProducerClaimRequestWithDefaults() *CameraSegmentProducerClaimRequest` + +NewCameraSegmentProducerClaimRequestWithDefaults instantiates a new CameraSegmentProducerClaimRequest object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetTimeoutSeconds + +`func (o *CameraSegmentProducerClaimRequest) GetTimeoutSeconds() float64` + +GetTimeoutSeconds returns the TimeoutSeconds field if non-nil, zero value otherwise. + +### GetTimeoutSecondsOk + +`func (o *CameraSegmentProducerClaimRequest) GetTimeoutSecondsOk() (*float64, bool)` + +GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTimeoutSeconds + +`func (o *CameraSegmentProducerClaimRequest) SetTimeoutSeconds(v float64)` + +SetTimeoutSeconds sets TimeoutSeconds field to given value. + +### HasTimeoutSeconds + +`func (o *CameraSegmentProducerClaimRequest) HasTimeoutSeconds() bool` + +HasTimeoutSeconds returns a boolean if a field has been set. + +### GetUntil + +`func (o *CameraSegmentProducerClaimRequest) GetUntil() time.Time` + +GetUntil returns the Until field if non-nil, zero value otherwise. + +### GetUntilOk + +`func (o *CameraSegmentProducerClaimRequest) GetUntilOk() (*time.Time, bool)` + +GetUntilOk returns a tuple with the Until field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUntil + +`func (o *CameraSegmentProducerClaimRequest) SetUntil(v time.Time)` + +SetUntil sets Until field to given value. + +### HasUntil + +`func (o *CameraSegmentProducerClaimRequest) HasUntil() bool` + +HasUntil returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkg/api_client/docs/CameraStreamProducerClaimRequest.md b/pkg/api_client/docs/CameraStreamProducerClaimRequest.md new file mode 100644 index 0000000..ac3eaf5 --- /dev/null +++ b/pkg/api_client/docs/CameraStreamProducerClaimRequest.md @@ -0,0 +1,82 @@ +# CameraStreamProducerClaimRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TimeoutSeconds** | Pointer to **float64** | | [optional] +**Until** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewCameraStreamProducerClaimRequest + +`func NewCameraStreamProducerClaimRequest() *CameraStreamProducerClaimRequest` + +NewCameraStreamProducerClaimRequest instantiates a new CameraStreamProducerClaimRequest object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewCameraStreamProducerClaimRequestWithDefaults + +`func NewCameraStreamProducerClaimRequestWithDefaults() *CameraStreamProducerClaimRequest` + +NewCameraStreamProducerClaimRequestWithDefaults instantiates a new CameraStreamProducerClaimRequest object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetTimeoutSeconds + +`func (o *CameraStreamProducerClaimRequest) GetTimeoutSeconds() float64` + +GetTimeoutSeconds returns the TimeoutSeconds field if non-nil, zero value otherwise. + +### GetTimeoutSecondsOk + +`func (o *CameraStreamProducerClaimRequest) GetTimeoutSecondsOk() (*float64, bool)` + +GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTimeoutSeconds + +`func (o *CameraStreamProducerClaimRequest) SetTimeoutSeconds(v float64)` + +SetTimeoutSeconds sets TimeoutSeconds field to given value. + +### HasTimeoutSeconds + +`func (o *CameraStreamProducerClaimRequest) HasTimeoutSeconds() bool` + +HasTimeoutSeconds returns a boolean if a field has been set. + +### GetUntil + +`func (o *CameraStreamProducerClaimRequest) GetUntil() time.Time` + +GetUntil returns the Until field if non-nil, zero value otherwise. + +### GetUntilOk + +`func (o *CameraStreamProducerClaimRequest) GetUntilOk() (*time.Time, bool)` + +GetUntilOk returns a tuple with the Until field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUntil + +`func (o *CameraStreamProducerClaimRequest) SetUntil(v time.Time)` + +SetUntil sets Until field to given value. + +### HasUntil + +`func (o *CameraStreamProducerClaimRequest) HasUntil() bool` + +HasUntil returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkg/api_client/docs/ClaimRequest.md b/pkg/api_client/docs/ClaimRequest.md deleted file mode 100644 index 882e974..0000000 --- a/pkg/api_client/docs/ClaimRequest.md +++ /dev/null @@ -1,56 +0,0 @@ -# ClaimRequest - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**ClaimDurationSeconds** | Pointer to **float64** | | [optional] - -## Methods - -### NewClaimRequest - -`func NewClaimRequest() *ClaimRequest` - -NewClaimRequest instantiates a new ClaimRequest object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewClaimRequestWithDefaults - -`func NewClaimRequestWithDefaults() *ClaimRequest` - -NewClaimRequestWithDefaults instantiates a new ClaimRequest object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetClaimDurationSeconds - -`func (o *ClaimRequest) GetClaimDurationSeconds() float64` - -GetClaimDurationSeconds returns the ClaimDurationSeconds field if non-nil, zero value otherwise. - -### GetClaimDurationSecondsOk - -`func (o *ClaimRequest) GetClaimDurationSecondsOk() (*float64, bool)` - -GetClaimDurationSecondsOk returns a tuple with the ClaimDurationSeconds field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetClaimDurationSeconds - -`func (o *ClaimRequest) SetClaimDurationSeconds(v float64)` - -SetClaimDurationSeconds sets ClaimDurationSeconds field to given value. - -### HasClaimDurationSeconds - -`func (o *ClaimRequest) HasClaimDurationSeconds() bool` - -HasClaimDurationSeconds returns a boolean if a field has been set. - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkg/api_client/docs/CustomAPI.md b/pkg/api_client/docs/CustomAPI.md deleted file mode 100644 index 95715dc..0000000 --- a/pkg/api_client/docs/CustomAPI.md +++ /dev/null @@ -1,73 +0,0 @@ -# \CustomAPI - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**PatchCustomClaimVideoForObjectDetector**](CustomAPI.md#PatchCustomClaimVideoForObjectDetector) | **Patch** /api/custom/claim-video-for-object-detector | - - - -## PatchCustomClaimVideoForObjectDetector - -> Video PatchCustomClaimVideoForObjectDetector(ctx).ClaimRequest(claimRequest).Execute() - - - -### Example - -```go -package main - -import ( - "context" - "fmt" - "os" - openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" -) - -func main() { - claimRequest := *openapiclient.NewClaimRequest() // ClaimRequest | - - configuration := openapiclient.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.CustomAPI.PatchCustomClaimVideoForObjectDetector(context.Background()).ClaimRequest(claimRequest).Execute() - if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `CustomAPI.PatchCustomClaimVideoForObjectDetector``: %v\n", err) - fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) - } - // response from `PatchCustomClaimVideoForObjectDetector`: Video - fmt.Fprintf(os.Stdout, "Response from `CustomAPI.PatchCustomClaimVideoForObjectDetector`: %v\n", resp) -} -``` - -### Path Parameters - - - -### Other Parameters - -Other parameters are passed through a pointer to a apiPatchCustomClaimVideoForObjectDetectorRequest struct via the builder pattern - - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **claimRequest** | [**ClaimRequest**](ClaimRequest.md) | | - -### Return type - -[**Video**](Video.md) - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: application/json -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) -[[Back to Model list]](../README.md#documentation-for-models) -[[Back to README]](../README.md) - diff --git a/pkg/api_client/docs/ObjectDetectorClaimVideoAPI.md b/pkg/api_client/docs/ObjectDetectorClaimVideoAPI.md new file mode 100644 index 0000000..ad58015 --- /dev/null +++ b/pkg/api_client/docs/ObjectDetectorClaimVideoAPI.md @@ -0,0 +1,73 @@ +# \ObjectDetectorClaimVideoAPI + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**PostObjectDetectorClaimVideos**](ObjectDetectorClaimVideoAPI.md#PostObjectDetectorClaimVideos) | **Post** /api/object-detector-claim-video | + + + +## PostObjectDetectorClaimVideos + +> ResponseWithGenericOfVideo PostObjectDetectorClaimVideos(ctx).VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + videoObjectDetectorClaimRequest := *openapiclient.NewVideoObjectDetectorClaimRequest() // VideoObjectDetectorClaimRequest | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.ObjectDetectorClaimVideoAPI.PostObjectDetectorClaimVideos(context.Background()).VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ObjectDetectorClaimVideoAPI.PostObjectDetectorClaimVideos``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostObjectDetectorClaimVideos`: ResponseWithGenericOfVideo + fmt.Fprintf(os.Stdout, "Response from `ObjectDetectorClaimVideoAPI.PostObjectDetectorClaimVideos`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostObjectDetectorClaimVideosRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **videoObjectDetectorClaimRequest** | [**VideoObjectDetectorClaimRequest**](VideoObjectDetectorClaimRequest.md) | | + +### Return type + +[**ResponseWithGenericOfVideo**](ResponseWithGenericOfVideo.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/ObjectTrackerClaimVideoAPI.md b/pkg/api_client/docs/ObjectTrackerClaimVideoAPI.md new file mode 100644 index 0000000..5f79664 --- /dev/null +++ b/pkg/api_client/docs/ObjectTrackerClaimVideoAPI.md @@ -0,0 +1,73 @@ +# \ObjectTrackerClaimVideoAPI + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**PostObjectTrackerClaimVideos**](ObjectTrackerClaimVideoAPI.md#PostObjectTrackerClaimVideos) | **Post** /api/object-tracker-claim-video | + + + +## PostObjectTrackerClaimVideos + +> ResponseWithGenericOfVideo PostObjectTrackerClaimVideos(ctx).VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + videoObjectTrackerClaimRequest := *openapiclient.NewVideoObjectTrackerClaimRequest() // VideoObjectTrackerClaimRequest | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.ObjectTrackerClaimVideoAPI.PostObjectTrackerClaimVideos(context.Background()).VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ObjectTrackerClaimVideoAPI.PostObjectTrackerClaimVideos``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostObjectTrackerClaimVideos`: ResponseWithGenericOfVideo + fmt.Fprintf(os.Stdout, "Response from `ObjectTrackerClaimVideoAPI.PostObjectTrackerClaimVideos`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostObjectTrackerClaimVideosRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **videoObjectTrackerClaimRequest** | [**VideoObjectTrackerClaimRequest**](VideoObjectTrackerClaimRequest.md) | | + +### Return type + +[**ResponseWithGenericOfVideo**](ResponseWithGenericOfVideo.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/SegmentProducerClaimCameraAPI.md b/pkg/api_client/docs/SegmentProducerClaimCameraAPI.md new file mode 100644 index 0000000..78d1326 --- /dev/null +++ b/pkg/api_client/docs/SegmentProducerClaimCameraAPI.md @@ -0,0 +1,73 @@ +# \SegmentProducerClaimCameraAPI + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**PostSegmentProducerClaimCameras**](SegmentProducerClaimCameraAPI.md#PostSegmentProducerClaimCameras) | **Post** /api/segment-producer-claim-camera | + + + +## PostSegmentProducerClaimCameras + +> ResponseWithGenericOfCamera PostSegmentProducerClaimCameras(ctx).CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + cameraSegmentProducerClaimRequest := *openapiclient.NewCameraSegmentProducerClaimRequest() // CameraSegmentProducerClaimRequest | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.SegmentProducerClaimCameraAPI.PostSegmentProducerClaimCameras(context.Background()).CameraSegmentProducerClaimRequest(cameraSegmentProducerClaimRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SegmentProducerClaimCameraAPI.PostSegmentProducerClaimCameras``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostSegmentProducerClaimCameras`: ResponseWithGenericOfCamera + fmt.Fprintf(os.Stdout, "Response from `SegmentProducerClaimCameraAPI.PostSegmentProducerClaimCameras`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostSegmentProducerClaimCamerasRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **cameraSegmentProducerClaimRequest** | [**CameraSegmentProducerClaimRequest**](CameraSegmentProducerClaimRequest.md) | | + +### Return type + +[**ResponseWithGenericOfCamera**](ResponseWithGenericOfCamera.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/StreamProducerClaimCameraAPI.md b/pkg/api_client/docs/StreamProducerClaimCameraAPI.md new file mode 100644 index 0000000..e146ed8 --- /dev/null +++ b/pkg/api_client/docs/StreamProducerClaimCameraAPI.md @@ -0,0 +1,73 @@ +# \StreamProducerClaimCameraAPI + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**PostStreamProducerClaimCameras**](StreamProducerClaimCameraAPI.md#PostStreamProducerClaimCameras) | **Post** /api/stream-producer-claim-camera | + + + +## PostStreamProducerClaimCameras + +> ResponseWithGenericOfCamera PostStreamProducerClaimCameras(ctx).CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + cameraStreamProducerClaimRequest := *openapiclient.NewCameraStreamProducerClaimRequest() // CameraStreamProducerClaimRequest | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.StreamProducerClaimCameraAPI.PostStreamProducerClaimCameras(context.Background()).CameraStreamProducerClaimRequest(cameraStreamProducerClaimRequest).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StreamProducerClaimCameraAPI.PostStreamProducerClaimCameras``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostStreamProducerClaimCameras`: ResponseWithGenericOfCamera + fmt.Fprintf(os.Stdout, "Response from `StreamProducerClaimCameraAPI.PostStreamProducerClaimCameras`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostStreamProducerClaimCamerasRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **cameraStreamProducerClaimRequest** | [**CameraStreamProducerClaimRequest**](CameraStreamProducerClaimRequest.md) | | + +### Return type + +[**ResponseWithGenericOfCamera**](ResponseWithGenericOfCamera.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/VideoAPI.md b/pkg/api_client/docs/VideoAPI.md index 02e9921..fd876f3 100644 --- a/pkg/api_client/docs/VideoAPI.md +++ b/pkg/api_client/docs/VideoAPI.md @@ -9,6 +9,8 @@ Method | HTTP request | Description [**GetVideos**](VideoAPI.md#GetVideos) | **Get** /api/videos | [**PatchVideo**](VideoAPI.md#PatchVideo) | **Patch** /api/videos/{primaryKey} | [**PostVideos**](VideoAPI.md#PostVideos) | **Post** /api/videos | +[**PostVideosObjectDetectorClaim**](VideoAPI.md#PostVideosObjectDetectorClaim) | **Post** /api/videos/{primaryKey}/object-detector-claim | +[**PostVideosObjectTrackerClaim**](VideoAPI.md#PostVideosObjectTrackerClaim) | **Post** /api/videos/{primaryKey}/object-tracker-claim | @@ -816,3 +818,147 @@ No authorization required [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## PostVideosObjectDetectorClaim + +> ResponseWithGenericOfVideo PostVideosObjectDetectorClaim(ctx, primaryKey).VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest).Depth(depth).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + primaryKey := "38400000-8cf0-11bd-b23e-10b96e4ef00d" // string | Path parameter primaryKey + videoObjectDetectorClaimRequest := *openapiclient.NewVideoObjectDetectorClaimRequest() // VideoObjectDetectorClaimRequest | + depth := int64(789) // int64 | Query parameter depth (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.VideoAPI.PostVideosObjectDetectorClaim(context.Background(), primaryKey).VideoObjectDetectorClaimRequest(videoObjectDetectorClaimRequest).Depth(depth).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `VideoAPI.PostVideosObjectDetectorClaim``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostVideosObjectDetectorClaim`: ResponseWithGenericOfVideo + fmt.Fprintf(os.Stdout, "Response from `VideoAPI.PostVideosObjectDetectorClaim`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**primaryKey** | **string** | Path parameter primaryKey | + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostVideosObjectDetectorClaimRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **videoObjectDetectorClaimRequest** | [**VideoObjectDetectorClaimRequest**](VideoObjectDetectorClaimRequest.md) | | + **depth** | **int64** | Query parameter depth | + +### Return type + +[**ResponseWithGenericOfVideo**](ResponseWithGenericOfVideo.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## PostVideosObjectTrackerClaim + +> ResponseWithGenericOfVideo PostVideosObjectTrackerClaim(ctx, primaryKey).VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest).Depth(depth).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func main() { + primaryKey := "38400000-8cf0-11bd-b23e-10b96e4ef00d" // string | Path parameter primaryKey + videoObjectTrackerClaimRequest := *openapiclient.NewVideoObjectTrackerClaimRequest() // VideoObjectTrackerClaimRequest | + depth := int64(789) // int64 | Query parameter depth (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.VideoAPI.PostVideosObjectTrackerClaim(context.Background(), primaryKey).VideoObjectTrackerClaimRequest(videoObjectTrackerClaimRequest).Depth(depth).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `VideoAPI.PostVideosObjectTrackerClaim``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PostVideosObjectTrackerClaim`: ResponseWithGenericOfVideo + fmt.Fprintf(os.Stdout, "Response from `VideoAPI.PostVideosObjectTrackerClaim`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**primaryKey** | **string** | Path parameter primaryKey | + +### Other Parameters + +Other parameters are passed through a pointer to a apiPostVideosObjectTrackerClaimRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **videoObjectTrackerClaimRequest** | [**VideoObjectTrackerClaimRequest**](VideoObjectTrackerClaimRequest.md) | | + **depth** | **int64** | Query parameter depth | + +### Return type + +[**ResponseWithGenericOfVideo**](ResponseWithGenericOfVideo.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/pkg/api_client/docs/VideoObjectDetectorClaimRequest.md b/pkg/api_client/docs/VideoObjectDetectorClaimRequest.md new file mode 100644 index 0000000..3f5472d --- /dev/null +++ b/pkg/api_client/docs/VideoObjectDetectorClaimRequest.md @@ -0,0 +1,82 @@ +# VideoObjectDetectorClaimRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TimeoutSeconds** | Pointer to **float64** | | [optional] +**Until** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewVideoObjectDetectorClaimRequest + +`func NewVideoObjectDetectorClaimRequest() *VideoObjectDetectorClaimRequest` + +NewVideoObjectDetectorClaimRequest instantiates a new VideoObjectDetectorClaimRequest object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewVideoObjectDetectorClaimRequestWithDefaults + +`func NewVideoObjectDetectorClaimRequestWithDefaults() *VideoObjectDetectorClaimRequest` + +NewVideoObjectDetectorClaimRequestWithDefaults instantiates a new VideoObjectDetectorClaimRequest object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetTimeoutSeconds + +`func (o *VideoObjectDetectorClaimRequest) GetTimeoutSeconds() float64` + +GetTimeoutSeconds returns the TimeoutSeconds field if non-nil, zero value otherwise. + +### GetTimeoutSecondsOk + +`func (o *VideoObjectDetectorClaimRequest) GetTimeoutSecondsOk() (*float64, bool)` + +GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTimeoutSeconds + +`func (o *VideoObjectDetectorClaimRequest) SetTimeoutSeconds(v float64)` + +SetTimeoutSeconds sets TimeoutSeconds field to given value. + +### HasTimeoutSeconds + +`func (o *VideoObjectDetectorClaimRequest) HasTimeoutSeconds() bool` + +HasTimeoutSeconds returns a boolean if a field has been set. + +### GetUntil + +`func (o *VideoObjectDetectorClaimRequest) GetUntil() time.Time` + +GetUntil returns the Until field if non-nil, zero value otherwise. + +### GetUntilOk + +`func (o *VideoObjectDetectorClaimRequest) GetUntilOk() (*time.Time, bool)` + +GetUntilOk returns a tuple with the Until field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUntil + +`func (o *VideoObjectDetectorClaimRequest) SetUntil(v time.Time)` + +SetUntil sets Until field to given value. + +### HasUntil + +`func (o *VideoObjectDetectorClaimRequest) HasUntil() bool` + +HasUntil returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkg/api_client/docs/VideoObjectTrackerClaimRequest.md b/pkg/api_client/docs/VideoObjectTrackerClaimRequest.md new file mode 100644 index 0000000..8fefe51 --- /dev/null +++ b/pkg/api_client/docs/VideoObjectTrackerClaimRequest.md @@ -0,0 +1,82 @@ +# VideoObjectTrackerClaimRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TimeoutSeconds** | Pointer to **float64** | | [optional] +**Until** | Pointer to **time.Time** | | [optional] + +## Methods + +### NewVideoObjectTrackerClaimRequest + +`func NewVideoObjectTrackerClaimRequest() *VideoObjectTrackerClaimRequest` + +NewVideoObjectTrackerClaimRequest instantiates a new VideoObjectTrackerClaimRequest object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewVideoObjectTrackerClaimRequestWithDefaults + +`func NewVideoObjectTrackerClaimRequestWithDefaults() *VideoObjectTrackerClaimRequest` + +NewVideoObjectTrackerClaimRequestWithDefaults instantiates a new VideoObjectTrackerClaimRequest object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetTimeoutSeconds + +`func (o *VideoObjectTrackerClaimRequest) GetTimeoutSeconds() float64` + +GetTimeoutSeconds returns the TimeoutSeconds field if non-nil, zero value otherwise. + +### GetTimeoutSecondsOk + +`func (o *VideoObjectTrackerClaimRequest) GetTimeoutSecondsOk() (*float64, bool)` + +GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTimeoutSeconds + +`func (o *VideoObjectTrackerClaimRequest) SetTimeoutSeconds(v float64)` + +SetTimeoutSeconds sets TimeoutSeconds field to given value. + +### HasTimeoutSeconds + +`func (o *VideoObjectTrackerClaimRequest) HasTimeoutSeconds() bool` + +HasTimeoutSeconds returns a boolean if a field has been set. + +### GetUntil + +`func (o *VideoObjectTrackerClaimRequest) GetUntil() time.Time` + +GetUntil returns the Until field if non-nil, zero value otherwise. + +### GetUntilOk + +`func (o *VideoObjectTrackerClaimRequest) GetUntilOk() (*time.Time, bool)` + +GetUntilOk returns a tuple with the Until field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUntil + +`func (o *VideoObjectTrackerClaimRequest) SetUntil(v time.Time)` + +SetUntil sets Until field to given value. + +### HasUntil + +`func (o *VideoObjectTrackerClaimRequest) HasUntil() bool` + +HasUntil returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkg/api_client/model_camera_segment_producer_claim_request.go b/pkg/api_client/model_camera_segment_producer_claim_request.go new file mode 100644 index 0000000..b359464 --- /dev/null +++ b/pkg/api_client/model_camera_segment_producer_claim_request.go @@ -0,0 +1,163 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "encoding/json" + "time" +) + +// checks if the CameraSegmentProducerClaimRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CameraSegmentProducerClaimRequest{} + +// CameraSegmentProducerClaimRequest struct for CameraSegmentProducerClaimRequest +type CameraSegmentProducerClaimRequest struct { + TimeoutSeconds *float64 `json:"timeout_seconds,omitempty"` + Until *time.Time `json:"until,omitempty"` +} + +// NewCameraSegmentProducerClaimRequest instantiates a new CameraSegmentProducerClaimRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCameraSegmentProducerClaimRequest() *CameraSegmentProducerClaimRequest { + this := CameraSegmentProducerClaimRequest{} + return &this +} + +// NewCameraSegmentProducerClaimRequestWithDefaults instantiates a new CameraSegmentProducerClaimRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCameraSegmentProducerClaimRequestWithDefaults() *CameraSegmentProducerClaimRequest { + this := CameraSegmentProducerClaimRequest{} + return &this +} + +// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise. +func (o *CameraSegmentProducerClaimRequest) GetTimeoutSeconds() float64 { + if o == nil || IsNil(o.TimeoutSeconds) { + var ret float64 + return ret + } + return *o.TimeoutSeconds +} + +// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CameraSegmentProducerClaimRequest) GetTimeoutSecondsOk() (*float64, bool) { + if o == nil || IsNil(o.TimeoutSeconds) { + return nil, false + } + return o.TimeoutSeconds, true +} + +// HasTimeoutSeconds returns a boolean if a field has been set. +func (o *CameraSegmentProducerClaimRequest) HasTimeoutSeconds() bool { + if o != nil && !IsNil(o.TimeoutSeconds) { + return true + } + + return false +} + +// SetTimeoutSeconds gets a reference to the given float64 and assigns it to the TimeoutSeconds field. +func (o *CameraSegmentProducerClaimRequest) SetTimeoutSeconds(v float64) { + o.TimeoutSeconds = &v +} + +// GetUntil returns the Until field value if set, zero value otherwise. +func (o *CameraSegmentProducerClaimRequest) GetUntil() time.Time { + if o == nil || IsNil(o.Until) { + var ret time.Time + return ret + } + return *o.Until +} + +// GetUntilOk returns a tuple with the Until field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CameraSegmentProducerClaimRequest) GetUntilOk() (*time.Time, bool) { + if o == nil || IsNil(o.Until) { + return nil, false + } + return o.Until, true +} + +// HasUntil returns a boolean if a field has been set. +func (o *CameraSegmentProducerClaimRequest) HasUntil() bool { + if o != nil && !IsNil(o.Until) { + return true + } + + return false +} + +// SetUntil gets a reference to the given time.Time and assigns it to the Until field. +func (o *CameraSegmentProducerClaimRequest) SetUntil(v time.Time) { + o.Until = &v +} + +func (o CameraSegmentProducerClaimRequest) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CameraSegmentProducerClaimRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.TimeoutSeconds) { + toSerialize["timeout_seconds"] = o.TimeoutSeconds + } + if !IsNil(o.Until) { + toSerialize["until"] = o.Until + } + return toSerialize, nil +} + +type NullableCameraSegmentProducerClaimRequest struct { + value *CameraSegmentProducerClaimRequest + isSet bool +} + +func (v NullableCameraSegmentProducerClaimRequest) Get() *CameraSegmentProducerClaimRequest { + return v.value +} + +func (v *NullableCameraSegmentProducerClaimRequest) Set(val *CameraSegmentProducerClaimRequest) { + v.value = val + v.isSet = true +} + +func (v NullableCameraSegmentProducerClaimRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableCameraSegmentProducerClaimRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCameraSegmentProducerClaimRequest(val *CameraSegmentProducerClaimRequest) *NullableCameraSegmentProducerClaimRequest { + return &NullableCameraSegmentProducerClaimRequest{value: val, isSet: true} +} + +func (v NullableCameraSegmentProducerClaimRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCameraSegmentProducerClaimRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/api_client/model_camera_stream_producer_claim_request.go b/pkg/api_client/model_camera_stream_producer_claim_request.go new file mode 100644 index 0000000..39ae7fd --- /dev/null +++ b/pkg/api_client/model_camera_stream_producer_claim_request.go @@ -0,0 +1,163 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "encoding/json" + "time" +) + +// checks if the CameraStreamProducerClaimRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CameraStreamProducerClaimRequest{} + +// CameraStreamProducerClaimRequest struct for CameraStreamProducerClaimRequest +type CameraStreamProducerClaimRequest struct { + TimeoutSeconds *float64 `json:"timeout_seconds,omitempty"` + Until *time.Time `json:"until,omitempty"` +} + +// NewCameraStreamProducerClaimRequest instantiates a new CameraStreamProducerClaimRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCameraStreamProducerClaimRequest() *CameraStreamProducerClaimRequest { + this := CameraStreamProducerClaimRequest{} + return &this +} + +// NewCameraStreamProducerClaimRequestWithDefaults instantiates a new CameraStreamProducerClaimRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCameraStreamProducerClaimRequestWithDefaults() *CameraStreamProducerClaimRequest { + this := CameraStreamProducerClaimRequest{} + return &this +} + +// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise. +func (o *CameraStreamProducerClaimRequest) GetTimeoutSeconds() float64 { + if o == nil || IsNil(o.TimeoutSeconds) { + var ret float64 + return ret + } + return *o.TimeoutSeconds +} + +// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CameraStreamProducerClaimRequest) GetTimeoutSecondsOk() (*float64, bool) { + if o == nil || IsNil(o.TimeoutSeconds) { + return nil, false + } + return o.TimeoutSeconds, true +} + +// HasTimeoutSeconds returns a boolean if a field has been set. +func (o *CameraStreamProducerClaimRequest) HasTimeoutSeconds() bool { + if o != nil && !IsNil(o.TimeoutSeconds) { + return true + } + + return false +} + +// SetTimeoutSeconds gets a reference to the given float64 and assigns it to the TimeoutSeconds field. +func (o *CameraStreamProducerClaimRequest) SetTimeoutSeconds(v float64) { + o.TimeoutSeconds = &v +} + +// GetUntil returns the Until field value if set, zero value otherwise. +func (o *CameraStreamProducerClaimRequest) GetUntil() time.Time { + if o == nil || IsNil(o.Until) { + var ret time.Time + return ret + } + return *o.Until +} + +// GetUntilOk returns a tuple with the Until field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CameraStreamProducerClaimRequest) GetUntilOk() (*time.Time, bool) { + if o == nil || IsNil(o.Until) { + return nil, false + } + return o.Until, true +} + +// HasUntil returns a boolean if a field has been set. +func (o *CameraStreamProducerClaimRequest) HasUntil() bool { + if o != nil && !IsNil(o.Until) { + return true + } + + return false +} + +// SetUntil gets a reference to the given time.Time and assigns it to the Until field. +func (o *CameraStreamProducerClaimRequest) SetUntil(v time.Time) { + o.Until = &v +} + +func (o CameraStreamProducerClaimRequest) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CameraStreamProducerClaimRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.TimeoutSeconds) { + toSerialize["timeout_seconds"] = o.TimeoutSeconds + } + if !IsNil(o.Until) { + toSerialize["until"] = o.Until + } + return toSerialize, nil +} + +type NullableCameraStreamProducerClaimRequest struct { + value *CameraStreamProducerClaimRequest + isSet bool +} + +func (v NullableCameraStreamProducerClaimRequest) Get() *CameraStreamProducerClaimRequest { + return v.value +} + +func (v *NullableCameraStreamProducerClaimRequest) Set(val *CameraStreamProducerClaimRequest) { + v.value = val + v.isSet = true +} + +func (v NullableCameraStreamProducerClaimRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableCameraStreamProducerClaimRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCameraStreamProducerClaimRequest(val *CameraStreamProducerClaimRequest) *NullableCameraStreamProducerClaimRequest { + return &NullableCameraStreamProducerClaimRequest{value: val, isSet: true} +} + +func (v NullableCameraStreamProducerClaimRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCameraStreamProducerClaimRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/api_client/model_claim_request.go b/pkg/api_client/model_claim_request.go deleted file mode 100644 index 4f7a6cc..0000000 --- a/pkg/api_client/model_claim_request.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Djangolang - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package api_client - -import ( - "encoding/json" -) - -// checks if the ClaimRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ClaimRequest{} - -// ClaimRequest struct for ClaimRequest -type ClaimRequest struct { - ClaimDurationSeconds *float64 `json:"claim_duration_seconds,omitempty"` -} - -// NewClaimRequest instantiates a new ClaimRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewClaimRequest() *ClaimRequest { - this := ClaimRequest{} - return &this -} - -// NewClaimRequestWithDefaults instantiates a new ClaimRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewClaimRequestWithDefaults() *ClaimRequest { - this := ClaimRequest{} - return &this -} - -// GetClaimDurationSeconds returns the ClaimDurationSeconds field value if set, zero value otherwise. -func (o *ClaimRequest) GetClaimDurationSeconds() float64 { - if o == nil || IsNil(o.ClaimDurationSeconds) { - var ret float64 - return ret - } - return *o.ClaimDurationSeconds -} - -// GetClaimDurationSecondsOk returns a tuple with the ClaimDurationSeconds field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ClaimRequest) GetClaimDurationSecondsOk() (*float64, bool) { - if o == nil || IsNil(o.ClaimDurationSeconds) { - return nil, false - } - return o.ClaimDurationSeconds, true -} - -// HasClaimDurationSeconds returns a boolean if a field has been set. -func (o *ClaimRequest) HasClaimDurationSeconds() bool { - if o != nil && !IsNil(o.ClaimDurationSeconds) { - return true - } - - return false -} - -// SetClaimDurationSeconds gets a reference to the given float64 and assigns it to the ClaimDurationSeconds field. -func (o *ClaimRequest) SetClaimDurationSeconds(v float64) { - o.ClaimDurationSeconds = &v -} - -func (o ClaimRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ClaimRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.ClaimDurationSeconds) { - toSerialize["claim_duration_seconds"] = o.ClaimDurationSeconds - } - return toSerialize, nil -} - -type NullableClaimRequest struct { - value *ClaimRequest - isSet bool -} - -func (v NullableClaimRequest) Get() *ClaimRequest { - return v.value -} - -func (v *NullableClaimRequest) Set(val *ClaimRequest) { - v.value = val - v.isSet = true -} - -func (v NullableClaimRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableClaimRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableClaimRequest(val *ClaimRequest) *NullableClaimRequest { - return &NullableClaimRequest{value: val, isSet: true} -} - -func (v NullableClaimRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableClaimRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/pkg/api_client/model_video_object_detector_claim_request.go b/pkg/api_client/model_video_object_detector_claim_request.go new file mode 100644 index 0000000..3841c52 --- /dev/null +++ b/pkg/api_client/model_video_object_detector_claim_request.go @@ -0,0 +1,163 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "encoding/json" + "time" +) + +// checks if the VideoObjectDetectorClaimRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VideoObjectDetectorClaimRequest{} + +// VideoObjectDetectorClaimRequest struct for VideoObjectDetectorClaimRequest +type VideoObjectDetectorClaimRequest struct { + TimeoutSeconds *float64 `json:"timeout_seconds,omitempty"` + Until *time.Time `json:"until,omitempty"` +} + +// NewVideoObjectDetectorClaimRequest instantiates a new VideoObjectDetectorClaimRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewVideoObjectDetectorClaimRequest() *VideoObjectDetectorClaimRequest { + this := VideoObjectDetectorClaimRequest{} + return &this +} + +// NewVideoObjectDetectorClaimRequestWithDefaults instantiates a new VideoObjectDetectorClaimRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewVideoObjectDetectorClaimRequestWithDefaults() *VideoObjectDetectorClaimRequest { + this := VideoObjectDetectorClaimRequest{} + return &this +} + +// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise. +func (o *VideoObjectDetectorClaimRequest) GetTimeoutSeconds() float64 { + if o == nil || IsNil(o.TimeoutSeconds) { + var ret float64 + return ret + } + return *o.TimeoutSeconds +} + +// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VideoObjectDetectorClaimRequest) GetTimeoutSecondsOk() (*float64, bool) { + if o == nil || IsNil(o.TimeoutSeconds) { + return nil, false + } + return o.TimeoutSeconds, true +} + +// HasTimeoutSeconds returns a boolean if a field has been set. +func (o *VideoObjectDetectorClaimRequest) HasTimeoutSeconds() bool { + if o != nil && !IsNil(o.TimeoutSeconds) { + return true + } + + return false +} + +// SetTimeoutSeconds gets a reference to the given float64 and assigns it to the TimeoutSeconds field. +func (o *VideoObjectDetectorClaimRequest) SetTimeoutSeconds(v float64) { + o.TimeoutSeconds = &v +} + +// GetUntil returns the Until field value if set, zero value otherwise. +func (o *VideoObjectDetectorClaimRequest) GetUntil() time.Time { + if o == nil || IsNil(o.Until) { + var ret time.Time + return ret + } + return *o.Until +} + +// GetUntilOk returns a tuple with the Until field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VideoObjectDetectorClaimRequest) GetUntilOk() (*time.Time, bool) { + if o == nil || IsNil(o.Until) { + return nil, false + } + return o.Until, true +} + +// HasUntil returns a boolean if a field has been set. +func (o *VideoObjectDetectorClaimRequest) HasUntil() bool { + if o != nil && !IsNil(o.Until) { + return true + } + + return false +} + +// SetUntil gets a reference to the given time.Time and assigns it to the Until field. +func (o *VideoObjectDetectorClaimRequest) SetUntil(v time.Time) { + o.Until = &v +} + +func (o VideoObjectDetectorClaimRequest) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o VideoObjectDetectorClaimRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.TimeoutSeconds) { + toSerialize["timeout_seconds"] = o.TimeoutSeconds + } + if !IsNil(o.Until) { + toSerialize["until"] = o.Until + } + return toSerialize, nil +} + +type NullableVideoObjectDetectorClaimRequest struct { + value *VideoObjectDetectorClaimRequest + isSet bool +} + +func (v NullableVideoObjectDetectorClaimRequest) Get() *VideoObjectDetectorClaimRequest { + return v.value +} + +func (v *NullableVideoObjectDetectorClaimRequest) Set(val *VideoObjectDetectorClaimRequest) { + v.value = val + v.isSet = true +} + +func (v NullableVideoObjectDetectorClaimRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableVideoObjectDetectorClaimRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVideoObjectDetectorClaimRequest(val *VideoObjectDetectorClaimRequest) *NullableVideoObjectDetectorClaimRequest { + return &NullableVideoObjectDetectorClaimRequest{value: val, isSet: true} +} + +func (v NullableVideoObjectDetectorClaimRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVideoObjectDetectorClaimRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/api_client/model_video_object_tracker_claim_request.go b/pkg/api_client/model_video_object_tracker_claim_request.go new file mode 100644 index 0000000..66444cc --- /dev/null +++ b/pkg/api_client/model_video_object_tracker_claim_request.go @@ -0,0 +1,163 @@ +/* +Djangolang + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api_client + +import ( + "encoding/json" + "time" +) + +// checks if the VideoObjectTrackerClaimRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VideoObjectTrackerClaimRequest{} + +// VideoObjectTrackerClaimRequest struct for VideoObjectTrackerClaimRequest +type VideoObjectTrackerClaimRequest struct { + TimeoutSeconds *float64 `json:"timeout_seconds,omitempty"` + Until *time.Time `json:"until,omitempty"` +} + +// NewVideoObjectTrackerClaimRequest instantiates a new VideoObjectTrackerClaimRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewVideoObjectTrackerClaimRequest() *VideoObjectTrackerClaimRequest { + this := VideoObjectTrackerClaimRequest{} + return &this +} + +// NewVideoObjectTrackerClaimRequestWithDefaults instantiates a new VideoObjectTrackerClaimRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewVideoObjectTrackerClaimRequestWithDefaults() *VideoObjectTrackerClaimRequest { + this := VideoObjectTrackerClaimRequest{} + return &this +} + +// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise. +func (o *VideoObjectTrackerClaimRequest) GetTimeoutSeconds() float64 { + if o == nil || IsNil(o.TimeoutSeconds) { + var ret float64 + return ret + } + return *o.TimeoutSeconds +} + +// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VideoObjectTrackerClaimRequest) GetTimeoutSecondsOk() (*float64, bool) { + if o == nil || IsNil(o.TimeoutSeconds) { + return nil, false + } + return o.TimeoutSeconds, true +} + +// HasTimeoutSeconds returns a boolean if a field has been set. +func (o *VideoObjectTrackerClaimRequest) HasTimeoutSeconds() bool { + if o != nil && !IsNil(o.TimeoutSeconds) { + return true + } + + return false +} + +// SetTimeoutSeconds gets a reference to the given float64 and assigns it to the TimeoutSeconds field. +func (o *VideoObjectTrackerClaimRequest) SetTimeoutSeconds(v float64) { + o.TimeoutSeconds = &v +} + +// GetUntil returns the Until field value if set, zero value otherwise. +func (o *VideoObjectTrackerClaimRequest) GetUntil() time.Time { + if o == nil || IsNil(o.Until) { + var ret time.Time + return ret + } + return *o.Until +} + +// GetUntilOk returns a tuple with the Until field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VideoObjectTrackerClaimRequest) GetUntilOk() (*time.Time, bool) { + if o == nil || IsNil(o.Until) { + return nil, false + } + return o.Until, true +} + +// HasUntil returns a boolean if a field has been set. +func (o *VideoObjectTrackerClaimRequest) HasUntil() bool { + if o != nil && !IsNil(o.Until) { + return true + } + + return false +} + +// SetUntil gets a reference to the given time.Time and assigns it to the Until field. +func (o *VideoObjectTrackerClaimRequest) SetUntil(v time.Time) { + o.Until = &v +} + +func (o VideoObjectTrackerClaimRequest) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o VideoObjectTrackerClaimRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.TimeoutSeconds) { + toSerialize["timeout_seconds"] = o.TimeoutSeconds + } + if !IsNil(o.Until) { + toSerialize["until"] = o.Until + } + return toSerialize, nil +} + +type NullableVideoObjectTrackerClaimRequest struct { + value *VideoObjectTrackerClaimRequest + isSet bool +} + +func (v NullableVideoObjectTrackerClaimRequest) Get() *VideoObjectTrackerClaimRequest { + return v.value +} + +func (v *NullableVideoObjectTrackerClaimRequest) Set(val *VideoObjectTrackerClaimRequest) { + v.value = val + v.isSet = true +} + +func (v NullableVideoObjectTrackerClaimRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableVideoObjectTrackerClaimRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVideoObjectTrackerClaimRequest(val *VideoObjectTrackerClaimRequest) *NullableVideoObjectTrackerClaimRequest { + return &NullableVideoObjectTrackerClaimRequest{value: val, isSet: true} +} + +func (v NullableVideoObjectTrackerClaimRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVideoObjectTrackerClaimRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/api_client/test/api_camera_test.go b/pkg/api_client/test/api_camera_test.go index 104479f..3aa524b 100644 --- a/pkg/api_client/test/api_camera_test.go +++ b/pkg/api_client/test/api_camera_test.go @@ -87,4 +87,32 @@ func Test_api_client_CameraAPIService(t *testing.T) { }) + t.Run("Test CameraAPIService PostCamerasSegmentProducerClaim", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var primaryKey string + + resp, httpRes, err := apiClient.CameraAPI.PostCamerasSegmentProducerClaim(context.Background(), primaryKey).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test CameraAPIService PostCamerasStreamProducerClaim", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var primaryKey string + + resp, httpRes, err := apiClient.CameraAPI.PostCamerasStreamProducerClaim(context.Background(), primaryKey).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + } diff --git a/pkg/api_client/test/api_object_detector_claim_video_test.go b/pkg/api_client/test/api_object_detector_claim_video_test.go new file mode 100644 index 0000000..f9aff0b --- /dev/null +++ b/pkg/api_client/test/api_object_detector_claim_video_test.go @@ -0,0 +1,37 @@ +/* +Djangolang + +Testing ObjectDetectorClaimVideoAPIService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package api_client + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func Test_api_client_ObjectDetectorClaimVideoAPIService(t *testing.T) { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + t.Run("Test ObjectDetectorClaimVideoAPIService PostObjectDetectorClaimVideos", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + resp, httpRes, err := apiClient.ObjectDetectorClaimVideoAPI.PostObjectDetectorClaimVideos(context.Background()).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + +} diff --git a/pkg/api_client/test/api_custom_test.go b/pkg/api_client/test/api_object_tracker_claim_video_test.go similarity index 61% rename from pkg/api_client/test/api_custom_test.go rename to pkg/api_client/test/api_object_tracker_claim_video_test.go index e3a3d7e..92261ea 100644 --- a/pkg/api_client/test/api_custom_test.go +++ b/pkg/api_client/test/api_object_tracker_claim_video_test.go @@ -1,7 +1,7 @@ /* Djangolang -Testing CustomAPIService +Testing ObjectTrackerClaimVideoAPIService */ @@ -17,16 +17,16 @@ import ( openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" ) -func Test_api_client_CustomAPIService(t *testing.T) { +func Test_api_client_ObjectTrackerClaimVideoAPIService(t *testing.T) { configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - t.Run("Test CustomAPIService PatchCustomClaimVideoForObjectDetector", func(t *testing.T) { + t.Run("Test ObjectTrackerClaimVideoAPIService PostObjectTrackerClaimVideos", func(t *testing.T) { t.Skip("skip test") // remove to run test - resp, httpRes, err := apiClient.CustomAPI.PatchCustomClaimVideoForObjectDetector(context.Background()).Execute() + resp, httpRes, err := apiClient.ObjectTrackerClaimVideoAPI.PostObjectTrackerClaimVideos(context.Background()).Execute() require.Nil(t, err) require.NotNil(t, resp) diff --git a/pkg/api_client/test/api_segment_producer_claim_camera_test.go b/pkg/api_client/test/api_segment_producer_claim_camera_test.go new file mode 100644 index 0000000..e105db2 --- /dev/null +++ b/pkg/api_client/test/api_segment_producer_claim_camera_test.go @@ -0,0 +1,37 @@ +/* +Djangolang + +Testing SegmentProducerClaimCameraAPIService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package api_client + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func Test_api_client_SegmentProducerClaimCameraAPIService(t *testing.T) { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + t.Run("Test SegmentProducerClaimCameraAPIService PostSegmentProducerClaimCameras", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + resp, httpRes, err := apiClient.SegmentProducerClaimCameraAPI.PostSegmentProducerClaimCameras(context.Background()).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + +} diff --git a/pkg/api_client/test/api_stream_producer_claim_camera_test.go b/pkg/api_client/test/api_stream_producer_claim_camera_test.go new file mode 100644 index 0000000..5eb42e9 --- /dev/null +++ b/pkg/api_client/test/api_stream_producer_claim_camera_test.go @@ -0,0 +1,37 @@ +/* +Djangolang + +Testing StreamProducerClaimCameraAPIService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package api_client + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" + openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID" +) + +func Test_api_client_StreamProducerClaimCameraAPIService(t *testing.T) { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + t.Run("Test StreamProducerClaimCameraAPIService PostStreamProducerClaimCameras", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + resp, httpRes, err := apiClient.StreamProducerClaimCameraAPI.PostStreamProducerClaimCameras(context.Background()).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + +} diff --git a/pkg/api_client/test/api_video_test.go b/pkg/api_client/test/api_video_test.go index dd3079c..1cb10a8 100644 --- a/pkg/api_client/test/api_video_test.go +++ b/pkg/api_client/test/api_video_test.go @@ -87,4 +87,32 @@ func Test_api_client_VideoAPIService(t *testing.T) { }) + t.Run("Test VideoAPIService PostVideosObjectDetectorClaim", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var primaryKey string + + resp, httpRes, err := apiClient.VideoAPI.PostVideosObjectDetectorClaim(context.Background(), primaryKey).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test VideoAPIService PostVideosObjectTrackerClaim", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var primaryKey string + + resp, httpRes, err := apiClient.VideoAPI.PostVideosObjectTrackerClaim(context.Background(), primaryKey).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + } diff --git a/schema/openapi.json b/schema/openapi.json index 854fb3d..b0f0d26 100644 --- a/schema/openapi.json +++ b/schema/openapi.json @@ -112,12 +112,29 @@ } } }, - "ClaimRequest": { + "CameraSegmentProducerClaimRequest": { "type": "object", "properties": { - "claim_duration_seconds": { + "timeout_seconds": { "type": "number", "format": "double" + }, + "until": { + "type": "string", + "format": "date-time" + } + } + }, + "CameraStreamProducerClaimRequest": { + "type": "object", + "properties": { + "timeout_seconds": { + "type": "number", + "format": "double" + }, + "until": { + "type": "string", + "format": "date-time" } } }, @@ -429,6 +446,32 @@ "format": "date-time" } } + }, + "VideoObjectDetectorClaimRequest": { + "type": "object", + "properties": { + "timeout_seconds": { + "type": "number", + "format": "double" + }, + "until": { + "type": "string", + "format": "date-time" + } + } + }, + "VideoObjectTrackerClaimRequest": { + "type": "object", + "properties": { + "timeout_seconds": { + "type": "number", + "format": "double" + }, + "until": { + "type": "string", + "format": "date-time" + } + } } } }, @@ -2256,17 +2299,39 @@ } } }, - "/api/custom/claim-video-for-object-detector": { - "patch": { + "/api/cameras/{primaryKey}/segment-producer-claim": { + "post": { "tags": [ - "Custom" + "Camera" + ], + "operationId": "PostCamerasSegmentProducerClaim", + "parameters": [ + { + "name": "primaryKey", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "Path parameter primaryKey" + }, + { + "name": "depth", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + }, + "description": "Query parameter depth" + } ], - "operationId": "PatchCustomClaimVideoForObjectDetector", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ClaimRequest" + "$ref": "#/components/schemas/CameraSegmentProducerClaimRequest" } } }, @@ -2274,17 +2339,99 @@ }, "responses": { "200": { - "description": "PatchCustomClaimVideoForObjectDetector success", + "description": "PostCamerasSegmentProducerClaim success", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NullableVideo" + "$ref": "#/components/schemas/ResponseWithGenericOfCamera" } } } }, "default": { - "description": "PatchCustomClaimVideoForObjectDetector failure", + "description": "PostCamerasSegmentProducerClaim failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, + "/api/cameras/{primaryKey}/stream-producer-claim": { + "post": { + "tags": [ + "Camera" + ], + "operationId": "PostCamerasStreamProducerClaim", + "parameters": [ + { + "name": "primaryKey", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "Path parameter primaryKey" + }, + { + "name": "depth", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + }, + "description": "Query parameter depth" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CameraStreamProducerClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostCamerasStreamProducerClaim success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfCamera" + } + } + } + }, + "default": { + "description": "PostCamerasStreamProducerClaim failure", "content": { "application/json": { "schema": { @@ -4303,6 +4450,246 @@ } } }, + "/api/object-detector-claim-video": { + "post": { + "tags": [ + "ObjectDetectorClaimVideo" + ], + "operationId": "PostObjectDetectorClaimVideos", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VideoObjectDetectorClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostObjectDetectorClaimVideos success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfVideo" + } + } + } + }, + "default": { + "description": "PostObjectDetectorClaimVideos failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, + "/api/object-tracker-claim-video": { + "post": { + "tags": [ + "ObjectTrackerClaimVideo" + ], + "operationId": "PostObjectTrackerClaimVideos", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VideoObjectTrackerClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostObjectTrackerClaimVideos success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfVideo" + } + } + } + }, + "default": { + "description": "PostObjectTrackerClaimVideos failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, + "/api/segment-producer-claim-camera": { + "post": { + "tags": [ + "SegmentProducerClaimCamera" + ], + "operationId": "PostSegmentProducerClaimCameras", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CameraSegmentProducerClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostSegmentProducerClaimCameras success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfCamera" + } + } + } + }, + "default": { + "description": "PostSegmentProducerClaimCameras failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, + "/api/stream-producer-claim-camera": { + "post": { + "tags": [ + "StreamProducerClaimCamera" + ], + "operationId": "PostStreamProducerClaimCameras", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CameraStreamProducerClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostStreamProducerClaimCameras success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfCamera" + } + } + } + }, + "default": { + "description": "PostStreamProducerClaimCameras failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, "/api/videos": { "get": { "tags": [ @@ -6857,6 +7244,170 @@ } } } + }, + "/api/videos/{primaryKey}/object-detector-claim": { + "post": { + "tags": [ + "Video" + ], + "operationId": "PostVideosObjectDetectorClaim", + "parameters": [ + { + "name": "primaryKey", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "Path parameter primaryKey" + }, + { + "name": "depth", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + }, + "description": "Query parameter depth" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VideoObjectDetectorClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostVideosObjectDetectorClaim success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfVideo" + } + } + } + }, + "default": { + "description": "PostVideosObjectDetectorClaim failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } + }, + "/api/videos/{primaryKey}/object-tracker-claim": { + "post": { + "tags": [ + "Video" + ], + "operationId": "PostVideosObjectTrackerClaim", + "parameters": [ + { + "name": "primaryKey", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + }, + "description": "Path parameter primaryKey" + }, + { + "name": "depth", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + }, + "description": "Query parameter depth" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VideoObjectTrackerClaimRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "PostVideosObjectTrackerClaim success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseWithGenericOfVideo" + } + } + } + }, + "default": { + "description": "PostVideosObjectTrackerClaim failure", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "array", + "items": { + "type": "string" + } + }, + "status": { + "type": "integer", + "format": "int32" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "status", + "success", + "error" + ] + } + } + } + } + } + } } } } \ No newline at end of file