diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 519dc34..c00fb84 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 17bba98d-ccbf-4675-8dd5-54aa47cbeeb4 management: - docChecksum: b110a3e16ac8c9cb846f38dff07c5874 + docChecksum: 61af080eec2ebd33f126aba1a0e7a45d docVersion: 1.0.0 - speakeasyVersion: 1.399.0 - generationVersion: 2.415.8 - releaseVersion: 0.4.0 - configChecksum: 045305673b918fe7ce55aa6c4e22d669 + speakeasyVersion: 1.460.3 + generationVersion: 2.484.0 + releaseVersion: 0.5.0 + configChecksum: c20140ffdc777aa1960a42b8c536e9a5 repoURL: https://github.com/livepeer/livepeer-go.git installationURL: https://github.com/livepeer/livepeer-go features: @@ -14,10 +14,10 @@ features: additionalDependencies: 0.1.0 additionalProperties: 0.1.2 constsAndDefaults: 0.1.6 - core: 3.5.8 + core: 3.6.2 defaultEnabledRetries: 0.2.0 deprecations: 2.81.1 - envVarSecurityUsage: 0.3.1 + envVarSecurityUsage: 0.3.2 errorUnions: 0.1.0 flattening: 2.81.1 globalSecurity: 2.82.10 @@ -29,9 +29,9 @@ features: nameOverrides: 2.81.2 nullables: 0.1.0 responseFormat: 0.1.2 - retries: 2.83.0 + retries: 2.83.1 sdkHooks: 0.1.0 - unions: 2.85.9 + unions: 2.85.10 uploadStreams: 0.1.0 generatedFiles: - .gitattributes @@ -42,6 +42,7 @@ generatedFiles: - /models/components/bodygenaudiototext.go - /models/components/bodygenimagetoimage.go - /models/components/bodygenimagetovideo.go + - /models/components/bodygenllm.go - /models/components/bodygensegmentanything2.go - /models/components/bodygenupscale.go - /models/components/chunk.go @@ -50,6 +51,7 @@ generatedFiles: - /models/components/creatorid.go - /models/components/encryption.go - /models/components/encryptionoutput.go + - /models/components/error.go - /models/components/exporttaskparams.go - /models/components/ffmpegprofile.go - /models/components/getroomuserresponse.go @@ -60,6 +62,7 @@ generatedFiles: - /models/components/inputcreatorid.go - /models/components/ipfsexportparams.go - /models/components/ipfsfileinfo.go + - /models/components/llmresponse.go - /models/components/masksresponse.go - /models/components/media.go - /models/components/multistream.go @@ -121,6 +124,7 @@ generatedFiles: - /models/operations/genaudiototext.go - /models/operations/genimagetoimage.go - /models/operations/genimagetovideo.go + - /models/operations/genllm.go - /models/operations/gensegmentanything2.go - /models/operations/gentexttoimage.go - /models/operations/genupscale.go @@ -170,6 +174,7 @@ generatedFiles: - /models/sdkerrors/genaudiototext.go - /models/sdkerrors/genimagetoimage.go - /models/sdkerrors/genimagetovideo.go + - /models/sdkerrors/genllm.go - /models/sdkerrors/gensegmentanything2.go - /models/sdkerrors/gentexttoimage.go - /models/sdkerrors/genupscale.go @@ -200,6 +205,7 @@ generatedFiles: - docs/models/components/bodygenimagetoimage.md - docs/models/components/bodygenimagetovideo.md - docs/models/components/bodygenimagetovideoimage.md + - docs/models/components/bodygenllm.md - docs/models/components/bodygensegmentanything2.md - docs/models/components/bodygensegmentanything2image.md - docs/models/components/bodygenupscale.md @@ -219,7 +225,9 @@ generatedFiles: - docs/models/components/domain.md - docs/models/components/dvrplayback.md - docs/models/components/encoder.md + - docs/models/components/encryption.md - docs/models/components/encryptionoutput.md + - docs/models/components/error.md - docs/models/components/events.md - docs/models/components/export.md - docs/models/components/exportdata.md @@ -252,6 +260,7 @@ generatedFiles: - docs/models/components/ismobile1.md - docs/models/components/lastfailure.md - docs/models/components/live.md + - docs/models/components/llmresponse.md - docs/models/components/loc.md - docs/models/components/location.md - docs/models/components/masksresponse.md @@ -261,6 +270,7 @@ generatedFiles: - docs/models/components/mp4.md - docs/models/components/multistream.md - docs/models/components/multistreamtarget.md + - docs/models/components/multistreamtargetinput.md - docs/models/components/multistreamtargetpatchpayload.md - docs/models/components/name.md - docs/models/components/newassetfromurlpayload.md @@ -328,6 +338,7 @@ generatedFiles: - docs/models/components/streamrecordingspec.md - docs/models/components/streamusertags.md - docs/models/components/studioapierror.md + - docs/models/components/target.md - docs/models/components/targetaddpayload.md - docs/models/components/targetaddpayloadspec.md - docs/models/components/targetoutput.md @@ -370,6 +381,7 @@ generatedFiles: - docs/models/components/videospec.md - docs/models/components/viewershipmetric.md - docs/models/components/webhook.md + - docs/models/components/webhookinput.md - docs/models/components/webhooklog.md - docs/models/operations/addmultistreamtargetrequest.md - docs/models/operations/addmultistreamtargetresponse.md @@ -402,6 +414,7 @@ generatedFiles: - docs/models/operations/genaudiototextresponse.md - docs/models/operations/genimagetoimageresponse.md - docs/models/operations/genimagetovideoresponse.md + - docs/models/operations/genllmresponse.md - docs/models/operations/gensegmentanything2response.md - docs/models/operations/gentexttoimageresponse.md - docs/models/operations/genupscaleresponse.md @@ -500,6 +513,7 @@ generatedFiles: - docs/models/operations/uploadassetresponse.md - docs/models/operations/uploadassettask.md - docs/models/sdkerrors/error.md + - docs/models/sdkerrors/genaudiototextgenerateresponse415responsebody.md - docs/models/sdkerrors/genaudiototextgenerateresponse422responsebody.md - docs/models/sdkerrors/genaudiototextgenerateresponse500responsebody.md - docs/models/sdkerrors/genaudiototextgenerateresponsebody.md @@ -513,6 +527,10 @@ generatedFiles: - docs/models/sdkerrors/genimagetovideogenerateresponsebody.md - docs/models/sdkerrors/genimagetovideogenerateresponseresponsebody.md - docs/models/sdkerrors/genimagetovideoresponsebody.md + - docs/models/sdkerrors/genllmgenerateresponse500responsebody.md + - docs/models/sdkerrors/genllmgenerateresponsebody.md + - docs/models/sdkerrors/genllmgenerateresponseresponsebody.md + - docs/models/sdkerrors/genllmresponsebody.md - docs/models/sdkerrors/gensegmentanything2generateresponse500responsebody.md - docs/models/sdkerrors/gensegmentanything2generateresponsebody.md - docs/models/sdkerrors/gensegmentanything2generateresponseresponsebody.md @@ -542,6 +560,7 @@ generatedFiles: - go.mod - internal/hooks/hooks.go - internal/utils/contenttype.go + - internal/utils/env.go - internal/utils/form.go - internal/utils/headers.go - internal/utils/json.go @@ -573,10 +592,10 @@ examples: createStream: speakeasy-default-create-stream: requestBody: - application/json: {"name": "test_stream", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p", "videoOnly": false, "id": "PUSH123", "spec": {"name": "My target", "url": "rtmps://live.my-service.tv/channel/secretKey"}}]}} + application/json: {"name": "test_stream", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p0", "id": "PUSH123"}]}} responses: "201": - application/json: {"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "name": "test_stream", "creatorId": {"type": "unverified", "value": "user123"}, "lastSeen": 1587667174725, "sourceSegments": 1, "transcodedSegments": 2, "sourceSegmentsDuration": 1, "transcodedSegmentsDuration": 2, "sourceBytes": 1, "transcodedBytes": 2, "ingestRate": 1, "outgoingRate": 2, "isActive": true, "createdByTokenName": "abc-123-xyz-456", "createdAt": 1587667174725, "parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "streamKey": "hgebdhhigq", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackId": "eaw4nk06ts2d0mzb", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p", "videoOnly": false, "id": "PUSH123"}]}, "lastTerminatedAt": 1713281212993} + application/json: {"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "name": "test_stream", "creatorId": {"type": "unverified", "value": "user123"}, "lastSeen": 1587667174725, "sourceSegments": 1, "transcodedSegments": 2, "sourceSegmentsDuration": 1, "transcodedSegmentsDuration": 2, "sourceBytes": 1, "transcodedBytes": 2, "ingestRate": 1, "outgoingRate": 2, "isActive": true, "createdByTokenName": "abc-123-xyz-456", "createdAt": 1587667174725, "parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "streamKey": "hgebdhhigq", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackId": "eaw4nk06ts2d0mzb", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p0", "id": "PUSH123"}]}, "lastTerminatedAt": 1713281212993} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} getStreams: @@ -593,7 +612,7 @@ examples: id: "" responses: "200": - application/json: {"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "name": "test_stream", "creatorId": {"type": "unverified", "value": "user123"}, "lastSeen": 1587667174725, "sourceSegments": 1, "transcodedSegments": 2, "sourceSegmentsDuration": 1, "transcodedSegmentsDuration": 2, "sourceBytes": 1, "transcodedBytes": 2, "ingestRate": 1, "outgoingRate": 2, "isActive": true, "createdByTokenName": "abc-123-xyz-456", "createdAt": 1587667174725, "parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "streamKey": "hgebdhhigq", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackId": "eaw4nk06ts2d0mzb", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p", "videoOnly": false, "id": "PUSH123"}]}, "lastTerminatedAt": 1713281212993} + application/json: {"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "name": "test_stream", "creatorId": {"type": "unverified", "value": "user123"}, "lastSeen": 1587667174725, "sourceSegments": 1, "transcodedSegments": 2, "sourceSegmentsDuration": 1, "transcodedSegmentsDuration": 2, "sourceBytes": 1, "transcodedBytes": 2, "ingestRate": 1, "outgoingRate": 2, "isActive": true, "createdByTokenName": "abc-123-xyz-456", "createdAt": 1587667174725, "parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88", "streamKey": "hgebdhhigq", "pull": {"source": "https://myservice.com/live/stream.flv", "headers": {"Authorization": "Bearer 123"}, "location": {"lat": 39.739, "lon": -104.988}}, "playbackId": "eaw4nk06ts2d0mzb", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "record": false, "recordingSpec": {"profiles": []}, "multistream": {"targets": [{"profile": "720p0", "id": "PUSH123"}]}, "lastTerminatedAt": 1713281212993} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} updateStream: @@ -602,7 +621,7 @@ examples: path: id: "" requestBody: - application/json: {"record": false, "multistream": {"targets": [{"profile": "720p", "videoOnly": false, "id": "PUSH123", "spec": {"name": "My target", "url": "rtmps://live.my-service.tv/channel/secretKey"}}]}, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "recordingSpec": {"profiles": []}} + application/json: {"record": false, "multistream": {"targets": [{"profile": "720p0", "id": "PUSH123"}]}, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": [], "recordingSpec": {"profiles": []}} responses: default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} @@ -636,7 +655,7 @@ examples: application/json: {"playbackId": "eaw4nk06ts2d0mzb", "startTime": 1587667174725, "endTime": 1587667174725, "name": "My Clip", "sessionId": "de7818e7-610a-4057-8f6f-b785dc1e6f88"} responses: "200": - application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "failed", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} + application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "failed", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} getClips: @@ -805,7 +824,7 @@ examples: application/json: {"name": "filename.mp4", "staticMp4": true, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "profiles": []} responses: "200": - application/json: {"url": "https://origin.livepeer.com/api/asset/upload/direct?token=eyJhbGciOiJIUzI1NiJ9.eyJtc2ciOiJoZWxsbyBoYWNrZXIsIHRoZXJlJ3Mgbm90aGluZyBmb3IgeW91IGhlcmUg8J-YhiJ9.1YDjmXsqLcgNyMSzT4kXl_kIni46_EuGX_xfqmC7e0Q", "tusEndpoint": "https://origin.livepeer.com/api/asset/upload/tus?token=eyJhbGciOiJIUzI1NiJ9.eyJtc2ciOiJoZWxsbyBoYWNrZXIsIHRoZXJlJ3Mgbm90aGluZyBmb3IgeW91IGhlcmUg8J-YhiJ9.1YDjmXsqLcgNyMSzT4kXl_kIni46_EuGX_xfqmC7e0Q", "asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "recording", "sessionId": ""}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "ready", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} + application/json: {"url": "https://origin.livepeer.com/api/asset/upload/direct?token=eyJhbGciOiJIUzI1NiJ9.eyJtc2ciOiJoZWxsbyBoYWNrZXIsIHRoZXJlJ3Mgbm90aGluZyBmb3IgeW91IGhlcmUg8J-YhiJ9.1YDjmXsqLcgNyMSzT4kXl_kIni46_EuGX_xfqmC7e0Q", "tusEndpoint": "https://origin.livepeer.com/api/asset/upload/tus?token=eyJhbGciOiJIUzI1NiJ9.eyJtc2ciOiJoZWxsbyBoYWNrZXIsIHRoZXJlJ3Mgbm90aGluZyBmb3IgeW91IGhlcmUg8J-YhiJ9.1YDjmXsqLcgNyMSzT4kXl_kIni46_EuGX_xfqmC7e0Q", "asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "recording", "sessionId": ""}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "ready", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} uploadAsset: @@ -814,9 +833,9 @@ examples: application/json: {"name": "filename.mp4", "staticMp4": true, "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "url": "https://s3.amazonaws.com/my-bucket/path/filename.mp4", "profiles": []} responses: "200": - application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "recording", "sessionId": ""}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "waiting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} + application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "recording", "sessionId": ""}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "waiting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} "201": - application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "url", "url": "http://dutiful-colorlessness.com"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "uploading", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} + application/json: {"asset": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "url", "url": "http://dutiful-colorlessness.com"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "uploading", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "task": {"id": "34d7618e-fd42-4798-acf5-19504616a11e"}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} getAsset: @@ -826,7 +845,7 @@ examples: assetId: "" responses: "200": - application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "ready", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}} + application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "ready", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} updateAsset: @@ -838,7 +857,7 @@ examples: application/json: {"name": "filename.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}} responses: "200": - application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "failed", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}} + application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "directUpload"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "failed", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} deleteAsset: @@ -1066,14 +1085,14 @@ examples: taskId: "" responses: "200": - application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "upload", "createdAt": 1587667174725, "scheduledAt": 1587667174725, "inputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "outputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "projectId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "requesterId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "params": {"upload": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4", "c2pa": true, "profiles": [], "targetSegmentSizeSecs": 6}, "export": {"ipfs": {}}, "exportData": {"ipfs": {"pinata": {"apiKey": "1234567890"}}, "type": "text/plain", "id": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}, "transcode-file": {"input": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4"}, "storage": {"url": "s3+https://accessKeyId:secretAccessKey@s3Endpoint/bucket"}, "outputs": {"hls": {"path": "/samplevideo/hls"}, "mp4": {"path": "/samplevideo/mp4"}}, "profiles": [], "targetSegmentSizeSecs": 10, "c2pa": false}, "clip": {"url": "https://asset-cdn.lp-playback.monster/hls/1bde4o2i6xycudoy/static360p0.mp4", "clipStrategy": {"startTime": 1587667174725, "endTime": 1587667174725, "playbackId": "eaw4nk06ts2d0mzb"}, "catalystPipelineStrategy": "catalyst_ffmpeg", "sessionId": "d32ae9e6-c459-4931-9898-e86e2f5e7e16", "inputId": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}, "status": {"phase": "pending", "updatedAt": 1587667174725, "progress": 0.5, "errorMessage": "Failed to upload file", "retries": 3}, "output": {"upload": {"assetSpec": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "clip"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "deleting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "key": "", "key1": ""}, "export": {"ipfs": {"videoFileCid": "Qmabc123xyz341", "videoFileUrl": "ipfs://Qmabc123xyz341", "videoFileGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341", "nftMetadataCid": "Qmabc123xyz341", "nftMetadataUrl": "ipfs://Qmabc123xyz341", "nftMetadataGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341"}}, "exportData": {"ipfs": {"cid": "Qmabc123xyz341"}}}} + application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "upload", "createdAt": 1587667174725, "scheduledAt": 1587667174725, "inputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "outputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "projectId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "requesterId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "params": {"upload": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4", "c2pa": true, "profiles": [], "targetSegmentSizeSecs": 6}, "export": {"ipfs": {"pinata": {"apiKey": "1234567890"}}}, "exportData": {"ipfs": {"pinata": {"apiKey": "1234567890"}}, "type": "text/plain", "id": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}, "transcode-file": {"input": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4"}, "storage": {"url": "s3+https://accessKeyId:secretAccessKey@s3Endpoint/bucket"}, "outputs": {"hls": {"path": "/samplevideo/hls"}, "mp4": {"path": "/samplevideo/mp4"}}, "profiles": [], "targetSegmentSizeSecs": 10, "c2pa": false}, "clip": {"url": "https://asset-cdn.lp-playback.monster/hls/1bde4o2i6xycudoy/static360p0.mp4", "clipStrategy": {"startTime": 1587667174725, "endTime": 1587667174725, "playbackId": "eaw4nk06ts2d0mzb"}, "catalystPipelineStrategy": "catalyst_ffmpeg", "sessionId": "d32ae9e6-c459-4931-9898-e86e2f5e7e16", "inputId": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}, "status": {"phase": "pending", "updatedAt": 1587667174725, "progress": 0.5, "errorMessage": "Failed to upload file", "retries": 3}, "output": {"upload": {"assetSpec": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "clip"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "deleting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "key": "", "key1": ""}, "export": {"ipfs": {"videoFileCid": "Qmabc123xyz341", "videoFileUrl": "ipfs://Qmabc123xyz341", "videoFileGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341", "nftMetadataCid": "Qmabc123xyz341", "nftMetadataUrl": "ipfs://Qmabc123xyz341", "nftMetadataGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341"}}, "exportData": {"ipfs": {"cid": "Qmabc123xyz341"}}}} transcodeVideo: speakeasy-default-transcode-video: requestBody: application/json: {"input": {"url": "https://s3.amazonaws.com/bucket/file.mp4"}, "storage": {"type": "s3", "endpoint": "https://gateway.storjshare.io", "bucket": "outputbucket", "credentials": {"accessKeyId": "AKIAIOSFODNN7EXAMPLE", "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"}}, "outputs": {"hls": {"path": "/samplevideo/hls"}, "mp4": {"path": "/samplevideo/mp4"}, "fmp4": {"path": "/samplevideo/fmp4"}}, "profiles": []} responses: "200": - application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "upload", "createdAt": 1587667174725, "scheduledAt": 1587667174725, "inputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "outputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "projectId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "requesterId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "params": {"upload": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4", "c2pa": true, "profiles": [], "targetSegmentSizeSecs": 6}, "export": {"ipfs": {"pinata": {"apiKey": "1234567890"}}}, "exportData": {"ipfs": {}, "type": "text/plain", "id": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}, "transcode-file": {"input": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4"}, "storage": {"url": "s3+https://accessKeyId:secretAccessKey@s3Endpoint/bucket"}, "outputs": {"hls": {"path": "/samplevideo/hls"}, "mp4": {"path": "/samplevideo/mp4"}}, "profiles": [], "targetSegmentSizeSecs": 10, "c2pa": false}, "clip": {"url": "https://asset-cdn.lp-playback.monster/hls/1bde4o2i6xycudoy/static360p0.mp4", "clipStrategy": {"startTime": 1587667174725, "endTime": 1587667174725, "playbackId": "eaw4nk06ts2d0mzb"}, "catalystPipelineStrategy": "catalyst_ffmpeg", "sessionId": "d32ae9e6-c459-4931-9898-e86e2f5e7e16", "inputId": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}, "status": {"phase": "pending", "updatedAt": 1587667174725, "progress": 0.5, "errorMessage": "Failed to upload file", "retries": 3}, "output": {"upload": {"assetSpec": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "url", "url": "http://speedy-basil.org"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "deleting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "key": ""}, "export": {"ipfs": {"videoFileCid": "Qmabc123xyz341", "videoFileUrl": "ipfs://Qmabc123xyz341", "videoFileGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341", "nftMetadataCid": "Qmabc123xyz341", "nftMetadataUrl": "ipfs://Qmabc123xyz341", "nftMetadataGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341"}}, "exportData": {"ipfs": {"cid": "Qmabc123xyz341"}}}} + application/json: {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "upload", "createdAt": 1587667174725, "scheduledAt": 1587667174725, "inputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "outputAssetId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "projectId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "requesterId": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "params": {"upload": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4", "c2pa": true, "profiles": [], "targetSegmentSizeSecs": 6}, "export": {"ipfs": {"pinata": {"apiKey": "1234567890"}}}, "exportData": {"ipfs": {}, "type": "text/plain", "id": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}, "transcode-file": {"input": {"url": "https://cdn.livepeer.com/ABC123/filename.mp4"}, "storage": {"url": "s3+https://accessKeyId:secretAccessKey@s3Endpoint/bucket"}, "outputs": {"hls": {"path": "/samplevideo/hls"}, "mp4": {"path": "/samplevideo/mp4"}}, "profiles": [], "targetSegmentSizeSecs": 10, "c2pa": false}, "clip": {"url": "https://asset-cdn.lp-playback.monster/hls/1bde4o2i6xycudoy/static360p0.mp4", "clipStrategy": {"startTime": 1587667174725, "endTime": 1587667174725, "playbackId": "eaw4nk06ts2d0mzb"}, "catalystPipelineStrategy": "catalyst_ffmpeg", "sessionId": "d32ae9e6-c459-4931-9898-e86e2f5e7e16", "inputId": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}, "status": {"phase": "pending", "updatedAt": 1587667174725, "progress": 0.5, "errorMessage": "Failed to upload file", "retries": 3}, "output": {"upload": {"assetSpec": {"id": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "type": "video", "playbackId": "eaw4nk06ts2d0mzb", "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8", "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4", "playbackPolicy": {"type": "webhook", "webhookId": "1bde4o2i6xycudoy", "webhookContext": {"streamerId": "my-custom-id"}, "refreshInterval": 600}, "source": {"type": "url", "url": "http://speedy-basil.org"}, "creatorId": {"type": "unverified", "value": "user123"}, "profiles": [], "storage": {"ipfs": {"updatedAt": 1587667174725}, "status": {"phase": "ready", "progress": 0.5, "errorMessage": "Failed to update storage", "tasks": {"pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7", "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"}}}, "status": {"phase": "deleting", "updatedAt": 1587667174725}, "name": "filename.mp4", "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", "createdAt": 1587667174725, "size": 84934509, "hash": [], "videoSpec": {"format": "mp4", "duration": 23.8328, "bitrate": 1000000, "tracks": []}}, "key": ""}, "export": {"ipfs": {"videoFileCid": "Qmabc123xyz341", "videoFileUrl": "ipfs://Qmabc123xyz341", "videoFileGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341", "nftMetadataCid": "Qmabc123xyz341", "nftMetadataUrl": "ipfs://Qmabc123xyz341", "nftMetadataGatewayUrl": "https://gateway.ipfs.io/ipfs/Qmabc123xyz341"}}, "exportData": {"ipfs": {"cid": "Qmabc123xyz341"}}}} default: application/json: {"errors": ["[\"id not provided\",\"Account not found\"]"]} getPlaybackInfo: @@ -1097,10 +1116,14 @@ examples: application/json: {"images": []} "400": application/json: {"detail": {"msg": ""}} - "401": {} - "422": {} - "500": {} - default: {} + "401": + application/json: {"detail": {"msg": ""}} + "422": + application/json: {} + "500": + application/json: {"detail": {"msg": ""}} + default: + application/json: {} genImageToImage: speakeasy-default-gen-image-to-image: requestBody: @@ -1112,10 +1135,12 @@ examples: application/json: {"detail": {"msg": ""}} "401": application/json: {"detail": {"msg": ""}} - "422": {} + "422": + application/json: {} "500": application/json: {"detail": {"msg": ""}} - default: {} + default: + application/json: {} genImageToVideo: speakeasy-default-gen-image-to-video: requestBody: @@ -1127,9 +1152,12 @@ examples: application/json: {"detail": {"msg": ""}} "401": application/json: {"detail": {"msg": ""}} - "422": {} - "500": {} - default: {} + "422": + application/json: {} + "500": + application/json: {"detail": {"msg": ""}} + default: + application/json: {} genUpscale: speakeasy-default-gen-upscale: requestBody: @@ -1139,11 +1167,14 @@ examples: application/json: {"images": []} "400": application/json: {"detail": {"msg": ""}} - "401": {} - "422": {} + "401": + application/json: {"detail": {"msg": ""}} + "422": + application/json: {} "500": application/json: {"detail": {"msg": ""}} - default: {} + default: + application/json: {} genAudioToText: speakeasy-default-gen-audio-to-text: requestBody: @@ -1151,14 +1182,20 @@ examples: responses: "200": application/json: {"text": "", "chunks": []} - "400": {} + "400": + application/json: {} "401": application/json: {"detail": {"msg": ""}} - "413": {} - "422": {} + "413": + application/json: {} + "422": + application/json: {} "500": application/json: {"detail": {"msg": ""}} - default: {} + default: + application/json: {} + "415": + application/json: {"detail": {"msg": ""}} genSegmentAnything2: speakeasy-default-gen-segment-anything2: requestBody: @@ -1166,10 +1203,31 @@ examples: responses: "200": application/json: {"masks": "", "scores": "", "logits": ""} - "400": {} + "400": + application/json: {} "401": application/json: {"detail": {"msg": ""}} - "422": {} + "422": + application/json: {} "500": application/json: {"detail": {"msg": ""}} - default: {} + default: + application/json: {} + genLLM: + speakeasy-default-gen-LLM: + requestBody: + application/x-www-form-urlencoded: {"prompt": ""} + responses: + "200": + application/json: {"response": "", "tokens_used": 60712} + "400": + application/json: {"detail": {"msg": ""}} + "401": + application/json: {} + "422": + application/json: {} + "500": + application/json: {"detail": {"msg": ""}} + default: + application/json: {} +generatedTests: {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 4eb281b..5f50611 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -11,11 +11,13 @@ generation: requestResponseComponentNamesFeb2024: true auth: oAuth2ClientCredentialsEnabled: true + oAuth2PasswordEnabled: false go: - version: 0.4.0 + version: 0.5.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true + defaultErrorName: SDKError flattenGlobalSecurity: true imports: option: openapi diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 0c9396a..1a64d37 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,18 +1,21 @@ -speakeasyVersion: 1.399.0 +speakeasyVersion: 1.460.3 sources: livepeer-studio-api: sourceNamespace: livepeer-studio-api - sourceRevisionDigest: sha256:f3ea883f13fc67e60cb167af92c3e9be9ec4fea50eacd4130a1b51d7f1cd5102 - sourceBlobDigest: sha256:a6e21f46600c0ad7fc422459cc7392d99943317b4a24fd41190670ba78a55eb8 + sourceRevisionDigest: sha256:ce18fd68ce79168af91b14123496667229658ab0d645b4886d58276d64e4565a + sourceBlobDigest: sha256:34f05da404b8cb67a833aca39b6c09d0fdfa7c7781122295f35d4fef72c6ef5c tags: - latest - - main + - speakeasy-sdk-regen-1731112098 + - 1.0.0 targets: livepeer-go: source: livepeer-studio-api sourceNamespace: livepeer-studio-api - sourceRevisionDigest: sha256:f3ea883f13fc67e60cb167af92c3e9be9ec4fea50eacd4130a1b51d7f1cd5102 - sourceBlobDigest: sha256:a6e21f46600c0ad7fc422459cc7392d99943317b4a24fd41190670ba78a55eb8 + sourceRevisionDigest: sha256:ce18fd68ce79168af91b14123496667229658ab0d645b4886d58276d64e4565a + sourceBlobDigest: sha256:34f05da404b8cb67a833aca39b6c09d0fdfa7c7781122295f35d4fef72c6ef5c + codeSamplesNamespace: livepeer-studio-api-go-code-samples + codeSamplesRevisionDigest: sha256:24734794cd95d06936364e974073b24866ab28d95c9203b3c261b31a7f97608e workflow: workflowVersion: 1.0.0 speakeasyVersion: latest @@ -31,3 +34,5 @@ workflow: source: livepeer-studio-api codeSamples: output: codeSamples.yaml + registry: + location: registry.speakeasyapi.dev/livepeer/livepeer-studio/livepeer-studio-api-go-code-samples diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 01e55ef..ea7fe80 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -15,3 +15,5 @@ targets: source: livepeer-studio-api codeSamples: output: codeSamples.yaml + registry: + location: registry.speakeasyapi.dev/livepeer/livepeer-studio/livepeer-studio-api-go-code-samples diff --git a/README.md b/README.md index 5ba1e1c..1cf81ee 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,17 @@ what they return. ## Table of Contents + +* [Livepeer Go SDK](#livepeer-go-sdk) + * [Documentation](#documentation) + * [SDK Installation](#sdk-installation) + * [SDK Example Usage](#sdk-example-usage) + * [Available Resources and Operations](#available-resources-and-operations) + * [Error Handling](#error-handling) + * [Custom HTTP Client](#custom-http-client) + * [Authentication](#authentication) + * [Retries](#retries) -* [SDK Installation](#sdk-installation) -* [SDK Example Usage](#sdk-example-usage) -* [Available Resources and Operations](#available-resources-and-operations) -* [Retries](#retries) -* [Error Handling](#error-handling) -* [Server Selection](#server-selection) -* [Custom HTTP Client](#custom-http-client) -* [Authentication](#authentication) -* [Special Types](#special-types) @@ -103,6 +104,7 @@ func main() { * [Upscale](docs/sdks/generate/README.md#upscale) - Upscale * [AudioToText](docs/sdks/generate/README.md#audiototext) - Audio To Text * [SegmentAnything2](docs/sdks/generate/README.md#segmentanything2) - Segment Anything 2 +* [Llm](docs/sdks/generate/README.md#llm) - LLM ### [Metrics](docs/sdks/metrics/README.md) @@ -184,12 +186,16 @@ func main() { ## Error Handling -Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass. +Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. -| Error Object | Status Code | Content Type | -| ------------------ | ------------------ | ------------------ | -| sdkerrors.Error | 404 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +By Default, an API error will return `sdkerrors.SDKError`. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. + +For example, the `Get` function may return the following errors: + +| Error Type | Status Code | Content Type | +| ------------------ | ----------- | ---------------- | +| sdkerrors.Error | 404 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ### Example @@ -205,11 +211,12 @@ import ( ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Playback.Get(ctx, "") if err != nil { @@ -268,9 +275,9 @@ This can be a convenient way to configure timeouts, cookies, proxies, custom hea This SDK supports the following security scheme globally: -| Name | Type | Scheme | -| ----------- | ----------- | ----------- | -| `APIKey` | http | HTTP Bearer | +| Name | Type | Scheme | +| -------- | ---- | ----------- | +| `APIKey` | http | HTTP Bearer | You can configure it using the `WithSecurity` option when initializing the SDK client instance. For example: ```go @@ -284,11 +291,12 @@ import ( ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Create(ctx, components.NewStreamPayload{ Name: "test_stream", Pull: &components.Pull{ @@ -342,13 +350,8 @@ func main() { Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, + Profile: "720p0", + ID: livepeergo.String("PUSH123"), }, }, }, @@ -364,12 +367,6 @@ func main() { ``` - -## Special Types - - - - ## Retries @@ -389,11 +386,12 @@ import ( ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Create(ctx, components.NewStreamPayload{ Name: "test_stream", Pull: &components.Pull{ @@ -447,13 +445,8 @@ func main() { Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, + Profile: "720p0", + ID: livepeergo.String("PUSH123"), }, }, }, @@ -491,6 +484,8 @@ import ( ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithRetryConfig( retry.Config{ @@ -506,7 +501,6 @@ func main() { livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Create(ctx, components.NewStreamPayload{ Name: "test_stream", Pull: &components.Pull{ @@ -560,13 +554,8 @@ func main() { Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, + Profile: "720p0", + ID: livepeergo.String("PUSH123"), }, }, }, diff --git a/RELEASES.md b/RELEASES.md index 6eefb1e..f1d539d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -108,4 +108,14 @@ Based on: ### Generated - [go v0.4.0] . ### Releases -- [Go v0.4.0] https://github.com/livepeer/livepeer-go/releases/tag/v0.4.0 - . \ No newline at end of file +- [Go v0.4.0] https://github.com/livepeer/livepeer-go/releases/tag/v0.4.0 - . + +## 2024-12-28 00:28:48 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.460.3 (2.484.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.5.0] . +### Releases +- [Go v0.5.0] https://github.com/livepeer/livepeer-go/releases/tag/v0.5.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index af39cb5..5ab392b 100644 --- a/USAGE.md +++ b/USAGE.md @@ -10,11 +10,12 @@ import ( ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Create(ctx, components.NewStreamPayload{ Name: "test_stream", Pull: &components.Pull{ @@ -68,13 +69,8 @@ func main() { Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, + Profile: "720p0", + ID: livepeergo.String("PUSH123"), }, }, }, diff --git a/accesscontrol.go b/accesscontrol.go index 58efdf9..801221f 100644 --- a/accesscontrol.go +++ b/accesscontrol.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -51,7 +50,12 @@ func (s *AccessControl) Create(ctx context.Context, opts ...operations.Option) ( } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/access-control/signing-key") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -79,6 +83,10 @@ func (s *AccessControl) Create(ctx context.Context, opts ...operations.Option) ( return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -109,7 +117,11 @@ func (s *AccessControl) Create(ctx context.Context, opts ...operations.Option) ( req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -171,21 +183,11 @@ func (s *AccessControl) Create(ctx context.Context, opts ...operations.Option) ( }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -197,42 +199,39 @@ func (s *AccessControl) Create(ctx context.Context, opts ...operations.Option) ( res.SigningKey = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -262,7 +261,12 @@ func (s *AccessControl) GetAll(ctx context.Context, opts ...operations.Option) ( } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/access-control/signing-key") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -290,6 +294,10 @@ func (s *AccessControl) GetAll(ctx context.Context, opts ...operations.Option) ( return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -320,7 +328,11 @@ func (s *AccessControl) GetAll(ctx context.Context, opts ...operations.Option) ( req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -382,21 +394,11 @@ func (s *AccessControl) GetAll(ctx context.Context, opts ...operations.Option) ( }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -408,42 +410,39 @@ func (s *AccessControl) GetAll(ctx context.Context, opts ...operations.Option) ( res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -477,7 +476,12 @@ func (s *AccessControl) Delete(ctx context.Context, keyID string, opts ...operat } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/access-control/signing-key/{keyId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -505,6 +509,10 @@ func (s *AccessControl) Delete(ctx context.Context, keyID string, opts ...operat return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -535,7 +543,11 @@ func (s *AccessControl) Delete(ctx context.Context, keyID string, opts ...operat req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -597,47 +609,35 @@ func (s *AccessControl) Delete(ctx context.Context, keyID string, opts ...operat }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -671,7 +671,12 @@ func (s *AccessControl) Get(ctx context.Context, keyID string, opts ...operation } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/access-control/signing-key/{keyId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -699,6 +704,10 @@ func (s *AccessControl) Get(ctx context.Context, keyID string, opts ...operation return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -729,7 +738,11 @@ func (s *AccessControl) Get(ctx context.Context, keyID string, opts ...operation req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -791,21 +804,11 @@ func (s *AccessControl) Get(ctx context.Context, keyID string, opts ...operation }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -817,42 +820,39 @@ func (s *AccessControl) Get(ctx context.Context, keyID string, opts ...operation res.SigningKey = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -887,7 +887,12 @@ func (s *AccessControl) Update(ctx context.Context, keyID string, requestBody op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/access-control/signing-key/{keyId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -921,6 +926,10 @@ func (s *AccessControl) Update(ctx context.Context, keyID string, requestBody op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -951,7 +960,11 @@ func (s *AccessControl) Update(ctx context.Context, keyID string, requestBody op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1013,47 +1026,35 @@ func (s *AccessControl) Update(ctx context.Context, keyID string, requestBody op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/asset.go b/asset.go index 592a1ff..49a6a8a 100644 --- a/asset.go +++ b/asset.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -49,7 +48,12 @@ func (s *Asset) GetAll(ctx context.Context, opts ...operations.Option) (*operati } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/asset") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -77,6 +81,10 @@ func (s *Asset) GetAll(ctx context.Context, opts ...operations.Option) (*operati return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -107,7 +115,11 @@ func (s *Asset) GetAll(ctx context.Context, opts ...operations.Option) (*operati req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -169,21 +181,11 @@ func (s *Asset) GetAll(ctx context.Context, opts ...operations.Option) (*operati }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -195,42 +197,39 @@ func (s *Asset) GetAll(ctx context.Context, opts ...operations.Option) (*operati res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -330,7 +329,12 @@ func (s *Asset) Create(ctx context.Context, request components.NewAssetPayload, } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/asset/request-upload") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -364,6 +368,10 @@ func (s *Asset) Create(ctx context.Context, request components.NewAssetPayload, return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -394,7 +402,11 @@ func (s *Asset) Create(ctx context.Context, request components.NewAssetPayload, req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -456,21 +468,11 @@ func (s *Asset) Create(ctx context.Context, request components.NewAssetPayload, }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -482,42 +484,39 @@ func (s *Asset) Create(ctx context.Context, request components.NewAssetPayload, res.Data = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -547,7 +546,12 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/asset/upload/url") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -581,6 +585,10 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -611,7 +619,11 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -673,21 +685,11 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -699,17 +701,16 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro res.TwoHundredApplicationJSONData = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -721,42 +722,39 @@ func (s *Asset) CreateViaURL(ctx context.Context, request components.NewAssetFro res.TwoHundredAndOneApplicationJSONData = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -790,7 +788,12 @@ func (s *Asset) Get(ctx context.Context, assetID string, opts ...operations.Opti } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/asset/{assetId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -818,6 +821,10 @@ func (s *Asset) Get(ctx context.Context, assetID string, opts ...operations.Opti return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -848,7 +855,11 @@ func (s *Asset) Get(ctx context.Context, assetID string, opts ...operations.Opti req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -910,21 +921,11 @@ func (s *Asset) Get(ctx context.Context, assetID string, opts ...operations.Opti }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -936,42 +937,39 @@ func (s *Asset) Get(ctx context.Context, assetID string, opts ...operations.Opti res.Asset = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1006,7 +1004,12 @@ func (s *Asset) Update(ctx context.Context, assetID string, assetPatchPayload co } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/asset/{assetId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1040,6 +1043,10 @@ func (s *Asset) Update(ctx context.Context, assetID string, assetPatchPayload co return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1070,7 +1077,11 @@ func (s *Asset) Update(ctx context.Context, assetID string, assetPatchPayload co req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1132,21 +1143,11 @@ func (s *Asset) Update(ctx context.Context, assetID string, assetPatchPayload co }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1158,42 +1159,39 @@ func (s *Asset) Update(ctx context.Context, assetID string, assetPatchPayload co res.Asset = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1227,7 +1225,12 @@ func (s *Asset) Delete(ctx context.Context, assetID string, opts ...operations.O } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/asset/{assetId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1255,6 +1258,10 @@ func (s *Asset) Delete(ctx context.Context, assetID string, opts ...operations.O return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1285,7 +1292,11 @@ func (s *Asset) Delete(ctx context.Context, assetID string, opts ...operations.O req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1347,47 +1358,35 @@ func (s *Asset) Delete(ctx context.Context, assetID string, opts ...operations.O }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/codeSamples.yaml b/codeSamples.yaml index 3542794..a666684 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -8,2113 +8,328 @@ actions: x-codeSamples: - lang: go label: getSigningKeys - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.AccessControl.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.AccessControl.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/access-control/signing-key"]["post"] update: x-codeSamples: - lang: go label: createSigningKey - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.AccessControl.Create(ctx) - if err != nil { - log.Fatal(err) - } - if res.SigningKey != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.AccessControl.Create(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.SigningKey != nil {\n // handle response\n }\n}" - target: $["paths"]["/access-control/signing-key/{keyId}"]["delete"] update: x-codeSamples: - lang: go label: deleteSigningKey - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.AccessControl.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.AccessControl.Delete(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/access-control/signing-key/{keyId}"]["get"] update: x-codeSamples: - lang: go label: getSigningKey - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.AccessControl.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.SigningKey != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.AccessControl.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.SigningKey != nil {\n // handle response\n }\n}" - target: $["paths"]["/access-control/signing-key/{keyId}"]["patch"] update: x-codeSamples: - lang: go label: updateSigningKey - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/operations" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.AccessControl.Update(ctx, "", operations.UpdateSigningKeyRequestBody{}) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/audio-to-text"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.AccessControl.Update(ctx, \"\", operations.UpdateSigningKeyRequestBody{})\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/audio-to-text"]["post"] update: x-codeSamples: - lang: go label: genAudioToText - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "os" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - content, fileErr := os.Open("example.file") - if fileErr != nil { - panic(fileErr) - } - - ctx := context.Background() - res, err := s.Generate.AudioToText(ctx, components.BodyGenAudioToText{ - Audio: components.Audio{ - FileName: "example.file", - Content: content, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.TextResponse != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/image-to-image"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"os\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.Generate.AudioToText(ctx, components.BodyGenAudioToText{\n Audio: components.Audio{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.TextResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/image-to-image"]["post"] update: x-codeSamples: - lang: go label: genImageToImage - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "os" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - content, fileErr := os.Open("example.file") - if fileErr != nil { - panic(fileErr) - } - - ctx := context.Background() - res, err := s.Generate.ImageToImage(ctx, components.BodyGenImageToImage{ - Prompt: "", - Image: components.Image{ - FileName: "example.file", - Content: content, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.ImageResponse != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/image-to-video"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"os\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.Generate.ImageToImage(ctx, components.BodyGenImageToImage{\n Prompt: \"\",\n Image: components.Image{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.ImageResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/image-to-video"]["post"] update: x-codeSamples: - lang: go label: genImageToVideo - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "os" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - content, fileErr := os.Open("example.file") - if fileErr != nil { - panic(fileErr) - } - - ctx := context.Background() - res, err := s.Generate.ImageToVideo(ctx, components.BodyGenImageToVideo{ - Image: components.BodyGenImageToVideoImage{ - FileName: "example.file", - Content: content, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.VideoResponse != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/segment-anything-2"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"os\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.Generate.ImageToVideo(ctx, components.BodyGenImageToVideo{\n Image: components.BodyGenImageToVideoImage{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.VideoResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/llm"]["post"] + update: + x-codeSamples: + - lang: go + label: genLLM + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Generate.Llm(ctx, components.BodyGenLLM{\n Prompt: \"\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.LLMResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/segment-anything-2"]["post"] update: x-codeSamples: - lang: go label: genSegmentAnything2 - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "os" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - content, fileErr := os.Open("example.file") - if fileErr != nil { - panic(fileErr) - } - - ctx := context.Background() - res, err := s.Generate.SegmentAnything2(ctx, components.BodyGenSegmentAnything2{ - Image: components.BodyGenSegmentAnything2Image{ - FileName: "example.file", - Content: content, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.MasksResponse != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/text-to-image"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"os\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.Generate.SegmentAnything2(ctx, components.BodyGenSegmentAnything2{\n Image: components.BodyGenSegmentAnything2Image{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.MasksResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/text-to-image"]["post"] update: x-codeSamples: - lang: go label: genTextToImage - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Generate.TextToImage(ctx, components.TextToImageParams{ - Prompt: "", - }) - if err != nil { - log.Fatal(err) - } - if res.ImageResponse != nil { - // handle response - } - } - - target: $["paths"]["/api/beta/generate/upscale"]["post"] + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Generate.TextToImage(ctx, components.TextToImageParams{\n Prompt: \"\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.ImageResponse != nil {\n // handle response\n }\n}" + - target: $["paths"]["/api/generate/upscale"]["post"] update: x-codeSamples: - lang: go label: genUpscale - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "os" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - content, fileErr := os.Open("example.file") - if fileErr != nil { - panic(fileErr) - } - - ctx := context.Background() - res, err := s.Generate.Upscale(ctx, components.BodyGenUpscale{ - Prompt: "", - Image: components.BodyGenUpscaleImage{ - FileName: "example.file", - Content: content, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.ImageResponse != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"os\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n content, fileErr := os.Open(\"example.file\")\n if fileErr != nil {\n panic(fileErr)\n }\n\n\n res, err := s.Generate.Upscale(ctx, components.BodyGenUpscale{\n Prompt: \"\",\n Image: components.BodyGenUpscaleImage{\n FileName: \"example.file\",\n Content: content,\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.ImageResponse != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset"]["get"] update: x-codeSamples: - lang: go label: getAssets - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset/request-upload"]["post"] update: x-codeSamples: - lang: go label: requestUpload - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.Create(ctx, components.NewAssetPayload{ - Name: "filename.mp4", - StaticMp4: livepeergo.Bool(true), - PlaybackPolicy: &components.PlaybackPolicy{ - Type: components.TypeWebhook, - WebhookID: livepeergo.String("1bde4o2i6xycudoy"), - WebhookContext: map[string]any{ - "streamerId": "my-custom-id", - }, - RefreshInterval: livepeergo.Float64(600), - }, - Profiles: []components.TranscodeProfile{ - components.TranscodeProfile{ - Width: livepeergo.Int64(1280), - Name: livepeergo.String("720p"), - Height: livepeergo.Int64(720), - Bitrate: 3000000, - Quality: livepeergo.Int64(23), - Fps: livepeergo.Int64(30), - FpsDen: livepeergo.Int64(1), - Gop: livepeergo.String("2"), - Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(), - Encoder: components.TranscodeProfileEncoderH264.ToPointer(), - }, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.Create(ctx, components.NewAssetPayload{\n Name: \"filename.mp4\",\n StaticMp4: livepeergo.Bool(true),\n PlaybackPolicy: &components.PlaybackPolicy{\n Type: components.TypeWebhook,\n WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n WebhookContext: map[string]any{\n \"streamerId\": \"my-custom-id\",\n },\n RefreshInterval: livepeergo.Float64(600),\n },\n Profiles: []components.TranscodeProfile{\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset/upload/url"]["post"] update: x-codeSamples: - lang: go label: uploadAsset - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.CreateViaURL(ctx, components.NewAssetFromURLPayload{ - Name: "filename.mp4", - StaticMp4: livepeergo.Bool(true), - PlaybackPolicy: &components.PlaybackPolicy{ - Type: components.TypeWebhook, - WebhookID: livepeergo.String("1bde4o2i6xycudoy"), - WebhookContext: map[string]any{ - "streamerId": "my-custom-id", - }, - RefreshInterval: livepeergo.Float64(600), - }, - URL: "https://s3.amazonaws.com/my-bucket/path/filename.mp4", - Profiles: []components.TranscodeProfile{ - components.TranscodeProfile{ - Width: livepeergo.Int64(1280), - Name: livepeergo.String("720p"), - Height: livepeergo.Int64(720), - Bitrate: 3000000, - Quality: livepeergo.Int64(23), - Fps: livepeergo.Int64(30), - FpsDen: livepeergo.Int64(1), - Gop: livepeergo.String("2"), - Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(), - Encoder: components.TranscodeProfileEncoderH264.ToPointer(), - }, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.TwoHundredApplicationJSONData != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.CreateViaURL(ctx, components.NewAssetFromURLPayload{\n Name: \"filename.mp4\",\n StaticMp4: livepeergo.Bool(true),\n PlaybackPolicy: &components.PlaybackPolicy{\n Type: components.TypeWebhook,\n WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n WebhookContext: map[string]any{\n \"streamerId\": \"my-custom-id\",\n },\n RefreshInterval: livepeergo.Float64(600),\n },\n URL: \"https://s3.amazonaws.com/my-bucket/path/filename.mp4\",\n Profiles: []components.TranscodeProfile{\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.TwoHundredApplicationJSONData != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset/{assetId}"]["delete"] update: x-codeSamples: - lang: go label: deleteAsset - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.Delete(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset/{assetId}"]["get"] update: x-codeSamples: - lang: go label: getAsset - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Asset != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Asset != nil {\n // handle response\n }\n}" - target: $["paths"]["/asset/{assetId}"]["patch"] update: x-codeSamples: - lang: go label: updateAsset - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Asset.Update(ctx, "", components.AssetPatchPayload{ - Name: livepeergo.String("filename.mp4"), - PlaybackPolicy: &components.PlaybackPolicy{ - Type: components.TypeWebhook, - WebhookID: livepeergo.String("1bde4o2i6xycudoy"), - WebhookContext: map[string]any{ - "streamerId": "my-custom-id", - }, - RefreshInterval: livepeergo.Float64(600), - }, - }) - if err != nil { - log.Fatal(err) - } - if res.Asset != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Asset.Update(ctx, \"\", components.AssetPatchPayload{\n Name: livepeergo.String(\"filename.mp4\"),\n PlaybackPolicy: &components.PlaybackPolicy{\n Type: components.TypeWebhook,\n WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n WebhookContext: map[string]any{\n \"streamerId\": \"my-custom-id\",\n },\n RefreshInterval: livepeergo.Float64(600),\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Asset != nil {\n // handle response\n }\n}" - target: $["paths"]["/clip"]["post"] update: x-codeSamples: - lang: go label: createClip - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.CreateClip(ctx, components.ClipPayload{ - PlaybackID: "eaw4nk06ts2d0mzb", - StartTime: 1587667174725, - EndTime: livepeergo.Float64(1587667174725), - Name: livepeergo.String("My Clip"), - SessionID: livepeergo.String("de7818e7-610a-4057-8f6f-b785dc1e6f88"), - }) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.CreateClip(ctx, components.ClipPayload{\n PlaybackID: \"eaw4nk06ts2d0mzb\",\n StartTime: 1587667174725,\n EndTime: livepeergo.Float64(1587667174725),\n Name: livepeergo.String(\"My Clip\"),\n SessionID: livepeergo.String(\"de7818e7-610a-4057-8f6f-b785dc1e6f88\"),\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/data/usage/query"]["get"] update: x-codeSamples: - lang: go label: getUsageMetrics - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/operations" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Metrics.GetUsage(ctx, operations.GetUsageMetricsRequest{}) - if err != nil { - log.Fatal(err) - } - if res.UsageMetric != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Metrics.GetUsage(ctx, operations.GetUsageMetricsRequest{})\n if err != nil {\n log.Fatal(err)\n }\n if res.UsageMetric != nil {\n // handle response\n }\n}" - target: $["paths"]["/data/views/now"]["get"] update: x-codeSamples: - lang: go label: getRealtimeViewershipNow - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Metrics.GetRealtimeViewership(ctx, nil, nil, nil) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Metrics.GetRealtimeViewership(ctx, nil, nil, nil)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/data/views/query"]["get"] update: x-codeSamples: - lang: go label: getViewershipMetrics - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/operations" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Metrics.GetViewership(ctx, operations.GetViewershipMetricsRequest{}) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Metrics.GetViewership(ctx, operations.GetViewershipMetricsRequest{})\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/data/views/query/creator"]["get"] update: x-codeSamples: - lang: go label: getCreatorViewershipMetrics - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/operations" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Metrics.GetCreatorViewership(ctx, operations.GetCreatorViewershipMetricsRequest{}) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Metrics.GetCreatorViewership(ctx, operations.GetCreatorViewershipMetricsRequest{})\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/data/views/query/total/{playbackId}"]["get"] update: x-codeSamples: - lang: go label: getPublicViewershipMetrics - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Metrics.GetPublicViewership(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Metrics.GetPublicViewership(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/multistream/target"]["get"] update: x-codeSamples: - lang: go label: getMultistreamTargets - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Multistream.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Multistream.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/multistream/target"]["post"] update: x-codeSamples: - lang: go label: createMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Multistream.Create(ctx, components.MultistreamTargetInput{ - URL: "rtmps://live.my-service.tv/channel/secretKey", - }) - if err != nil { - log.Fatal(err) - } - if res.MultistreamTarget != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Multistream.Create(ctx, components.MultistreamTargetInput{\n URL: \"rtmps://live.my-service.tv/channel/secretKey\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.MultistreamTarget != nil {\n // handle response\n }\n}" - target: $["paths"]["/multistream/target/{id}"]["delete"] update: x-codeSamples: - lang: go label: deleteMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Multistream.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Multistream.Delete(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/multistream/target/{id}"]["get"] update: x-codeSamples: - lang: go label: getMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Multistream.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.MultistreamTarget != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Multistream.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.MultistreamTarget != nil {\n // handle response\n }\n}" - target: $["paths"]["/multistream/target/{id}"]["patch"] update: x-codeSamples: - lang: go label: updateMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Multistream.Update(ctx, "", components.MultistreamTargetPatchPayload{ - URL: "rtmps://live.my-service.tv/channel/secretKey", - }) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Multistream.Update(ctx, \"\", components.MultistreamTargetPatchPayload{\n URL: \"rtmps://live.my-service.tv/channel/secretKey\",\n })\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/playback/{id}"]["get"] update: x-codeSamples: - lang: go label: getPlaybackInfo - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Playback.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.PlaybackInfo != nil { - // handle response - } - } - - target: $["paths"]["/room"]["post"] - update: - x-codeSamples: - - lang: go - label: createRoom - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.Create(ctx) - if err != nil { - log.Fatal(err) - } - if res.CreateRoomResponse != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}"]["delete"] - update: - x-codeSamples: - - lang: go - label: deleteRoom - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}"]["get"] - update: - x-codeSamples: - - lang: go - label: getRoom - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Room != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/egress"]["delete"] - update: - x-codeSamples: - - lang: go - label: stopRoomEgress - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.StopEgress(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/egress"]["post"] - update: - x-codeSamples: - - lang: go - label: startRoomEgress - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.StartEgress(ctx, "", components.RoomEgressPayload{ - StreamID: "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", - }) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/user"]["post"] - update: - x-codeSamples: - - lang: go - label: createRoomUser - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.CreateUser(ctx, "", components.RoomUserPayload{ - Name: "name", - CanPublish: livepeergo.Bool(true), - CanPublishData: livepeergo.Bool(true), - }) - if err != nil { - log.Fatal(err) - } - if res.RoomUserResponse != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/user/{userId}"]["delete"] - update: - x-codeSamples: - - lang: go - label: deleteRoomUser - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.DeleteUser(ctx, "", "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/user/{userId}"]["get"] - update: - x-codeSamples: - - lang: go - label: getRoomUser - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.GetUser(ctx, "", "") - if err != nil { - log.Fatal(err) - } - if res.GetRoomUserResponse != nil { - // handle response - } - } - - target: $["paths"]["/room/{id}/user/{userId}"]["put"] - update: - x-codeSamples: - - lang: go - label: updateRoomUser - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Room.UpdateUser(ctx, "", "", components.RoomUserUpdatePayload{ - CanPublish: livepeergo.Bool(true), - CanPublishData: livepeergo.Bool(true), - }) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Playback.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.PlaybackInfo != nil {\n // handle response\n }\n}" - target: $["paths"]["/session"]["get"] update: x-codeSamples: - lang: go label: getSessions - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Session.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Session.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/session/{id}"]["get"] update: x-codeSamples: - lang: go label: getSession - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Session.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Session != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Session.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Session != nil {\n // handle response\n }\n}" - target: $["paths"]["/session/{id}/clips"]["get"] update: x-codeSamples: - lang: go label: getSessionClips - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Session.GetClips(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Session.GetClips(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream"]["get"] update: x-codeSamples: - lang: go label: getStreams - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.GetAll(ctx, nil) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.GetAll(ctx, nil)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream"]["post"] update: x-codeSamples: - lang: go label: createStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.Create(ctx, components.NewStreamPayload{ - Name: "test_stream", - Pull: &components.Pull{ - Source: "https://myservice.com/live/stream.flv", - Headers: map[string]string{ - "Authorization": "Bearer 123", - }, - Location: &components.Location{ - Lat: 39.739, - Lon: -104.988, - }, - }, - PlaybackPolicy: &components.PlaybackPolicy{ - Type: components.TypeWebhook, - WebhookID: livepeergo.String("1bde4o2i6xycudoy"), - WebhookContext: map[string]any{ - "streamerId": "my-custom-id", - }, - RefreshInterval: livepeergo.Float64(600), - }, - Profiles: []components.FfmpegProfile{ - components.FfmpegProfile{ - Width: 1280, - Name: "720p", - Height: 720, - Bitrate: 3000000, - Fps: 30, - FpsDen: livepeergo.Int64(1), - Quality: livepeergo.Int64(23), - Gop: livepeergo.String("2"), - Profile: components.ProfileH264Baseline.ToPointer(), - }, - }, - Record: livepeergo.Bool(false), - RecordingSpec: &components.NewStreamPayloadRecordingSpec{ - Profiles: []components.TranscodeProfile{ - components.TranscodeProfile{ - Width: livepeergo.Int64(1280), - Name: livepeergo.String("720p"), - Height: livepeergo.Int64(720), - Bitrate: 3000000, - Quality: livepeergo.Int64(23), - Fps: livepeergo.Int64(30), - FpsDen: livepeergo.Int64(1), - Gop: livepeergo.String("2"), - Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(), - Encoder: components.TranscodeProfileEncoderH264.ToPointer(), - }, - }, - }, - Multistream: &components.Multistream{ - Targets: []components.Target{ - components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, - }, - }, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.Stream != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.Create(ctx, components.NewStreamPayload{\n Name: \"test_stream\",\n Pull: &components.Pull{\n Source: \"https://myservice.com/live/stream.flv\",\n Headers: map[string]string{\n \"Authorization\": \"Bearer 123\",\n },\n Location: &components.Location{\n Lat: 39.739,\n Lon: -104.988,\n },\n },\n PlaybackPolicy: &components.PlaybackPolicy{\n Type: components.TypeWebhook,\n WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n WebhookContext: map[string]any{\n \"streamerId\": \"my-custom-id\",\n },\n RefreshInterval: livepeergo.Float64(600),\n },\n Profiles: []components.FfmpegProfile{\n components.FfmpegProfile{\n Width: 1280,\n Name: \"720p\",\n Height: 720,\n Bitrate: 3000000,\n Fps: 30,\n FpsDen: livepeergo.Int64(1),\n Quality: livepeergo.Int64(23),\n Gop: livepeergo.String(\"2\"),\n Profile: components.ProfileH264Baseline.ToPointer(),\n },\n },\n Record: livepeergo.Bool(false),\n RecordingSpec: &components.NewStreamPayloadRecordingSpec{\n Profiles: []components.TranscodeProfile{\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n },\n },\n Multistream: &components.Multistream{\n Targets: []components.Target{\n components.Target{\n Profile: \"720p0\",\n ID: livepeergo.String(\"PUSH123\"),\n },\n },\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Stream != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}"]["delete"] update: x-codeSamples: - lang: go label: deleteStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.Delete(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}"]["get"] update: x-codeSamples: - lang: go label: getStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Stream != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Stream != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}"]["patch"] update: x-codeSamples: - lang: go label: updateStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.Update(ctx, "", components.StreamPatchPayload{ - Record: livepeergo.Bool(false), - Multistream: &components.Multistream{ - Targets: []components.Target{ - components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, - }, - }, - }, - PlaybackPolicy: &components.PlaybackPolicy{ - Type: components.TypeWebhook, - WebhookID: livepeergo.String("1bde4o2i6xycudoy"), - WebhookContext: map[string]any{ - "streamerId": "my-custom-id", - }, - RefreshInterval: livepeergo.Float64(600), - }, - Profiles: []components.FfmpegProfile{ - components.FfmpegProfile{ - Width: 1280, - Name: "720p", - Height: 720, - Bitrate: 3000000, - Fps: 30, - FpsDen: livepeergo.Int64(1), - Quality: livepeergo.Int64(23), - Gop: livepeergo.String("2"), - Profile: components.ProfileH264Baseline.ToPointer(), - }, - }, - RecordingSpec: &components.RecordingSpec{ - Profiles: []components.TranscodeProfile{ - components.TranscodeProfile{ - Width: livepeergo.Int64(1280), - Name: livepeergo.String("720p"), - Height: livepeergo.Int64(720), - Bitrate: 3000000, - Quality: livepeergo.Int64(23), - Fps: livepeergo.Int64(30), - FpsDen: livepeergo.Int64(1), - Gop: livepeergo.String("2"), - Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(), - Encoder: components.TranscodeProfileEncoderH264.ToPointer(), - }, - }, - }, - }) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.Update(ctx, \"\", components.StreamPatchPayload{\n Record: livepeergo.Bool(false),\n Multistream: &components.Multistream{\n Targets: []components.Target{\n components.Target{\n Profile: \"720p0\",\n ID: livepeergo.String(\"PUSH123\"),\n },\n },\n },\n PlaybackPolicy: &components.PlaybackPolicy{\n Type: components.TypeWebhook,\n WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n WebhookContext: map[string]any{\n \"streamerId\": \"my-custom-id\",\n },\n RefreshInterval: livepeergo.Float64(600),\n },\n Profiles: []components.FfmpegProfile{\n components.FfmpegProfile{\n Width: 1280,\n Name: \"720p\",\n Height: 720,\n Bitrate: 3000000,\n Fps: 30,\n FpsDen: livepeergo.Int64(1),\n Quality: livepeergo.Int64(23),\n Gop: livepeergo.String(\"2\"),\n Profile: components.ProfileH264Baseline.ToPointer(),\n },\n components.FfmpegProfile{\n Width: 1280,\n Name: \"720p\",\n Height: 720,\n Bitrate: 3000000,\n Fps: 30,\n FpsDen: livepeergo.Int64(1),\n Quality: livepeergo.Int64(23),\n Gop: livepeergo.String(\"2\"),\n Profile: components.ProfileH264Baseline.ToPointer(),\n },\n components.FfmpegProfile{\n Width: 1280,\n Name: \"720p\",\n Height: 720,\n Bitrate: 3000000,\n Fps: 30,\n FpsDen: livepeergo.Int64(1),\n Quality: livepeergo.Int64(23),\n Gop: livepeergo.String(\"2\"),\n Profile: components.ProfileH264Baseline.ToPointer(),\n },\n },\n RecordingSpec: &components.RecordingSpec{\n Profiles: []components.TranscodeProfile{\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n },\n },\n Name: livepeergo.String(\"test_stream\"),\n })\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}/clips"]["get"] update: x-codeSamples: - lang: go label: getClips - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.GetClips(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.GetClips(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}/create-multistream-target"]["post"] update: x-codeSamples: - lang: go label: addMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.AddMultistreamTarget(ctx, "", components.TargetAddPayload{ - Profile: "720p0", - VideoOnly: livepeergo.Bool(false), - ID: livepeergo.String("PUSH123"), - Spec: &components.TargetAddPayloadSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, - }) - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.AddMultistreamTarget(ctx, \"\", components.TargetAddPayload{\n Profile: \"720p0\",\n VideoOnly: livepeergo.Bool(false),\n ID: livepeergo.String(\"PUSH123\"),\n Spec: &components.TargetAddPayloadSpec{\n Name: livepeergo.String(\"My target\"),\n URL: \"rtmps://live.my-service.tv/channel/secretKey\",\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}/multistream/{targetId}"]["delete"] update: x-codeSamples: - lang: go label: removeMultistreamTarget - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.RemoveMultistreamTarget(ctx, "", "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.RemoveMultistreamTarget(ctx, \"\", \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}/start-pull"]["post"] update: x-codeSamples: - lang: go label: startPullStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.StartPull(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.StartPull(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{id}/terminate"]["delete"] update: x-codeSamples: - lang: go label: terminateStream - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Stream.Terminate(ctx, "") - if err != nil { - log.Fatal(err) - } - if res != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Stream.Terminate(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/stream/{parentId}/sessions"]["get"] update: x-codeSamples: - lang: go label: getRecordedSessions - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Session.GetRecorded(ctx, "", livepeergo.Pointer(operations.CreateRecordBoolean( - true, - ))) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Session.GetRecorded(ctx, \"\", livepeergo.Pointer(operations.CreateRecordBoolean(\n true,\n )))\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/task"]["get"] update: x-codeSamples: - lang: go label: getTasks - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Task.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Task.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/task/{taskId}"]["get"] update: x-codeSamples: - lang: go label: getTask - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Task.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Task != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Task.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Task != nil {\n // handle response\n }\n}" - target: $["paths"]["/transcode"]["post"] update: x-codeSamples: - lang: go label: transcodeVideo - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Transcode.Create(ctx, components.TranscodePayload{ - Input: components.CreateInputInput1( - components.Input1{ - URL: "https://s3.amazonaws.com/bucket/file.mp4", - }, - ), - Storage: components.CreateTranscodePayloadStorageStorage1( - components.Storage1{ - Type: components.StorageTypeS3, - Endpoint: "https://gateway.storjshare.io", - Bucket: "outputbucket", - Credentials: components.StorageCredentials{ - AccessKeyID: "AKIAIOSFODNN7EXAMPLE", - SecretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", - }, - }, - ), - Outputs: components.Outputs{ - Hls: &components.Hls{ - Path: "/samplevideo/hls", - }, - Mp4: &components.Mp4{ - Path: "/samplevideo/mp4", - }, - Fmp4: &components.Fmp4{ - Path: "/samplevideo/fmp4", - }, - }, - Profiles: []components.TranscodeProfile{ - components.TranscodeProfile{ - Width: livepeergo.Int64(1280), - Name: livepeergo.String("720p"), - Height: livepeergo.Int64(720), - Bitrate: 3000000, - Quality: livepeergo.Int64(23), - Fps: livepeergo.Int64(30), - FpsDen: livepeergo.Int64(1), - Gop: livepeergo.String("2"), - Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(), - Encoder: components.TranscodeProfileEncoderH264.ToPointer(), - }, - }, - }) - if err != nil { - log.Fatal(err) - } - if res.Task != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Transcode.Create(ctx, components.TranscodePayload{\n Input: components.CreateInputInput1(\n components.Input1{\n URL: \"https://s3.amazonaws.com/bucket/file.mp4\",\n },\n ),\n Storage: components.CreateTranscodePayloadStorageStorage2(\n components.Storage2{\n Type: components.TranscodePayloadStorageTypeWeb3Storage,\n Credentials: components.TranscodePayloadStorageCredentials{\n Proof: \"EaJlcm9vdHOAZ3ZlcnNpb24BmgIBcRIg2uxHpcPYSWNtifMKFkPC7IEDvFDCxCd3ADViv0coV7SnYXNYRO2hA0AnblHEW38s3lSlcwaDjPn\",\n },\n },\n ),\n Outputs: components.Outputs{\n Hls: &components.Hls{\n Path: \"/samplevideo/hls\",\n },\n Mp4: &components.Mp4{\n Path: \"/samplevideo/mp4\",\n },\n Fmp4: &components.Fmp4{\n Path: \"/samplevideo/fmp4\",\n },\n },\n Profiles: []components.TranscodeProfile{\n components.TranscodeProfile{\n Width: livepeergo.Int64(1280),\n Name: livepeergo.String(\"720p\"),\n Height: livepeergo.Int64(720),\n Bitrate: 3000000,\n Quality: livepeergo.Int64(23),\n Fps: livepeergo.Int64(30),\n FpsDen: livepeergo.Int64(1),\n Gop: livepeergo.String(\"2\"),\n Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n },\n },\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Task != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook"]["get"] update: x-codeSamples: - lang: go label: getWebhooks - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.GetAll(ctx) - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.GetAll(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook"]["post"] update: x-codeSamples: - lang: go label: createWebhook - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.Create(ctx, components.WebhookInput{ - Name: "test_webhook", - ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"), - Events: []components.Events{ - components.EventsStreamStarted, - components.EventsStreamIdle, - }, - URL: "https://my-service.com/webhook", - SharedSecret: livepeergo.String("my-secret"), - StreamID: livepeergo.String("de7818e7-610a-4057-8f6f-b785dc1e6f88"), - }) - if err != nil { - log.Fatal(err) - } - if res.Webhook != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.Create(ctx, components.WebhookInput{\n Name: \"test_webhook\",\n ProjectID: livepeergo.String(\"aac12556-4d65-4d34-9fb6-d1f0985eb0a9\"),\n Events: []components.Events{\n components.EventsStreamStarted,\n components.EventsStreamIdle,\n },\n URL: \"https://my-service.com/webhook\",\n SharedSecret: livepeergo.String(\"my-secret\"),\n StreamID: livepeergo.String(\"de7818e7-610a-4057-8f6f-b785dc1e6f88\"),\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Webhook != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}"]["delete"] update: x-codeSamples: - lang: go label: deleteWebhook - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.Delete(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Webhook != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.Delete(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Webhook != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}"]["get"] update: x-codeSamples: - lang: go label: getWebhook - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.Get(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Webhook != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.Get(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Webhook != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}"]["put"] update: x-codeSamples: - lang: go label: updateWebhook - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "github.com/livepeer/livepeer-go/models/components" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.Update(ctx, "", components.WebhookInput{ - Name: "test_webhook", - ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"), - Events: []components.Events{ - components.EventsStreamStarted, - components.EventsStreamIdle, - }, - URL: "https://my-service.com/webhook", - SharedSecret: livepeergo.String("my-secret"), - StreamID: livepeergo.String("de7818e7-610a-4057-8f6f-b785dc1e6f88"), - }) - if err != nil { - log.Fatal(err) - } - if res.Webhook != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.Update(ctx, \"\", components.WebhookInput{\n Name: \"test_webhook\",\n ProjectID: livepeergo.String(\"aac12556-4d65-4d34-9fb6-d1f0985eb0a9\"),\n Events: []components.Events{\n components.EventsStreamStarted,\n components.EventsStreamIdle,\n },\n URL: \"https://my-service.com/webhook\",\n SharedSecret: livepeergo.String(\"my-secret\"),\n StreamID: livepeergo.String(\"de7818e7-610a-4057-8f6f-b785dc1e6f88\"),\n })\n if err != nil {\n log.Fatal(err)\n }\n if res.Webhook != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}/log"]["get"] update: x-codeSamples: - lang: go label: getWebhookLogs - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.GetLogs(ctx, "") - if err != nil { - log.Fatal(err) - } - if res.Data != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.GetLogs(ctx, \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.Data != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}/log/{logId}"]["get"] update: x-codeSamples: - lang: go label: getWebhookLog - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.GetLog(ctx, "", "") - if err != nil { - log.Fatal(err) - } - if res.WebhookLog != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.GetLog(ctx, \"\", \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.WebhookLog != nil {\n // handle response\n }\n}" - target: $["paths"]["/webhook/{id}/log/{logId}/resend"]["post"] update: x-codeSamples: - lang: go label: resendWebhook - source: |- - package main - - import( - livepeergo "github.com/livepeer/livepeer-go" - "context" - "log" - ) - - func main() { - s := livepeergo.New( - livepeergo.WithSecurity(""), - ) - - ctx := context.Background() - res, err := s.Webhook.ResendLog(ctx, "", "") - if err != nil { - log.Fatal(err) - } - if res.WebhookLog != nil { - // handle response - } - } + source: "package main\n\nimport(\n\t\"context\"\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"log\"\n)\n\nfunc main() {\n ctx := context.Background()\n \n s := livepeergo.New(\n livepeergo.WithSecurity(\"\"),\n )\n\n res, err := s.Webhook.ResendLog(ctx, \"\", \"\")\n if err != nil {\n log.Fatal(err)\n }\n if res.WebhookLog != nil {\n // handle response\n }\n}" diff --git a/docs/models/components/asset.md b/docs/models/components/asset.md index 22d7fcf..9931ea3 100644 --- a/docs/models/components/asset.md +++ b/docs/models/components/asset.md @@ -10,7 +10,7 @@ | `PlaybackID` | **string* | :heavy_minus_sign: | The playback ID to use with the Playback Info endpoint to retrieve playback URLs. | eaw4nk06ts2d0mzb | | ~~`UserID`~~ | **string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible. | 66E2161C-7670-4D05-B71D-DA2D6979556F | | `PlaybackURL` | **string* | :heavy_minus_sign: | URL for HLS playback. **It is recommended to not use this URL**, and instead use playback IDs with the Playback Info endpoint to retrieve the playback URLs - this URL format is subject to change (e.g. https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8). | https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8 | -| `DownloadURL` | **string* | :heavy_minus_sign: | The URL to directly download the asset, e.g. `https://livepeercdn.com/asset/eawrrk06ts2d0mzb/video`. It is not recommended to use this for playback. | https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video | +| `DownloadURL` | **string* | :heavy_minus_sign: | The URL to directly download the asset, e.g. `https://livepeercdn.com/asset/eawrrk06ts2d0mzb/video`. It is not recommended to use this for playback. | https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4 | | `PlaybackPolicy` | [*components.PlaybackPolicy](../../models/components/playbackpolicy.md) | :heavy_minus_sign: | Whether the playback policy for an asset or stream is public or signed | | | `Source` | [components.Source](../../models/components/source.md) | :heavy_check_mark: | N/A | | | `CreatorID` | [*components.CreatorID](../../models/components/creatorid.md) | :heavy_minus_sign: | N/A | | diff --git a/docs/models/components/bodygenaudiototext.md b/docs/models/components/bodygenaudiototext.md index 493921c..67dd27c 100644 --- a/docs/models/components/bodygenaudiototext.md +++ b/docs/models/components/bodygenaudiototext.md @@ -3,7 +3,8 @@ ## Fields -| Field | Type | Required | Description | -| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | -| `Audio` | [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | -| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Audio` | [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | +| `ReturnTimestamps` | **string* | :heavy_minus_sign: | Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. | \ No newline at end of file diff --git a/docs/models/components/bodygenimagetoimage.md b/docs/models/components/bodygenimagetoimage.md index f40a6bb..a393b76 100644 --- a/docs/models/components/bodygenimagetoimage.md +++ b/docs/models/components/bodygenimagetoimage.md @@ -3,16 +3,17 @@ ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| `Prompt` | *string* | :heavy_check_mark: | Text prompt(s) to guide image generation. | -| `Image` | [components.Image](../../models/components/image.md) | :heavy_check_mark: | Uploaded image to modify with the pipeline. | -| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | -| `Strength` | **float64* | :heavy_minus_sign: | Degree of transformation applied to the reference image (0 to 1). | -| `GuidanceScale` | **float64* | :heavy_minus_sign: | Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality). | -| `ImageGuidanceScale` | **float64* | :heavy_minus_sign: | Degree to which the generated image is pushed towards the initial image. | -| `NegativePrompt` | **string* | :heavy_minus_sign: | Text prompt(s) to guide what to exclude from image generation. Ignored if guidance_scale < 1. | -| `SafetyCheck` | **bool* | :heavy_minus_sign: | Perform a safety check to estimate if generated images could be offensive or harmful. | -| `Seed` | **int64* | :heavy_minus_sign: | Seed for random number generation. | -| `NumInferenceSteps` | **int64* | :heavy_minus_sign: | Number of denoising steps. More steps usually lead to higher quality images but slower inference. Modulated by strength. | -| `NumImagesPerPrompt` | **int64* | :heavy_minus_sign: | Number of images to generate per prompt. | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Prompt` | *string* | :heavy_check_mark: | Text prompt(s) to guide image generation. | +| `Image` | [components.Image](../../models/components/image.md) | :heavy_check_mark: | Uploaded image to modify with the pipeline. | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | +| `Loras` | **string* | :heavy_minus_sign: | A LoRA (Low-Rank Adaptation) model and its corresponding weight for image generation. Example: { "latent-consistency/lcm-lora-sdxl": 1.0, "nerijs/pixel-art-xl": 1.2}. | +| `Strength` | **float64* | :heavy_minus_sign: | Degree of transformation applied to the reference image (0 to 1). | +| `GuidanceScale` | **float64* | :heavy_minus_sign: | Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality). | +| `ImageGuidanceScale` | **float64* | :heavy_minus_sign: | Degree to which the generated image is pushed towards the initial image. | +| `NegativePrompt` | **string* | :heavy_minus_sign: | Text prompt(s) to guide what to exclude from image generation. Ignored if guidance_scale < 1. | +| `SafetyCheck` | **bool* | :heavy_minus_sign: | Perform a safety check to estimate if generated images could be offensive or harmful. | +| `Seed` | **int64* | :heavy_minus_sign: | Seed for random number generation. | +| `NumInferenceSteps` | **int64* | :heavy_minus_sign: | Number of denoising steps. More steps usually lead to higher quality images but slower inference. Modulated by strength. | +| `NumImagesPerPrompt` | **int64* | :heavy_minus_sign: | Number of images to generate per prompt. | \ No newline at end of file diff --git a/docs/models/components/bodygenllm.md b/docs/models/components/bodygenllm.md new file mode 100644 index 0000000..b4dc982 --- /dev/null +++ b/docs/models/components/bodygenllm.md @@ -0,0 +1,14 @@ +# BodyGenLLM + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Prompt` | *string* | :heavy_check_mark: | N/A | +| `ModelID` | **string* | :heavy_minus_sign: | N/A | +| `SystemMsg` | **string* | :heavy_minus_sign: | N/A | +| `Temperature` | **float64* | :heavy_minus_sign: | N/A | +| `MaxTokens` | **int64* | :heavy_minus_sign: | N/A | +| `History` | **string* | :heavy_minus_sign: | N/A | +| `Stream` | **bool* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/components/encryption.md b/docs/models/components/encryption.md new file mode 100644 index 0000000..6fb8768 --- /dev/null +++ b/docs/models/components/encryption.md @@ -0,0 +1,8 @@ +# Encryption + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | +| `EncryptedKey` | *string* | :heavy_check_mark: | Encryption key used to encrypt the asset. Only writable in the upload asset endpoints and cannot be retrieved back. | \ No newline at end of file diff --git a/docs/models/components/error.md b/docs/models/components/error.md new file mode 100644 index 0000000..b644f4b --- /dev/null +++ b/docs/models/components/error.md @@ -0,0 +1,8 @@ +# Error + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Errors` | []*string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/components/llmresponse.md b/docs/models/components/llmresponse.md new file mode 100644 index 0000000..58bfd58 --- /dev/null +++ b/docs/models/components/llmresponse.md @@ -0,0 +1,9 @@ +# LLMResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Response` | *string* | :heavy_check_mark: | N/A | +| `TokensUsed` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/components/multistreamtargetinput.md b/docs/models/components/multistreamtargetinput.md new file mode 100644 index 0000000..cdfc163 --- /dev/null +++ b/docs/models/components/multistreamtargetinput.md @@ -0,0 +1,10 @@ +# MultistreamTargetInput + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `Name` | **string* | :heavy_minus_sign: | N/A | | +| `URL` | *string* | :heavy_check_mark: | Livepeer-compatible multistream target URL (RTMP(S) or SRT) | rtmps://live.my-service.tv/channel/secretKey | +| `Disabled` | **bool* | :heavy_minus_sign: | If true then this multistream target will not be used for pushing
even if it is configured in a stream object.
| | \ No newline at end of file diff --git a/docs/models/components/streampatchpayload.md b/docs/models/components/streampatchpayload.md index 3e8b856..36744fb 100644 --- a/docs/models/components/streampatchpayload.md +++ b/docs/models/components/streampatchpayload.md @@ -12,4 +12,5 @@ | `PlaybackPolicy` | [*components.PlaybackPolicy](../../models/components/playbackpolicy.md) | :heavy_minus_sign: | Whether the playback policy for an asset or stream is public or signed | | | `Profiles` | [][components.FfmpegProfile](../../models/components/ffmpegprofile.md) | :heavy_minus_sign: | N/A | | | `RecordingSpec` | [*components.RecordingSpec](../../models/components/recordingspec.md) | :heavy_minus_sign: | N/A | | -| `UserTags` | map[string][components.UserTags](../../models/components/usertags.md) | :heavy_minus_sign: | User input tags associated with the stream | | \ No newline at end of file +| `UserTags` | map[string][components.UserTags](../../models/components/usertags.md) | :heavy_minus_sign: | User input tags associated with the stream | | +| `Name` | **string* | :heavy_minus_sign: | N/A | test_stream | \ No newline at end of file diff --git a/docs/models/components/target.md b/docs/models/components/target.md new file mode 100644 index 0000000..12fc770 --- /dev/null +++ b/docs/models/components/target.md @@ -0,0 +1,11 @@ +# Target + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `Profile` | *string* | :heavy_check_mark: | Name of transcoding profile that should be sent. Use
"source" for pushing source stream data
| 720p0 | +| `VideoOnly` | **bool* | :heavy_minus_sign: | If true, the stream audio will be muted and only silent
video will be pushed to the target.
| false | +| `ID` | **string* | :heavy_minus_sign: | ID of multistream target object where to push this stream | PUSH123 | +| `Spec` | [*components.TargetSpec](../../models/components/targetspec.md) | :heavy_minus_sign: | Inline multistream target object. Will automatically
create the target resource to be used by the created
stream.
| | \ No newline at end of file diff --git a/docs/models/components/texttoimageparams.md b/docs/models/components/texttoimageparams.md index 48ed5e1..f79d7d1 100644 --- a/docs/models/components/texttoimageparams.md +++ b/docs/models/components/texttoimageparams.md @@ -3,15 +3,16 @@ ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | -| `Prompt` | *string* | :heavy_check_mark: | Text prompt(s) to guide image generation. Separate multiple prompts with '\|' if supported by the model. | -| `Height` | **int64* | :heavy_minus_sign: | The height in pixels of the generated image. | -| `Width` | **int64* | :heavy_minus_sign: | The width in pixels of the generated image. | -| `GuidanceScale` | **float64* | :heavy_minus_sign: | Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality). | -| `NegativePrompt` | **string* | :heavy_minus_sign: | Text prompt(s) to guide what to exclude from image generation. Ignored if guidance_scale < 1. | -| `SafetyCheck` | **bool* | :heavy_minus_sign: | Perform a safety check to estimate if generated images could be offensive or harmful. | -| `Seed` | **int64* | :heavy_minus_sign: | Seed for random number generation. | -| `NumInferenceSteps` | **int64* | :heavy_minus_sign: | Number of denoising steps. More steps usually lead to higher quality images but slower inference. Modulated by strength. | -| `NumImagesPerPrompt` | **int64* | :heavy_minus_sign: | Number of images to generate per prompt. | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | +| `Loras` | **string* | :heavy_minus_sign: | A LoRA (Low-Rank Adaptation) model and its corresponding weight for image generation. Example: { "latent-consistency/lcm-lora-sdxl": 1.0, "nerijs/pixel-art-xl": 1.2}. | +| `Prompt` | *string* | :heavy_check_mark: | Text prompt(s) to guide image generation. Separate multiple prompts with '\|' if supported by the model. | +| `Height` | **int64* | :heavy_minus_sign: | The height in pixels of the generated image. | +| `Width` | **int64* | :heavy_minus_sign: | The width in pixels of the generated image. | +| `GuidanceScale` | **float64* | :heavy_minus_sign: | Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality). | +| `NegativePrompt` | **string* | :heavy_minus_sign: | Text prompt(s) to guide what to exclude from image generation. Ignored if guidance_scale < 1. | +| `SafetyCheck` | **bool* | :heavy_minus_sign: | Perform a safety check to estimate if generated images could be offensive or harmful. | +| `Seed` | **int64* | :heavy_minus_sign: | Seed for random number generation. | +| `NumInferenceSteps` | **int64* | :heavy_minus_sign: | Number of denoising steps. More steps usually lead to higher quality images but slower inference. Modulated by strength. | +| `NumImagesPerPrompt` | **int64* | :heavy_minus_sign: | Number of images to generate per prompt. | \ No newline at end of file diff --git a/docs/models/components/webhookinput.md b/docs/models/components/webhookinput.md new file mode 100644 index 0000000..6306e96 --- /dev/null +++ b/docs/models/components/webhookinput.md @@ -0,0 +1,13 @@ +# WebhookInput + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | N/A | test_webhook | +| `ProjectID` | **string* | :heavy_minus_sign: | The ID of the project | aac12556-4d65-4d34-9fb6-d1f0985eb0a9 | +| `Events` | [][components.Events](../../models/components/events.md) | :heavy_minus_sign: | N/A | [
"stream.started",
"stream.idle"
] | +| `URL` | *string* | :heavy_check_mark: | N/A | https://my-service.com/webhook | +| `SharedSecret` | **string* | :heavy_minus_sign: | shared secret used to sign the webhook payload | my-secret | +| `StreamID` | **string* | :heavy_minus_sign: | streamId of the stream on which the webhook is applied | de7818e7-610a-4057-8f6f-b785dc1e6f88 | \ No newline at end of file diff --git a/docs/models/operations/addmultistreamtargetresponse.md b/docs/models/operations/addmultistreamtargetresponse.md index 59e449c..62cb0a5 100644 --- a/docs/models/operations/addmultistreamtargetresponse.md +++ b/docs/models/operations/addmultistreamtargetresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createclipresponse.md b/docs/models/operations/createclipresponse.md index 3d23582..e647858 100644 --- a/docs/models/operations/createclipresponse.md +++ b/docs/models/operations/createclipresponse.md @@ -7,4 +7,4 @@ | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [*operations.CreateClipData](../../models/operations/createclipdata.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createmultistreamtargetresponse.md b/docs/models/operations/createmultistreamtargetresponse.md index 5f5dbaa..2888786 100644 --- a/docs/models/operations/createmultistreamtargetresponse.md +++ b/docs/models/operations/createmultistreamtargetresponse.md @@ -7,4 +7,4 @@ | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `MultistreamTarget` | [*components.MultistreamTarget](../../models/components/multistreamtarget.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createroomresponse.md b/docs/models/operations/createroomresponse.md index 5e369ce..848f1a8 100644 --- a/docs/models/operations/createroomresponse.md +++ b/docs/models/operations/createroomresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `CreateRoomResponse` | [*components.CreateRoomResponse](../../models/components/createroomresponse.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createroomuserresponse.md b/docs/models/operations/createroomuserresponse.md index 456eb75..ef704ef 100644 --- a/docs/models/operations/createroomuserresponse.md +++ b/docs/models/operations/createroomuserresponse.md @@ -7,4 +7,4 @@ | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `RoomUserResponse` | [*components.RoomUserResponse](../../models/components/roomuserresponse.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createsigningkeyresponse.md b/docs/models/operations/createsigningkeyresponse.md index 906e173..883e539 100644 --- a/docs/models/operations/createsigningkeyresponse.md +++ b/docs/models/operations/createsigningkeyresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `SigningKey` | [*components.SigningKey](../../models/components/signingkey.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createstreamresponse.md b/docs/models/operations/createstreamresponse.md index f26770a..14ac257 100644 --- a/docs/models/operations/createstreamresponse.md +++ b/docs/models/operations/createstreamresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Stream` | [*components.Stream](../../models/components/stream.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/createwebhookresponse.md b/docs/models/operations/createwebhookresponse.md index 2d50cc9..7265010 100644 --- a/docs/models/operations/createwebhookresponse.md +++ b/docs/models/operations/createwebhookresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Webhook` | [*components.Webhook](../../models/components/webhook.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deleteassetresponse.md b/docs/models/operations/deleteassetresponse.md index b7ea7c3..1d706a5 100644 --- a/docs/models/operations/deleteassetresponse.md +++ b/docs/models/operations/deleteassetresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deletemultistreamtargetresponse.md b/docs/models/operations/deletemultistreamtargetresponse.md index 7ce7c05..7ca1602 100644 --- a/docs/models/operations/deletemultistreamtargetresponse.md +++ b/docs/models/operations/deletemultistreamtargetresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deleteroomresponse.md b/docs/models/operations/deleteroomresponse.md index f08711c..50f2d9f 100644 --- a/docs/models/operations/deleteroomresponse.md +++ b/docs/models/operations/deleteroomresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deleteroomuserresponse.md b/docs/models/operations/deleteroomuserresponse.md index 53c551f..85f0b6c 100644 --- a/docs/models/operations/deleteroomuserresponse.md +++ b/docs/models/operations/deleteroomuserresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deletesigningkeyresponse.md b/docs/models/operations/deletesigningkeyresponse.md index 9350336..5eb503a 100644 --- a/docs/models/operations/deletesigningkeyresponse.md +++ b/docs/models/operations/deletesigningkeyresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deletestreamresponse.md b/docs/models/operations/deletestreamresponse.md index 7802b30..4eaa21d 100644 --- a/docs/models/operations/deletestreamresponse.md +++ b/docs/models/operations/deletestreamresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/deletewebhookresponse.md b/docs/models/operations/deletewebhookresponse.md index dc8e218..c6876ed 100644 --- a/docs/models/operations/deletewebhookresponse.md +++ b/docs/models/operations/deletewebhookresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Webhook` | [*components.Webhook](../../models/components/webhook.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/genllmresponse.md b/docs/models/operations/genllmresponse.md new file mode 100644 index 0000000..7bae050 --- /dev/null +++ b/docs/models/operations/genllmresponse.md @@ -0,0 +1,10 @@ +# GenLLMResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `LLMResponse` | [*components.LLMResponse](../../models/components/llmresponse.md) | :heavy_minus_sign: | Successful Response | +| `StudioAPIError` | [*components.StudioAPIError](../../models/components/studioapierror.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getassetresponse.md b/docs/models/operations/getassetresponse.md index c5082c2..885c841 100644 --- a/docs/models/operations/getassetresponse.md +++ b/docs/models/operations/getassetresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Asset` | [*components.Asset](../../models/components/asset.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getassetsresponse.md b/docs/models/operations/getassetsresponse.md index f606acf..662701a 100644 --- a/docs/models/operations/getassetsresponse.md +++ b/docs/models/operations/getassetsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Asset](../../models/components/asset.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getclipsresponse.md b/docs/models/operations/getclipsresponse.md index de3f2f0..75154d7 100644 --- a/docs/models/operations/getclipsresponse.md +++ b/docs/models/operations/getclipsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Asset](../../models/components/asset.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getcreatorviewershipmetricsresponse.md b/docs/models/operations/getcreatorviewershipmetricsresponse.md index ab8a9cc..aa03d5e 100644 --- a/docs/models/operations/getcreatorviewershipmetricsresponse.md +++ b/docs/models/operations/getcreatorviewershipmetricsresponse.md @@ -7,4 +7,4 @@ | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.ViewershipMetric](../../models/components/viewershipmetric.md) | :heavy_minus_sign: | A list of Metric objects | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getmultistreamtargetresponse.md b/docs/models/operations/getmultistreamtargetresponse.md index 3732916..5298999 100644 --- a/docs/models/operations/getmultistreamtargetresponse.md +++ b/docs/models/operations/getmultistreamtargetresponse.md @@ -7,4 +7,4 @@ | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `MultistreamTarget` | [*components.MultistreamTarget](../../models/components/multistreamtarget.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getmultistreamtargetsresponse.md b/docs/models/operations/getmultistreamtargetsresponse.md index a212e82..db0e737 100644 --- a/docs/models/operations/getmultistreamtargetsresponse.md +++ b/docs/models/operations/getmultistreamtargetsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.MultistreamTarget](../../models/components/multistreamtarget.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getplaybackinforesponse.md b/docs/models/operations/getplaybackinforesponse.md index a7c4230..b7cb65c 100644 --- a/docs/models/operations/getplaybackinforesponse.md +++ b/docs/models/operations/getplaybackinforesponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `PlaybackInfo` | [*components.PlaybackInfo](../../models/components/playbackinfo.md) | :heavy_minus_sign: | Successful response | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Playback not found | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Playback not found | \ No newline at end of file diff --git a/docs/models/operations/getpublicviewershipmetricsresponse.md b/docs/models/operations/getpublicviewershipmetricsresponse.md index 4144c8f..1974508 100644 --- a/docs/models/operations/getpublicviewershipmetricsresponse.md +++ b/docs/models/operations/getpublicviewershipmetricsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [*operations.GetPublicViewershipMetricsData](../../models/operations/getpublicviewershipmetricsdata.md) | :heavy_minus_sign: | A single Metric object with the viewCount and playtimeMins metrics. | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getrealtimeviewershipnowresponse.md b/docs/models/operations/getrealtimeviewershipnowresponse.md index c94667f..6b1bcaf 100644 --- a/docs/models/operations/getrealtimeviewershipnowresponse.md +++ b/docs/models/operations/getrealtimeviewershipnowresponse.md @@ -7,4 +7,4 @@ | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.RealtimeViewershipMetric](../../models/components/realtimeviewershipmetric.md) | :heavy_minus_sign: | A list of Metric objects | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getrecordedsessionsresponse.md b/docs/models/operations/getrecordedsessionsresponse.md index bdc544d..79778f6 100644 --- a/docs/models/operations/getrecordedsessionsresponse.md +++ b/docs/models/operations/getrecordedsessionsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Session](../../models/components/session.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getroomresponse.md b/docs/models/operations/getroomresponse.md index 5329acb..7d57947 100644 --- a/docs/models/operations/getroomresponse.md +++ b/docs/models/operations/getroomresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Room` | [*components.Room](../../models/components/room.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getroomuserresponse.md b/docs/models/operations/getroomuserresponse.md index c225585..b2955e7 100644 --- a/docs/models/operations/getroomuserresponse.md +++ b/docs/models/operations/getroomuserresponse.md @@ -7,4 +7,4 @@ | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `GetRoomUserResponse` | [*components.GetRoomUserResponse](../../models/components/getroomuserresponse.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getsessionclipsresponse.md b/docs/models/operations/getsessionclipsresponse.md index eb218ef..6e8d72b 100644 --- a/docs/models/operations/getsessionclipsresponse.md +++ b/docs/models/operations/getsessionclipsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Asset](../../models/components/asset.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getsessionresponse.md b/docs/models/operations/getsessionresponse.md index 2a1005d..c0bad5c 100644 --- a/docs/models/operations/getsessionresponse.md +++ b/docs/models/operations/getsessionresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Session` | [*components.Session](../../models/components/session.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getsessionsresponse.md b/docs/models/operations/getsessionsresponse.md index 5a9fcea..bc3c436 100644 --- a/docs/models/operations/getsessionsresponse.md +++ b/docs/models/operations/getsessionsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Session](../../models/components/session.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getsigningkeyresponse.md b/docs/models/operations/getsigningkeyresponse.md index e1d5e9b..8f37e86 100644 --- a/docs/models/operations/getsigningkeyresponse.md +++ b/docs/models/operations/getsigningkeyresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `SigningKey` | [*components.SigningKey](../../models/components/signingkey.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getsigningkeysresponse.md b/docs/models/operations/getsigningkeysresponse.md index e5e6d83..a278d31 100644 --- a/docs/models/operations/getsigningkeysresponse.md +++ b/docs/models/operations/getsigningkeysresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.SigningKey](../../models/components/signingkey.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getstreamresponse.md b/docs/models/operations/getstreamresponse.md index 5e71833..51d42b3 100644 --- a/docs/models/operations/getstreamresponse.md +++ b/docs/models/operations/getstreamresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Stream` | [*components.Stream](../../models/components/stream.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getstreamsresponse.md b/docs/models/operations/getstreamsresponse.md index 8e1b355..970a13a 100644 --- a/docs/models/operations/getstreamsresponse.md +++ b/docs/models/operations/getstreamsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Stream](../../models/components/stream.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/gettasksresponse.md b/docs/models/operations/gettasksresponse.md index b4d0825..d70916d 100644 --- a/docs/models/operations/gettasksresponse.md +++ b/docs/models/operations/gettasksresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Task](../../models/components/task.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getusagemetricsresponse.md b/docs/models/operations/getusagemetricsresponse.md index 64605d5..320e8c7 100644 --- a/docs/models/operations/getusagemetricsresponse.md +++ b/docs/models/operations/getusagemetricsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `UsageMetric` | [*components.UsageMetric](../../models/components/usagemetric.md) | :heavy_minus_sign: | A Usage Metric object | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getviewershipmetricsresponse.md b/docs/models/operations/getviewershipmetricsresponse.md index aa67ff3..45288c2 100644 --- a/docs/models/operations/getviewershipmetricsresponse.md +++ b/docs/models/operations/getviewershipmetricsresponse.md @@ -7,4 +7,4 @@ | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.ViewershipMetric](../../models/components/viewershipmetric.md) | :heavy_minus_sign: | A list of Metric objects | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getwebhooklogresponse.md b/docs/models/operations/getwebhooklogresponse.md index 499b2bb..2fef315 100644 --- a/docs/models/operations/getwebhooklogresponse.md +++ b/docs/models/operations/getwebhooklogresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `WebhookLog` | [*components.WebhookLog](../../models/components/webhooklog.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getwebhooklogsresponse.md b/docs/models/operations/getwebhooklogsresponse.md index 2c3e5d3..d6da1c3 100644 --- a/docs/models/operations/getwebhooklogsresponse.md +++ b/docs/models/operations/getwebhooklogsresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.WebhookLog](../../models/components/webhooklog.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getwebhookresponse.md b/docs/models/operations/getwebhookresponse.md index 40a95de..d8e7cff 100644 --- a/docs/models/operations/getwebhookresponse.md +++ b/docs/models/operations/getwebhookresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Webhook` | [*components.Webhook](../../models/components/webhook.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/getwebhooksresponse.md b/docs/models/operations/getwebhooksresponse.md index a516bc9..957966c 100644 --- a/docs/models/operations/getwebhooksresponse.md +++ b/docs/models/operations/getwebhooksresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [][components.Webhook](../../models/components/webhook.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/removemultistreamtargetresponse.md b/docs/models/operations/removemultistreamtargetresponse.md index 308369d..496d079 100644 --- a/docs/models/operations/removemultistreamtargetresponse.md +++ b/docs/models/operations/removemultistreamtargetresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/requestuploadresponse.md b/docs/models/operations/requestuploadresponse.md index 9b3c56f..b232656 100644 --- a/docs/models/operations/requestuploadresponse.md +++ b/docs/models/operations/requestuploadresponse.md @@ -7,4 +7,4 @@ | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Data` | [*operations.RequestUploadData](../../models/operations/requestuploaddata.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/resendwebhookresponse.md b/docs/models/operations/resendwebhookresponse.md index f84b81d..97ba3dd 100644 --- a/docs/models/operations/resendwebhookresponse.md +++ b/docs/models/operations/resendwebhookresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `WebhookLog` | [*components.WebhookLog](../../models/components/webhooklog.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/startpullstreamresponse.md b/docs/models/operations/startpullstreamresponse.md index 86bae85..b42701a 100644 --- a/docs/models/operations/startpullstreamresponse.md +++ b/docs/models/operations/startpullstreamresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/startroomegressresponse.md b/docs/models/operations/startroomegressresponse.md index 7104209..6c99d53 100644 --- a/docs/models/operations/startroomegressresponse.md +++ b/docs/models/operations/startroomegressresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/stoproomegressresponse.md b/docs/models/operations/stoproomegressresponse.md index d875e7c..afa0309 100644 --- a/docs/models/operations/stoproomegressresponse.md +++ b/docs/models/operations/stoproomegressresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/terminatestreamresponse.md b/docs/models/operations/terminatestreamresponse.md index 46e432f..4410447 100644 --- a/docs/models/operations/terminatestreamresponse.md +++ b/docs/models/operations/terminatestreamresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/transcodevideoresponse.md b/docs/models/operations/transcodevideoresponse.md index c361a66..7a6a3e0 100644 --- a/docs/models/operations/transcodevideoresponse.md +++ b/docs/models/operations/transcodevideoresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Task` | [*components.Task](../../models/components/task.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updateassetresponse.md b/docs/models/operations/updateassetresponse.md index f761f43..655537d 100644 --- a/docs/models/operations/updateassetresponse.md +++ b/docs/models/operations/updateassetresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Asset` | [*components.Asset](../../models/components/asset.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updatemultistreamtargetresponse.md b/docs/models/operations/updatemultistreamtargetresponse.md index 27031a0..32cb96c 100644 --- a/docs/models/operations/updatemultistreamtargetresponse.md +++ b/docs/models/operations/updatemultistreamtargetresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updateroomuserresponse.md b/docs/models/operations/updateroomuserresponse.md index 09b13f0..2470277 100644 --- a/docs/models/operations/updateroomuserresponse.md +++ b/docs/models/operations/updateroomuserresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updatesigningkeyresponse.md b/docs/models/operations/updatesigningkeyresponse.md index 189b51b..5643605 100644 --- a/docs/models/operations/updatesigningkeyresponse.md +++ b/docs/models/operations/updatesigningkeyresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updatestreamresponse.md b/docs/models/operations/updatestreamresponse.md index d34b361..4031a8a 100644 --- a/docs/models/operations/updatestreamresponse.md +++ b/docs/models/operations/updatestreamresponse.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/updatewebhookresponse.md b/docs/models/operations/updatewebhookresponse.md index d67e72a..5d0a6bd 100644 --- a/docs/models/operations/updatewebhookresponse.md +++ b/docs/models/operations/updatewebhookresponse.md @@ -7,4 +7,4 @@ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `Webhook` | [*components.Webhook](../../models/components/webhook.md) | :heavy_minus_sign: | Success | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/operations/uploadassetresponse.md b/docs/models/operations/uploadassetresponse.md index 947298e..d872b6e 100644 --- a/docs/models/operations/uploadassetresponse.md +++ b/docs/models/operations/uploadassetresponse.md @@ -8,4 +8,4 @@ | `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | | `TwoHundredApplicationJSONData` | [*operations.UploadAssetData](../../models/operations/uploadassetdata.md) | :heavy_minus_sign: | Upload in progress | | `TwoHundredAndOneApplicationJSONData` | [*operations.UploadAssetDataOutput](../../models/operations/uploadassetdataoutput.md) | :heavy_minus_sign: | Upload started | -| `Error` | **sdkerrors.Error* | :heavy_minus_sign: | Error | \ No newline at end of file +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/docs/models/sdkerrors/genaudiototextgenerateresponse415responsebody.md b/docs/models/sdkerrors/genaudiototextgenerateresponse415responsebody.md new file mode 100644 index 0000000..cb7d29d --- /dev/null +++ b/docs/models/sdkerrors/genaudiototextgenerateresponse415responsebody.md @@ -0,0 +1,19 @@ +# GenAudioToTextGenerateResponse415ResponseBody + +Unsupported Media Type + + +## Supported Types + +### HTTPError + +```go +genAudioToTextGenerateResponse415ResponseBody := sdkerrors.CreateGenAudioToTextGenerateResponse415ResponseBodyHTTPError(components.HTTPError{/* values here */}) +``` + +### StudioAPIError + +```go +genAudioToTextGenerateResponse415ResponseBody := sdkerrors.CreateGenAudioToTextGenerateResponse415ResponseBodyStudioAPIError(components.StudioAPIError{/* values here */}) +``` + diff --git a/docs/models/sdkerrors/genllmgenerateresponse500responsebody.md b/docs/models/sdkerrors/genllmgenerateresponse500responsebody.md new file mode 100644 index 0000000..3419fb0 --- /dev/null +++ b/docs/models/sdkerrors/genllmgenerateresponse500responsebody.md @@ -0,0 +1,19 @@ +# GenLLMGenerateResponse500ResponseBody + +Internal Server Error + + +## Supported Types + +### HTTPError + +```go +genLLMGenerateResponse500ResponseBody := sdkerrors.CreateGenLLMGenerateResponse500ResponseBodyHTTPError(components.HTTPError{/* values here */}) +``` + +### StudioAPIError + +```go +genLLMGenerateResponse500ResponseBody := sdkerrors.CreateGenLLMGenerateResponse500ResponseBodyStudioAPIError(components.StudioAPIError{/* values here */}) +``` + diff --git a/docs/models/sdkerrors/genllmgenerateresponsebody.md b/docs/models/sdkerrors/genllmgenerateresponsebody.md new file mode 100644 index 0000000..aa85160 --- /dev/null +++ b/docs/models/sdkerrors/genllmgenerateresponsebody.md @@ -0,0 +1,19 @@ +# GenLLMGenerateResponseBody + +Unauthorized + + +## Supported Types + +### HTTPError + +```go +genLLMGenerateResponseBody := sdkerrors.CreateGenLLMGenerateResponseBodyHTTPError(components.HTTPError{/* values here */}) +``` + +### StudioAPIError + +```go +genLLMGenerateResponseBody := sdkerrors.CreateGenLLMGenerateResponseBodyStudioAPIError(components.StudioAPIError{/* values here */}) +``` + diff --git a/docs/models/sdkerrors/genllmgenerateresponseresponsebody.md b/docs/models/sdkerrors/genllmgenerateresponseresponsebody.md new file mode 100644 index 0000000..08b936d --- /dev/null +++ b/docs/models/sdkerrors/genllmgenerateresponseresponsebody.md @@ -0,0 +1,19 @@ +# GenLLMGenerateResponseResponseBody + +Validation Error + + +## Supported Types + +### HTTPValidationError + +```go +genLLMGenerateResponseResponseBody := sdkerrors.CreateGenLLMGenerateResponseResponseBodyHTTPValidationError(components.HTTPValidationError{/* values here */}) +``` + +### StudioAPIError + +```go +genLLMGenerateResponseResponseBody := sdkerrors.CreateGenLLMGenerateResponseResponseBodyStudioAPIError(components.StudioAPIError{/* values here */}) +``` + diff --git a/docs/models/sdkerrors/genllmresponsebody.md b/docs/models/sdkerrors/genllmresponsebody.md new file mode 100644 index 0000000..cc513b8 --- /dev/null +++ b/docs/models/sdkerrors/genllmresponsebody.md @@ -0,0 +1,19 @@ +# GenLLMResponseBody + +Bad Request + + +## Supported Types + +### HTTPError + +```go +genLLMResponseBody := sdkerrors.CreateGenLLMResponseBodyHTTPError(components.HTTPError{/* values here */}) +``` + +### StudioAPIError + +```go +genLLMResponseBody := sdkerrors.CreateGenLLMResponseBodyStudioAPIError(components.StudioAPIError{/* values here */}) +``` + diff --git a/docs/sdks/accesscontrol/README.md b/docs/sdks/accesscontrol/README.md index d5c8121..57461ac 100644 --- a/docs/sdks/accesscontrol/README.md +++ b/docs/sdks/accesscontrol/README.md @@ -25,17 +25,18 @@ Up to 10 signing keys can be generated, after that you must delete at least one package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.AccessControl.Create(ctx) if err != nil { log.Fatal(err) @@ -59,10 +60,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetAll @@ -74,17 +74,18 @@ Retrieves signing keys package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.AccessControl.GetAll(ctx) if err != nil { log.Fatal(err) @@ -108,10 +109,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -123,17 +123,18 @@ Delete Signing Key package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.AccessControl.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -158,10 +159,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -173,17 +173,18 @@ Retrieves a signing key package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.AccessControl.Get(ctx, "") if err != nil { log.Fatal(err) @@ -208,10 +209,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Update @@ -223,18 +223,19 @@ Update a signing key package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/operations" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.AccessControl.Update(ctx, "", operations.UpdateSigningKeyRequestBody{}) if err != nil { log.Fatal(err) @@ -260,6 +261,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/asset/README.md b/docs/sdks/asset/README.md index 6bd16f5..3e1ecdf 100644 --- a/docs/sdks/asset/README.md +++ b/docs/sdks/asset/README.md @@ -24,17 +24,18 @@ Retrieve assets package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.GetAll(ctx) if err != nil { log.Fatal(err) @@ -58,10 +59,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Create @@ -144,18 +144,19 @@ definition above. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.Create(ctx, components.NewAssetPayload{ Name: "filename.mp4", StaticMp4: livepeergo.Bool(true), @@ -205,10 +206,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## CreateViaURL @@ -220,18 +220,19 @@ Upload asset via URL package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.CreateViaURL(ctx, components.NewAssetFromURLPayload{ Name: "filename.mp4", StaticMp4: livepeergo.Bool(true), @@ -282,10 +283,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -297,17 +297,18 @@ Retrieves an asset package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.Get(ctx, "") if err != nil { log.Fatal(err) @@ -332,10 +333,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Update @@ -347,18 +347,19 @@ Patch an asset package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.Update(ctx, "", components.AssetPatchPayload{ Name: livepeergo.String("filename.mp4"), PlaybackPolicy: &components.PlaybackPolicy{ @@ -394,10 +395,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -409,17 +409,18 @@ Delete an asset package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Asset.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -444,6 +445,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/generate/README.md b/docs/sdks/generate/README.md index 6043883..de44b27 100644 --- a/docs/sdks/generate/README.md +++ b/docs/sdks/generate/README.md @@ -13,6 +13,7 @@ Operations related to AI generate api * [Upscale](#upscale) - Upscale * [AudioToText](#audiototext) - Audio To Text * [SegmentAnything2](#segmentanything2) - Segment Anything 2 +* [Llm](#llm) - LLM ## TextToImage @@ -24,18 +25,19 @@ Generate images from text prompts. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Generate.TextToImage(ctx, components.TextToImageParams{ Prompt: "", }) @@ -62,14 +64,13 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | | sdkerrors.GenTextToImageResponseBody | 400 | application/json | | sdkerrors.GenTextToImageGenerateResponseBody | 401 | application/json | | sdkerrors.GenTextToImageGenerateResponseResponseBody | 422 | application/json | | sdkerrors.GenTextToImageGenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ImageToImage @@ -81,14 +82,16 @@ Apply image transformations to a provided image. package main import( + "context" livepeergo "github.com/livepeer/livepeer-go" "os" - "context" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) @@ -98,7 +101,7 @@ func main() { panic(fileErr) } - ctx := context.Background() + res, err := s.Generate.ImageToImage(ctx, components.BodyGenImageToImage{ Prompt: "", Image: components.Image{ @@ -129,14 +132,13 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | | sdkerrors.GenImageToImageResponseBody | 400 | application/json | | sdkerrors.GenImageToImageGenerateResponseBody | 401 | application/json | | sdkerrors.GenImageToImageGenerateResponseResponseBody | 422 | application/json | | sdkerrors.GenImageToImageGenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ImageToVideo @@ -148,14 +150,16 @@ Generate a video from a provided image. package main import( + "context" livepeergo "github.com/livepeer/livepeer-go" "os" - "context" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) @@ -165,7 +169,7 @@ func main() { panic(fileErr) } - ctx := context.Background() + res, err := s.Generate.ImageToVideo(ctx, components.BodyGenImageToVideo{ Image: components.BodyGenImageToVideoImage{ FileName: "example.file", @@ -195,14 +199,13 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | | sdkerrors.GenImageToVideoResponseBody | 400 | application/json | | sdkerrors.GenImageToVideoGenerateResponseBody | 401 | application/json | | sdkerrors.GenImageToVideoGenerateResponseResponseBody | 422 | application/json | | sdkerrors.GenImageToVideoGenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Upscale @@ -214,14 +217,16 @@ Upscale an image by increasing its resolution. package main import( + "context" livepeergo "github.com/livepeer/livepeer-go" "os" - "context" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) @@ -231,7 +236,7 @@ func main() { panic(fileErr) } - ctx := context.Background() + res, err := s.Generate.Upscale(ctx, components.BodyGenUpscale{ Prompt: "", Image: components.BodyGenUpscaleImage{ @@ -262,14 +267,13 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | | sdkerrors.GenUpscaleResponseBody | 400 | application/json | | sdkerrors.GenUpscaleGenerateResponseBody | 401 | application/json | | sdkerrors.GenUpscaleGenerateResponseResponseBody | 422 | application/json | | sdkerrors.GenUpscaleGenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## AudioToText @@ -281,14 +285,16 @@ Transcribe audio files to text. package main import( + "context" livepeergo "github.com/livepeer/livepeer-go" "os" - "context" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) @@ -298,7 +304,7 @@ func main() { panic(fileErr) } - ctx := context.Background() + res, err := s.Generate.AudioToText(ctx, components.BodyGenAudioToText{ Audio: components.Audio{ FileName: "example.file", @@ -328,15 +334,15 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | | sdkerrors.GenAudioToTextResponseBody | 400 | application/json | | sdkerrors.GenAudioToTextGenerateResponseBody | 401 | application/json | | sdkerrors.GenAudioToTextGenerateResponseResponseBody | 413 | application/json | +| sdkerrors.GenAudioToTextGenerateResponse415ResponseBody | 415 | application/json | | sdkerrors.GenAudioToTextGenerateResponse422ResponseBody | 422 | application/json | | sdkerrors.GenAudioToTextGenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## SegmentAnything2 @@ -348,14 +354,16 @@ Segment objects in an image. package main import( + "context" livepeergo "github.com/livepeer/livepeer-go" "os" - "context" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) @@ -365,7 +373,7 @@ func main() { panic(fileErr) } - ctx := context.Background() + res, err := s.Generate.SegmentAnything2(ctx, components.BodyGenSegmentAnything2{ Image: components.BodyGenSegmentAnything2Image{ FileName: "example.file", @@ -395,10 +403,67 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | sdkerrors.GenSegmentAnything2ResponseBody | 400 | application/json | | sdkerrors.GenSegmentAnything2GenerateResponseBody | 401 | application/json | | sdkerrors.GenSegmentAnything2GenerateResponseResponseBody | 422 | application/json | | sdkerrors.GenSegmentAnything2GenerateResponse500ResponseBody | 500 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | + +## Llm + +Generate text using a language model. + +### Example Usage + +```go +package main + +import( + "context" + livepeergo "github.com/livepeer/livepeer-go" + "github.com/livepeer/livepeer-go/models/components" + "log" +) + +func main() { + ctx := context.Background() + + s := livepeergo.New( + livepeergo.WithSecurity(""), + ) + + res, err := s.Generate.Llm(ctx, components.BodyGenLLM{ + Prompt: "", + }) + if err != nil { + log.Fatal(err) + } + if res.LLMResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [components.BodyGenLLM](../../models/components/bodygenllm.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GenLLMResponse](../../models/operations/genllmresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | +| sdkerrors.GenLLMResponseBody | 400 | application/json | +| sdkerrors.GenLLMGenerateResponseBody | 401 | application/json | +| sdkerrors.GenLLMGenerateResponseResponseBody | 422 | application/json | +| sdkerrors.GenLLMGenerateResponse500ResponseBody | 500 | application/json | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/livepeer/README.md b/docs/sdks/livepeer/README.md index 808685b..912df69 100644 --- a/docs/sdks/livepeer/README.md +++ b/docs/sdks/livepeer/README.md @@ -5,3 +5,6 @@ Livepeer API Reference: Welcome to the Livepeer API reference docs. Here you will find all the endpoints exposed on the standard Livepeer API, learn how to use them and what they return. + + +### Available Operations diff --git a/docs/sdks/metrics/README.md b/docs/sdks/metrics/README.md index 4682129..6424a38 100644 --- a/docs/sdks/metrics/README.md +++ b/docs/sdks/metrics/README.md @@ -24,17 +24,18 @@ Requires a private (non-CORS) API key to be used. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Metrics.GetRealtimeViewership(ctx, nil, nil, nil) if err != nil { log.Fatal(err) @@ -61,10 +62,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetViewership @@ -77,18 +77,19 @@ Requires a private (non-CORS) API key to be used. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/operations" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Metrics.GetViewership(ctx, operations.GetViewershipMetricsRequest{}) if err != nil { log.Fatal(err) @@ -113,10 +114,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetCreatorViewership @@ -129,18 +129,19 @@ Requires a proof of ownership to be sent in the request, which for now is just t package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/operations" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Metrics.GetCreatorViewership(ctx, operations.GetCreatorViewershipMetricsRequest{}) if err != nil { log.Fatal(err) @@ -165,10 +166,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetPublicViewership @@ -183,17 +183,18 @@ unauthenticated. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Metrics.GetPublicViewership(ctx, "") if err != nil { log.Fatal(err) @@ -218,10 +219,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetUsage @@ -233,18 +233,19 @@ Query usage metrics package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/operations" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Metrics.GetUsage(ctx, operations.GetUsageMetricsRequest{}) if err != nil { log.Fatal(err) @@ -269,6 +270,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/multistream/README.md b/docs/sdks/multistream/README.md index e59c424..2f78ada 100644 --- a/docs/sdks/multistream/README.md +++ b/docs/sdks/multistream/README.md @@ -23,17 +23,18 @@ Retrieve Multistream Targets package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Multistream.GetAll(ctx) if err != nil { log.Fatal(err) @@ -57,10 +58,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Create @@ -72,18 +72,19 @@ Create a multistream target package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Multistream.Create(ctx, components.MultistreamTargetInput{ URL: "rtmps://live.my-service.tv/channel/secretKey", }) @@ -110,10 +111,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -125,17 +125,18 @@ Retrieve a multistream target package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Multistream.Get(ctx, "") if err != nil { log.Fatal(err) @@ -160,10 +161,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Update @@ -175,18 +175,19 @@ Update Multistream Target package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Multistream.Update(ctx, "", components.MultistreamTargetPatchPayload{ URL: "rtmps://live.my-service.tv/channel/secretKey", }) @@ -214,10 +215,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -231,17 +231,18 @@ streams before actually deleting it from the API. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Multistream.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -266,6 +267,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/playback/README.md b/docs/sdks/playback/README.md index e266b7e..166a3c0 100644 --- a/docs/sdks/playback/README.md +++ b/docs/sdks/playback/README.md @@ -19,17 +19,18 @@ Retrieve Playback Info package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Playback.Get(ctx, "") if err != nil { log.Fatal(err) @@ -54,7 +55,7 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | | sdkerrors.Error | 404 | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/room/README.md b/docs/sdks/room/README.md index d04b47a..3efba97 100644 --- a/docs/sdks/room/README.md +++ b/docs/sdks/room/README.md @@ -30,17 +30,18 @@ Create a multiparticipant livestreaming room. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.Create(ctx) if err != nil { log.Fatal(err) @@ -64,10 +65,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~Get~~ @@ -81,17 +81,18 @@ Retrieve a room package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.Get(ctx, "") if err != nil { log.Fatal(err) @@ -116,10 +117,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~Delete~~ @@ -133,17 +133,18 @@ Delete a room package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -168,10 +169,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~StartEgress~~ @@ -187,18 +187,19 @@ This allows you to leverage livestreaming features like recording and HLS output package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.StartEgress(ctx, "", components.RoomEgressPayload{ StreamID: "aac12556-4d65-4d34-9fb6-d1f0985eb0a9", }) @@ -226,10 +227,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~StopEgress~~ @@ -243,17 +243,18 @@ Stop room RTMP egress package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.StopEgress(ctx, "") if err != nil { log.Fatal(err) @@ -278,10 +279,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~CreateUser~~ @@ -298,18 +298,19 @@ Alternatively the joining token can be used with a custom app. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.CreateUser(ctx, "", components.RoomUserPayload{ Name: "name", CanPublish: livepeergo.Bool(true), @@ -339,10 +340,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~GetUser~~ @@ -356,17 +356,18 @@ Get user details package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.GetUser(ctx, "", "") if err != nil { log.Fatal(err) @@ -392,10 +393,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~UpdateUser~~ @@ -409,18 +409,19 @@ Update properties for a user. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.UpdateUser(ctx, "", "", components.RoomUserUpdatePayload{ CanPublish: livepeergo.Bool(true), CanPublishData: livepeergo.Bool(true), @@ -450,10 +451,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ~~DeleteUser~~ @@ -467,17 +467,18 @@ Remove a user from the room package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Room.DeleteUser(ctx, "", "") if err != nil { log.Fatal(err) @@ -503,6 +504,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/session/README.md b/docs/sdks/session/README.md index 1fa375d..8fe4aba 100644 --- a/docs/sdks/session/README.md +++ b/docs/sdks/session/README.md @@ -22,17 +22,18 @@ Retrieve clips of a session package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Session.GetClips(ctx, "") if err != nil { log.Fatal(err) @@ -57,10 +58,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetAll @@ -72,17 +72,18 @@ Retrieve sessions package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Session.GetAll(ctx) if err != nil { log.Fatal(err) @@ -106,10 +107,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -121,17 +121,18 @@ Retrieve a session package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Session.Get(ctx, "") if err != nil { log.Fatal(err) @@ -156,10 +157,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetRecorded @@ -171,17 +171,18 @@ Retrieve Recorded Sessions package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Session.GetRecorded(ctx, "", livepeergo.Pointer(operations.CreateRecordBoolean( true, ))) @@ -209,6 +210,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/stream/README.md b/docs/sdks/stream/README.md index de10662..c18ddd7 100644 --- a/docs/sdks/stream/README.md +++ b/docs/sdks/stream/README.md @@ -42,18 +42,19 @@ also be added upon the creation of a new stream by adding package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Create(ctx, components.NewStreamPayload{ Name: "test_stream", Pull: &components.Pull{ @@ -107,13 +108,8 @@ func main() { Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), + Profile: "720p0", ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, }, }, }, @@ -141,10 +137,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetAll @@ -156,17 +151,18 @@ Retrieve streams package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.GetAll(ctx, nil) if err != nil { log.Fatal(err) @@ -191,10 +187,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -206,17 +201,18 @@ Retrieve a stream package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Get(ctx, "") if err != nil { log.Fatal(err) @@ -241,10 +237,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Update @@ -256,30 +251,26 @@ Update a stream package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Update(ctx, "", components.StreamPatchPayload{ Record: livepeergo.Bool(false), Multistream: &components.Multistream{ Targets: []components.Target{ components.Target{ - Profile: "720p", - VideoOnly: livepeergo.Bool(false), + Profile: "720p0", ID: livepeergo.String("PUSH123"), - Spec: &components.TargetSpec{ - Name: livepeergo.String("My target"), - URL: "rtmps://live.my-service.tv/channel/secretKey", - }, }, }, }, @@ -345,10 +336,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -364,17 +354,18 @@ using the PATCH stream API. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -399,10 +390,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Terminate @@ -422,17 +412,18 @@ terminated. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.Terminate(ctx, "") if err != nil { log.Fatal(err) @@ -457,10 +448,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## StartPull @@ -479,17 +469,18 @@ started. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.StartPull(ctx, "") if err != nil { log.Fatal(err) @@ -514,10 +505,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## CreateClip @@ -529,18 +519,19 @@ Create a clip package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.CreateClip(ctx, components.ClipPayload{ PlaybackID: "eaw4nk06ts2d0mzb", StartTime: 1587667174725, @@ -571,10 +562,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetClips @@ -586,17 +576,18 @@ Retrieve clips of a livestream package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.GetClips(ctx, "") if err != nil { log.Fatal(err) @@ -621,10 +612,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## AddMultistreamTarget @@ -636,18 +626,19 @@ Add a multistream target package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.AddMultistreamTarget(ctx, "", components.TargetAddPayload{ Profile: "720p0", VideoOnly: livepeergo.Bool(false), @@ -681,10 +672,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## RemoveMultistreamTarget @@ -696,17 +686,18 @@ Remove a multistream target package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Stream.RemoveMultistreamTarget(ctx, "", "") if err != nil { log.Fatal(err) @@ -732,6 +723,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/task/README.md b/docs/sdks/task/README.md index 2aa4483..5402fed 100644 --- a/docs/sdks/task/README.md +++ b/docs/sdks/task/README.md @@ -20,17 +20,18 @@ Retrieve Tasks package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Task.GetAll(ctx) if err != nil { log.Fatal(err) @@ -54,10 +55,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -69,17 +69,18 @@ Retrieve a Task package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Task.Get(ctx, "") if err != nil { log.Fatal(err) @@ -104,6 +105,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/transcode/README.md b/docs/sdks/transcode/README.md index cfd0e09..a78c6c2 100644 --- a/docs/sdks/transcode/README.md +++ b/docs/sdks/transcode/README.md @@ -140,18 +140,19 @@ This endpoint currently supports the following output types: package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Transcode.Create(ctx, components.TranscodePayload{ Input: components.CreateInputInput1( components.Input1{ @@ -218,6 +219,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/webhook/README.md b/docs/sdks/webhook/README.md index a6c5fff..dbcba0d 100644 --- a/docs/sdks/webhook/README.md +++ b/docs/sdks/webhook/README.md @@ -26,17 +26,18 @@ Retrieve a Webhook package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.GetAll(ctx) if err != nil { log.Fatal(err) @@ -60,10 +61,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Create @@ -76,18 +76,19 @@ To create a new webhook, you need to make an API call with the events you want t package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.Create(ctx, components.WebhookInput{ Name: "test_webhook", ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"), @@ -122,10 +123,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Get @@ -137,17 +137,18 @@ Retrieve a webhook package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.Get(ctx, "") if err != nil { log.Fatal(err) @@ -172,10 +173,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Update @@ -187,18 +187,19 @@ Update a webhook package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "github.com/livepeer/livepeer-go/models/components" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.Update(ctx, "", components.WebhookInput{ Name: "test_webhook", ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"), @@ -234,10 +235,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## Delete @@ -249,17 +249,18 @@ Delete a webhook package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.Delete(ctx, "") if err != nil { log.Fatal(err) @@ -284,10 +285,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetLogs @@ -299,17 +299,18 @@ Retrieve webhook logs package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.GetLogs(ctx, "") if err != nil { log.Fatal(err) @@ -334,10 +335,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## GetLog @@ -349,17 +349,18 @@ Retrieve a webhook log package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.GetLog(ctx, "", "") if err != nil { log.Fatal(err) @@ -385,10 +386,9 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | - +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | ## ResendLog @@ -403,17 +403,18 @@ to check or fix the behaviour in your handler. package main import( - livepeergo "github.com/livepeer/livepeer-go" "context" + livepeergo "github.com/livepeer/livepeer-go" "log" ) func main() { + ctx := context.Background() + s := livepeergo.New( livepeergo.WithSecurity(""), ) - ctx := context.Background() res, err := s.Webhook.ResendLog(ctx, "", "") if err != nil { log.Fatal(err) @@ -439,6 +440,6 @@ func main() { ### Errors -| Error Object | Status Code | Content Type | +| Error Type | Status Code | Content Type | | ------------------ | ------------------ | ------------------ | -| sdkerrors.SDKError | 4xx-5xx | */* | +| sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/generate.go b/generate.go index a907bf0..9aef1c6 100644 --- a/generate.go +++ b/generate.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -50,8 +49,13 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/text-to-image") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/text-to-image") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -84,6 +88,10 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -114,7 +122,11 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -176,21 +188,11 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -202,17 +204,16 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -224,17 +225,16 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -246,17 +246,16 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -268,17 +267,16 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -290,26 +288,24 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -321,11 +317,10 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -356,8 +351,13 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/image-to-image") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/image-to-image") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -390,6 +390,10 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -420,7 +424,11 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -482,21 +490,11 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -508,17 +506,16 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -530,17 +527,16 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -552,17 +548,16 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -574,17 +569,16 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -596,26 +590,24 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -627,11 +619,10 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -662,8 +653,13 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/image-to-video") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/image-to-video") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -696,6 +692,10 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -726,7 +726,11 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -788,21 +792,11 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -814,17 +808,16 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI res.VideoResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -836,17 +829,16 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -858,17 +850,16 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -880,17 +871,16 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -902,26 +892,24 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -933,11 +921,10 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -968,8 +955,13 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/upscale") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/upscale") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -1002,6 +994,10 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1032,7 +1028,11 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1094,21 +1094,11 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1120,17 +1110,16 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1142,17 +1131,16 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1164,17 +1152,16 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1186,17 +1173,16 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1208,26 +1194,24 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1239,11 +1223,10 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1274,8 +1257,13 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/audio-to-text") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/audio-to-text") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -1308,6 +1296,10 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1338,7 +1330,11 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1378,7 +1374,7 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "413", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "413", "415", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1400,21 +1396,11 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1426,17 +1412,16 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu res.TextResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1448,17 +1433,16 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1470,17 +1454,16 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 413: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1492,17 +1475,37 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 415: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.GenAudioToTextGenerateResponse415ResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1514,17 +1517,16 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1536,26 +1538,24 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1567,11 +1567,10 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1602,8 +1601,13 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/api/beta/generate/segment-anything-2") + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/segment-anything-2") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -1636,6 +1640,10 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1666,7 +1674,11 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1728,21 +1740,11 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1754,17 +1756,16 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body res.MasksResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1776,17 +1777,16 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 401: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1798,17 +1798,16 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1820,17 +1819,16 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1842,26 +1840,24 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1873,11 +1869,312 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body res.StudioAPIError = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// Llm - LLM +// Generate text using a language model. +func (s *Generate) Llm(ctx context.Context, request components.BodyGenLLM, opts ...operations.Option) (*operations.GenLLMResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "genLLM", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/api/generate/llm") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "form", `request:"mediaType=application/x-www-form-urlencoded"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GenLLMResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.LLMResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LLMResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.GenLLMResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.GenLLMGenerateResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 422: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.GenLLMGenerateResponseResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.GenLLMGenerateResponse500ResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.StudioAPIError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.StudioAPIError = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/go.mod b/go.mod index deed817..eadb156 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module github.com/livepeer/livepeer-go go 1.20 -require ( - github.com/cenkalti/backoff/v4 v4.2.0 - github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 -) +require github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 diff --git a/go.sum b/go.sum index f955779..c5a75f1 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,2 @@ -github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= -github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= diff --git a/internal/utils/env.go b/internal/utils/env.go new file mode 100644 index 0000000..110d464 --- /dev/null +++ b/internal/utils/env.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "os" +) + +// GetEnv returns the value of the environment variable named by the key or the defaultValue if the environment variable is not set. +func GetEnv(name, defaultValue string) string { + value := os.Getenv(name) + if value == "" { + return defaultValue + } + return value +} diff --git a/internal/utils/queryparams.go b/internal/utils/queryparams.go index a7085f5..ce33860 100644 --- a/internal/utils/queryparams.go +++ b/internal/utils/queryparams.go @@ -214,7 +214,11 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru continue } - scope := priorScope + "[" + qpTag.ParamName + "]" + scope := priorScope + + if !qpTag.Inline { + scope = priorScope + "[" + qpTag.ParamName + "]" + } switch fieldValue.Kind() { case reflect.Array, reflect.Slice: @@ -252,6 +256,13 @@ type paramTag struct { Explode bool ParamName string Serialization string + + // Inline is a special case for union/oneOf. When a wrapper struct type is + // used, each union/oneOf value field should be inlined (e.g. not appended + // in deepObject style with the name) as if the value was directly on the + // parent struct field. Without this annotation, the value would not be + // encoded by downstream logic that requires the struct field tag. + Inline bool } func parseQueryParamTag(field reflect.StructField) *paramTag { diff --git a/internal/utils/requestbody.go b/internal/utils/requestbody.go index 000226e..78479c6 100644 --- a/internal/utils/requestbody.go +++ b/internal/utils/requestbody.go @@ -166,7 +166,7 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { tag := parseMultipartFormTag(field) if tag.File { - if err := encodeMultipartFormDataFile(writer, fieldType, valType); err != nil { + if err := encodeMultipartFormDataFile(writer, tag.Name, fieldType, valType); err != nil { writer.Close() return "", err } @@ -211,12 +211,11 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { return writer.FormDataContentType(), nil } -func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, valType reflect.Value) error { +func encodeMultipartFormDataFile(w *multipart.Writer, fieldName string, fieldType reflect.Type, valType reflect.Value) error { if fieldType.Kind() != reflect.Struct { return fmt.Errorf("invalid type %s for multipart/form-data file", valType.Type()) } - var fieldName string var fileName string var reader io.Reader @@ -236,12 +235,11 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va reader = val.Interface().(io.Reader) } } else { - fieldName = tag.Name fileName = val.String() } } - if fieldName == "" || fileName == "" || reader == nil { + if fileName == "" || reader == nil { return fmt.Errorf("invalid multipart/form-data file") } diff --git a/internal/utils/retries.go b/internal/utils/retries.go index d277938..ec1ff85 100644 --- a/internal/utils/retries.go +++ b/internal/utils/retries.go @@ -6,8 +6,9 @@ import ( "context" "errors" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/retry" + "math" + "math/rand" "net/http" "net/url" "strconv" @@ -15,8 +16,6 @@ import ( "time" ) -var errRequestFailed = errors.New("request failed") - // Deprecated: Use retry.BackoffStrategy instead. type BackoffStrategy = retry.BackoffStrategy @@ -28,34 +27,27 @@ type Retries struct { StatusCodes []string } -func Retry(ctx context.Context, r Retries, action func() (*http.Response, error)) (*http.Response, error) { +func Retry(ctx context.Context, r Retries, operation func() (*http.Response, error)) (*http.Response, error) { switch r.Config.Strategy { case "backoff": if r.Config.Backoff == nil { - return action() + return operation() } - config := backoff.NewExponentialBackOff() - config.InitialInterval = time.Duration(r.Config.Backoff.InitialInterval) * time.Millisecond - config.MaxInterval = time.Duration(r.Config.Backoff.MaxInterval) * time.Millisecond - config.Multiplier = r.Config.Backoff.Exponent - config.MaxElapsedTime = time.Duration(r.Config.Backoff.MaxElapsedTime) * time.Millisecond - config.Reset() - var resp *http.Response - err := backoff.Retry(func() error { + err := retryWithBackoff(ctx, r.Config.Backoff, func() error { if resp != nil { resp.Body.Close() } select { case <-ctx.Done(): - return backoff.Permanent(ctx.Err()) + return retry.Permanent(ctx.Err()) default: } - res, err := action() + res, err := operation() if err != nil { urlError := new(url.Error) if errors.As(err, &urlError) { @@ -64,7 +56,7 @@ func Retry(ctx context.Context, r Retries, action func() (*http.Response, error) } } - return backoff.Permanent(err) + return retry.Permanent(err) } resp = res if res == nil { @@ -81,7 +73,7 @@ func Retry(ctx context.Context, r Retries, action func() (*http.Response, error) s := res.StatusCode / 100 if s >= codeRange && s < codeRange+1 { - return errRequestFailed + return retry.TemporaryFromResponse("request failed", res) } } else { parsedCode, err := strconv.Atoi(code) @@ -90,7 +82,7 @@ func Retry(ctx context.Context, r Retries, action func() (*http.Response, error) } if res.StatusCode == parsedCode { - return errRequestFailed + return retry.TemporaryFromResponse("request failed", res) } } } @@ -98,13 +90,131 @@ func Retry(ctx context.Context, r Retries, action func() (*http.Response, error) resp = res return nil - }, config) - if err != nil && !errors.Is(err, errRequestFailed) { + }) + + var tempErr *retry.TemporaryError + if err != nil && !errors.As(err, &tempErr) { return nil, err } return resp, nil default: - return action() + return operation() + } +} + +func retryWithBackoff(ctx context.Context, s *retry.BackoffStrategy, operation func() error) error { + var ( + err error + next time.Duration + attempt int + start = time.Now() + maxElapsedTime = time.Duration(s.MaxElapsedTime) * time.Millisecond + ) + + timer := &defaultTimer{} + defer func() { + timer.Stop() + }() + + for { + err = operation() + if err == nil { + return nil + } + + var permanent *retry.PermanentError + if errors.As(err, &permanent) { + return permanent.Unwrap() + } + + if time.Since(start) >= maxElapsedTime { + return err + } + + var temporary *retry.TemporaryError + if errors.As(err, &temporary) { + next = temporary.RetryAfter() + } + + if next <= 0 { + next = nextInterval(s, attempt) + } + + timer.Start(next) + + select { + case <-ctx.Done(): + return ctx.Err() + case <-timer.C(): + } + + attempt += 1 } } + +type Timer interface { + Start(duration time.Duration) + Stop() + C() <-chan time.Time +} + +// defaultTimer implements Timer interface using time.Timer +type defaultTimer struct { + timer *time.Timer +} + +// C returns the timers channel which receives the current time when the timer fires. +func (t *defaultTimer) C() <-chan time.Time { + return t.timer.C +} + +// Start starts the timer to fire after the given duration +func (t *defaultTimer) Start(duration time.Duration) { + if t.timer == nil { + t.timer = time.NewTimer(duration) + return + } + + if !t.timer.Stop() { + select { + case <-t.timer.C: + default: + } + } + + t.timer.Reset(duration) +} + +// Stop is called when the timer is not used anymore and resources may be freed. +func (t *defaultTimer) Stop() { + if t.timer != nil { + t.timer.Stop() + } +} + +func nextInterval(s *retry.BackoffStrategy, attempt int) time.Duration { + initialInterval := float64(time.Duration(s.InitialInterval) * time.Millisecond) + maxInterval := float64(time.Duration(s.MaxInterval) * time.Millisecond) + exponent := s.Exponent + jitterFactor := float64(0.25) + + interval := initialInterval * math.Pow(float64(attempt+1), exponent) + + jitter := rand.Float64() * jitterFactor * interval + if rand.Float64() < 0.5 { + jitter = -1 * jitter + } + + interval = interval + jitter + + if interval <= 0 { + interval = initialInterval + } + + if interval > maxInterval { + interval = maxInterval + } + + return time.Duration(interval) +} diff --git a/internal/utils/utils.go b/internal/utils/utils.go index adb2f70..031a71a 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -3,10 +3,12 @@ package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -125,6 +127,7 @@ func parseStructTag(tagKey string, field reflect.StructField) map[string]string func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string, defaultExplode bool) *paramTag { // example `{tagKey}:"style=simple,explode=false,name=apiID"` + // example `{tagKey}:"inline"` values := parseStructTag(tagKey, field) if values == nil { return nil @@ -138,6 +141,8 @@ func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string for k, v := range values { switch k { + case "inline": + tag.Inline = v == "true" case "style": tag.Style = v case "explode": @@ -228,3 +233,15 @@ func contains(arr []string, str string) bool { } return false } + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/livepeer.go b/livepeer.go index 7043a47..c747eb4 100644 --- a/livepeer.go +++ b/livepeer.go @@ -173,9 +173,9 @@ func New(opts ...SDKOption) *Livepeer { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.4.0", - GenVersion: "2.415.8", - UserAgent: "speakeasy-sdk/go 0.4.0 2.415.8 1.0.0 github.com/livepeer/livepeer-go", + SDKVersion: "0.5.0", + GenVersion: "2.484.0", + UserAgent: "speakeasy-sdk/go 0.5.0 2.484.0 1.0.0 github.com/livepeer/livepeer-go", Hooks: hooks.New(), }, } diff --git a/metrics.go b/metrics.go index da53da1..38ab543 100644 --- a/metrics.go +++ b/metrics.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -56,7 +55,12 @@ func (s *Metrics) GetRealtimeViewership(ctx context.Context, playbackID *string, } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/data/views/now") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -88,6 +92,10 @@ func (s *Metrics) GetRealtimeViewership(ctx context.Context, playbackID *string, return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -118,7 +126,11 @@ func (s *Metrics) GetRealtimeViewership(ctx context.Context, playbackID *string, req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -180,21 +192,11 @@ func (s *Metrics) GetRealtimeViewership(ctx context.Context, playbackID *string, }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -206,42 +208,39 @@ func (s *Metrics) GetRealtimeViewership(ctx context.Context, playbackID *string, res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -272,7 +271,12 @@ func (s *Metrics) GetViewership(ctx context.Context, request operations.GetViewe } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/data/views/query") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -304,6 +308,10 @@ func (s *Metrics) GetViewership(ctx context.Context, request operations.GetViewe return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -334,7 +342,11 @@ func (s *Metrics) GetViewership(ctx context.Context, request operations.GetViewe req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -396,21 +408,11 @@ func (s *Metrics) GetViewership(ctx context.Context, request operations.GetViewe }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -422,42 +424,39 @@ func (s *Metrics) GetViewership(ctx context.Context, request operations.GetViewe res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -488,7 +487,12 @@ func (s *Metrics) GetCreatorViewership(ctx context.Context, request operations.G } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/data/views/query/creator") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -520,6 +524,10 @@ func (s *Metrics) GetCreatorViewership(ctx context.Context, request operations.G return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -550,7 +558,11 @@ func (s *Metrics) GetCreatorViewership(ctx context.Context, request operations.G req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -612,21 +624,11 @@ func (s *Metrics) GetCreatorViewership(ctx context.Context, request operations.G }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -638,42 +640,39 @@ func (s *Metrics) GetCreatorViewership(ctx context.Context, request operations.G res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -710,7 +709,12 @@ func (s *Metrics) GetPublicViewership(ctx context.Context, playbackID string, op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/data/views/query/total/{playbackId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -738,6 +742,10 @@ func (s *Metrics) GetPublicViewership(ctx context.Context, playbackID string, op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -768,7 +776,11 @@ func (s *Metrics) GetPublicViewership(ctx context.Context, playbackID string, op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -830,21 +842,11 @@ func (s *Metrics) GetPublicViewership(ctx context.Context, playbackID string, op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -856,42 +858,39 @@ func (s *Metrics) GetPublicViewership(ctx context.Context, playbackID string, op res.Data = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -921,7 +920,12 @@ func (s *Metrics) GetUsage(ctx context.Context, request operations.GetUsageMetri } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/data/usage/query") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -953,6 +957,10 @@ func (s *Metrics) GetUsage(ctx context.Context, request operations.GetUsageMetri return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -983,7 +991,11 @@ func (s *Metrics) GetUsage(ctx context.Context, request operations.GetUsageMetri req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1045,21 +1057,11 @@ func (s *Metrics) GetUsage(ctx context.Context, request operations.GetUsageMetri }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1071,42 +1073,39 @@ func (s *Metrics) GetUsage(ctx context.Context, request operations.GetUsageMetri res.UsageMetric = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/models/components/asset.go b/models/components/asset.go index e75732b..df42158 100644 --- a/models/components/asset.go +++ b/models/components/asset.go @@ -238,9 +238,9 @@ const ( ) type Source struct { - Source1 *Source1 - Two *Two - Source3 *Source3 + Source1 *Source1 `queryParam:"inline"` + Two *Two `queryParam:"inline"` + Source3 *Source3 `queryParam:"inline"` Type SourceUnionType } diff --git a/models/components/bodygenaudiototext.go b/models/components/bodygenaudiototext.go index 670a740..cafd4ac 100644 --- a/models/components/bodygenaudiototext.go +++ b/models/components/bodygenaudiototext.go @@ -7,7 +7,7 @@ import ( ) type Audio struct { - FileName string `multipartForm:"name=audio"` + FileName string `multipartForm:"name=fileName"` // This field accepts []byte data or io.Reader implementations, such as *os.File. Content any `multipartForm:"content"` } @@ -28,9 +28,11 @@ func (o *Audio) GetContent() any { type BodyGenAudioToText struct { // Uploaded audio file to be transcribed. - Audio Audio `multipartForm:"file"` + Audio Audio `multipartForm:"file,name=audio"` // Hugging Face model ID used for transcription. ModelID *string `default:"openai/whisper-large-v3" multipartForm:"name=model_id"` + // Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. + ReturnTimestamps *string `default:"true" multipartForm:"name=return_timestamps"` } func (b BodyGenAudioToText) MarshalJSON() ([]byte, error) { @@ -57,3 +59,10 @@ func (o *BodyGenAudioToText) GetModelID() *string { } return o.ModelID } + +func (o *BodyGenAudioToText) GetReturnTimestamps() *string { + if o == nil { + return nil + } + return o.ReturnTimestamps +} diff --git a/models/components/bodygenimagetoimage.go b/models/components/bodygenimagetoimage.go index 743cffe..d3a8730 100644 --- a/models/components/bodygenimagetoimage.go +++ b/models/components/bodygenimagetoimage.go @@ -7,7 +7,7 @@ import ( ) type Image struct { - FileName string `multipartForm:"name=image"` + FileName string `multipartForm:"name=fileName"` // This field accepts []byte data or io.Reader implementations, such as *os.File. Content any `multipartForm:"content"` } @@ -30,9 +30,11 @@ type BodyGenImageToImage struct { // Text prompt(s) to guide image generation. Prompt string `multipartForm:"name=prompt"` // Uploaded image to modify with the pipeline. - Image Image `multipartForm:"file"` + Image Image `multipartForm:"file,name=image"` // Hugging Face model ID used for image generation. ModelID *string `default:"timbrooks/instruct-pix2pix" multipartForm:"name=model_id"` + // A LoRA (Low-Rank Adaptation) model and its corresponding weight for image generation. Example: { "latent-consistency/lcm-lora-sdxl": 1.0, "nerijs/pixel-art-xl": 1.2}. + Loras *string `default:"" multipartForm:"name=loras"` // Degree of transformation applied to the reference image (0 to 1). Strength *float64 `default:"0.8" multipartForm:"name=strength"` // Encourages model to generate images closely linked to the text prompt (higher values may reduce image quality). @@ -83,6 +85,13 @@ func (o *BodyGenImageToImage) GetModelID() *string { return o.ModelID } +func (o *BodyGenImageToImage) GetLoras() *string { + if o == nil { + return nil + } + return o.Loras +} + func (o *BodyGenImageToImage) GetStrength() *float64 { if o == nil { return nil diff --git a/models/components/bodygenimagetovideo.go b/models/components/bodygenimagetovideo.go index fedf3d9..2343160 100644 --- a/models/components/bodygenimagetovideo.go +++ b/models/components/bodygenimagetovideo.go @@ -7,7 +7,7 @@ import ( ) type BodyGenImageToVideoImage struct { - FileName string `multipartForm:"name=image"` + FileName string `multipartForm:"name=fileName"` // This field accepts []byte data or io.Reader implementations, such as *os.File. Content any `multipartForm:"content"` } @@ -28,7 +28,7 @@ func (o *BodyGenImageToVideoImage) GetContent() any { type BodyGenImageToVideo struct { // Uploaded image to generate a video from. - Image BodyGenImageToVideoImage `multipartForm:"file"` + Image BodyGenImageToVideoImage `multipartForm:"file,name=image"` // Hugging Face model ID used for video generation. ModelID *string `default:"stabilityai/stable-video-diffusion-img2vid-xt-1-1" multipartForm:"name=model_id"` // The height in pixels of the generated video. diff --git a/models/components/bodygenllm.go b/models/components/bodygenllm.go new file mode 100644 index 0000000..d6728da --- /dev/null +++ b/models/components/bodygenllm.go @@ -0,0 +1,77 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/livepeer/livepeer-go/internal/utils" +) + +type BodyGenLLM struct { + Prompt string `form:"name=prompt"` + ModelID *string `default:"meta-llama/Meta-Llama-3.1-8B-Instruct" form:"name=model_id"` + SystemMsg *string `default:"" form:"name=system_msg"` + Temperature *float64 `default:"0.7" form:"name=temperature"` + MaxTokens *int64 `default:"256" form:"name=max_tokens"` + History *string `default:"[]" form:"name=history"` + Stream *bool `default:"false" form:"name=stream"` +} + +func (b BodyGenLLM) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BodyGenLLM) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BodyGenLLM) GetPrompt() string { + if o == nil { + return "" + } + return o.Prompt +} + +func (o *BodyGenLLM) GetModelID() *string { + if o == nil { + return nil + } + return o.ModelID +} + +func (o *BodyGenLLM) GetSystemMsg() *string { + if o == nil { + return nil + } + return o.SystemMsg +} + +func (o *BodyGenLLM) GetTemperature() *float64 { + if o == nil { + return nil + } + return o.Temperature +} + +func (o *BodyGenLLM) GetMaxTokens() *int64 { + if o == nil { + return nil + } + return o.MaxTokens +} + +func (o *BodyGenLLM) GetHistory() *string { + if o == nil { + return nil + } + return o.History +} + +func (o *BodyGenLLM) GetStream() *bool { + if o == nil { + return nil + } + return o.Stream +} diff --git a/models/components/bodygensegmentanything2.go b/models/components/bodygensegmentanything2.go index 02d9334..dd2583a 100644 --- a/models/components/bodygensegmentanything2.go +++ b/models/components/bodygensegmentanything2.go @@ -7,7 +7,7 @@ import ( ) type BodyGenSegmentAnything2Image struct { - FileName string `multipartForm:"name=image"` + FileName string `multipartForm:"name=fileName"` // This field accepts []byte data or io.Reader implementations, such as *os.File. Content any `multipartForm:"content"` } @@ -28,9 +28,9 @@ func (o *BodyGenSegmentAnything2Image) GetContent() any { type BodyGenSegmentAnything2 struct { // Image to segment. - Image BodyGenSegmentAnything2Image `multipartForm:"file"` + Image BodyGenSegmentAnything2Image `multipartForm:"file,name=image"` // Hugging Face model ID used for image generation. - ModelID *string `default:"facebook/sam2-hiera-large:" multipartForm:"name=model_id"` + ModelID *string `default:"facebook/sam2-hiera-large" multipartForm:"name=model_id"` // Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels. PointCoords *string `multipartForm:"name=point_coords"` // Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point. diff --git a/models/components/bodygenupscale.go b/models/components/bodygenupscale.go index 391394a..704b116 100644 --- a/models/components/bodygenupscale.go +++ b/models/components/bodygenupscale.go @@ -7,7 +7,7 @@ import ( ) type BodyGenUpscaleImage struct { - FileName string `multipartForm:"name=image"` + FileName string `multipartForm:"name=fileName"` // This field accepts []byte data or io.Reader implementations, such as *os.File. Content any `multipartForm:"content"` } @@ -30,7 +30,7 @@ type BodyGenUpscale struct { // Text prompt(s) to guide upscaled image generation. Prompt string `multipartForm:"name=prompt"` // Uploaded image to modify with the pipeline. - Image BodyGenUpscaleImage `multipartForm:"file"` + Image BodyGenUpscaleImage `multipartForm:"file,name=image"` // Hugging Face model ID used for upscaled image generation. ModelID *string `default:"stabilityai/stable-diffusion-x4-upscaler" multipartForm:"name=model_id"` // Perform a safety check to estimate if generated images could be offensive or harmful. diff --git a/models/components/creatorid.go b/models/components/creatorid.go index 05a15e1..86a4f7a 100644 --- a/models/components/creatorid.go +++ b/models/components/creatorid.go @@ -59,7 +59,7 @@ const ( ) type CreatorID struct { - CreatorID1 *CreatorID1 + CreatorID1 *CreatorID1 `queryParam:"inline"` Type CreatorIDUnionType } diff --git a/models/components/error.go b/models/components/error.go new file mode 100644 index 0000000..e88a632 --- /dev/null +++ b/models/components/error.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Error struct { + Errors []string `json:"errors,omitempty"` +} + +func (o *Error) GetErrors() []string { + if o == nil { + return nil + } + return o.Errors +} diff --git a/models/components/exporttaskparams.go b/models/components/exporttaskparams.go index 650c1c6..8a3b21a 100644 --- a/models/components/exporttaskparams.go +++ b/models/components/exporttaskparams.go @@ -82,8 +82,8 @@ const ( // ExportTaskParams - Parameters for the export task type ExportTaskParams struct { - ExportTaskParams1 *ExportTaskParams1 - ExportTaskParams2 *ExportTaskParams2 + ExportTaskParams1 *ExportTaskParams1 `queryParam:"inline"` + ExportTaskParams2 *ExportTaskParams2 `queryParam:"inline"` Type ExportTaskParamsType } diff --git a/models/components/inputcreatorid.go b/models/components/inputcreatorid.go index 47dcb59..7980a5f 100644 --- a/models/components/inputcreatorid.go +++ b/models/components/inputcreatorid.go @@ -59,8 +59,8 @@ const ( ) type InputCreatorID struct { - InputCreatorID1 *InputCreatorID1 - Str *string + InputCreatorID1 *InputCreatorID1 `queryParam:"inline"` + Str *string `queryParam:"inline"` Type InputCreatorIDUnionType } diff --git a/models/components/ipfsexportparams.go b/models/components/ipfsexportparams.go index a25bfdd..ada7565 100644 --- a/models/components/ipfsexportparams.go +++ b/models/components/ipfsexportparams.go @@ -33,8 +33,8 @@ const ( // Pinata - Custom credentials for the Piñata service. Must have either // a JWT or an API key and an API secret. type Pinata struct { - Pinata1 *Pinata1 - Pinata2 *Pinata2 + Pinata1 *Pinata1 `queryParam:"inline"` + Pinata2 *Pinata2 `queryParam:"inline"` Type PinataType } diff --git a/models/components/llmresponse.go b/models/components/llmresponse.go new file mode 100644 index 0000000..7b5b217 --- /dev/null +++ b/models/components/llmresponse.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type LLMResponse struct { + Response string `json:"response"` + TokensUsed int64 `json:"tokens_used"` +} + +func (o *LLMResponse) GetResponse() string { + if o == nil { + return "" + } + return o.Response +} + +func (o *LLMResponse) GetTokensUsed() int64 { + if o == nil { + return 0 + } + return o.TokensUsed +} diff --git a/models/components/newassetpayload.go b/models/components/newassetpayload.go index 92a6c8f..0b7dd05 100644 --- a/models/components/newassetpayload.go +++ b/models/components/newassetpayload.go @@ -30,8 +30,8 @@ const ( // pinned files, specify an object with a spec field. False or null // means to unpin from IPFS, but it's unsupported right now. type NewAssetPayloadIpfs struct { - NewAssetPayloadIpfs1 *NewAssetPayloadIpfs1 - Boolean *bool + NewAssetPayloadIpfs1 *NewAssetPayloadIpfs1 `queryParam:"inline"` + Boolean *bool `queryParam:"inline"` Type NewAssetPayloadIpfsType } diff --git a/models/components/pull.go b/models/components/pull.go index 521a307..0ddb0de 100644 --- a/models/components/pull.go +++ b/models/components/pull.go @@ -48,8 +48,8 @@ const ( // IsMobile - Indicates whether the stream will be pulled from a mobile source. type IsMobile struct { - One *One - Boolean *bool + One *One `queryParam:"inline"` + Boolean *bool `queryParam:"inline"` Type IsMobileType } diff --git a/models/components/storage.go b/models/components/storage.go index 5544cb1..6379c45 100644 --- a/models/components/storage.go +++ b/models/components/storage.go @@ -30,8 +30,8 @@ const ( // pinned files, specify an object with a spec field. False or null // means to unpin from IPFS, but it's unsupported right now. type Ipfs struct { - Ipfs1 *Ipfs1 - Boolean *bool + Ipfs1 *Ipfs1 `queryParam:"inline"` + Boolean *bool `queryParam:"inline"` Type IpfsType } diff --git a/models/components/stream.go b/models/components/stream.go index e68627f..9df0641 100644 --- a/models/components/stream.go +++ b/models/components/stream.go @@ -17,8 +17,8 @@ const ( ) type Three struct { - Str *string - Number *float64 + Str *string `queryParam:"inline"` + Number *float64 `queryParam:"inline"` Type ThreeType } @@ -81,9 +81,9 @@ const ( ) type StreamUserTags struct { - Str *string - Number *float64 - ArrayOf3 []Three + Str *string `queryParam:"inline"` + Number *float64 `queryParam:"inline"` + ArrayOf3 []Three `queryParam:"inline"` Type StreamUserTagsType } @@ -196,8 +196,8 @@ const ( // StreamIsMobile - Indicates whether the stream will be pulled from a mobile source. type StreamIsMobile struct { - IsMobile1 *IsMobile1 - Boolean *bool + IsMobile1 *IsMobile1 `queryParam:"inline"` + Boolean *bool `queryParam:"inline"` Type StreamIsMobileType } diff --git a/models/components/streampatchpayload.go b/models/components/streampatchpayload.go index 2672434..4863a25 100644 --- a/models/components/streampatchpayload.go +++ b/models/components/streampatchpayload.go @@ -17,6 +17,7 @@ type StreamPatchPayload struct { RecordingSpec *RecordingSpec `json:"recordingSpec,omitempty"` // User input tags associated with the stream UserTags map[string]UserTags `json:"userTags,omitempty"` + Name *string `json:"name,omitempty"` } func (o *StreamPatchPayload) GetCreatorID() *InputCreatorID { @@ -74,3 +75,10 @@ func (o *StreamPatchPayload) GetUserTags() map[string]UserTags { } return o.UserTags } + +func (o *StreamPatchPayload) GetName() *string { + if o == nil { + return nil + } + return o.Name +} diff --git a/models/components/texttoimageparams.go b/models/components/texttoimageparams.go index 6078067..bd1fed9 100644 --- a/models/components/texttoimageparams.go +++ b/models/components/texttoimageparams.go @@ -9,6 +9,8 @@ import ( type TextToImageParams struct { // Hugging Face model ID used for image generation. ModelID *string `default:"SG161222/RealVisXL_V4.0_Lightning" json:"model_id"` + // A LoRA (Low-Rank Adaptation) model and its corresponding weight for image generation. Example: { "latent-consistency/lcm-lora-sdxl": 1.0, "nerijs/pixel-art-xl": 1.2}. + Loras *string `default:"" json:"loras"` // Text prompt(s) to guide image generation. Separate multiple prompts with '|' if supported by the model. Prompt string `json:"prompt"` // The height in pixels of the generated image. @@ -47,6 +49,13 @@ func (o *TextToImageParams) GetModelID() *string { return o.ModelID } +func (o *TextToImageParams) GetLoras() *string { + if o == nil { + return nil + } + return o.Loras +} + func (o *TextToImageParams) GetPrompt() string { if o == nil { return "" diff --git a/models/components/transcodepayload.go b/models/components/transcodepayload.go index 2ec9748..29f8cc0 100644 --- a/models/components/transcodepayload.go +++ b/models/components/transcodepayload.go @@ -128,8 +128,8 @@ const ( ) type Input struct { - Input1 *Input1 - Input2 *Input2 + Input1 *Input1 `queryParam:"inline"` + Input2 *Input2 `queryParam:"inline"` Type InputUnionType } @@ -339,8 +339,8 @@ const ( ) type TranscodePayloadStorage struct { - Storage1 *Storage1 - Storage2 *Storage2 + Storage1 *Storage1 `queryParam:"inline"` + Storage2 *Storage2 `queryParam:"inline"` Type TranscodePayloadStorageUnionType } diff --git a/models/components/usertags.go b/models/components/usertags.go index 96cd6f4..9ea26f6 100644 --- a/models/components/usertags.go +++ b/models/components/usertags.go @@ -16,8 +16,8 @@ const ( ) type UserTags3 struct { - Str *string - Number *float64 + Str *string `queryParam:"inline"` + Number *float64 `queryParam:"inline"` Type UserTags3Type } @@ -80,9 +80,9 @@ const ( ) type UserTags struct { - Str *string - Number *float64 - ArrayOfUserTags3 []UserTags3 + Str *string `queryParam:"inline"` + Number *float64 `queryParam:"inline"` + ArrayOfUserTags3 []UserTags3 `queryParam:"inline"` Type UserTagsType } diff --git a/models/components/validationerror.go b/models/components/validationerror.go index 81b4734..a5889ad 100644 --- a/models/components/validationerror.go +++ b/models/components/validationerror.go @@ -16,8 +16,8 @@ const ( ) type Loc struct { - Str *string - Integer *int64 + Str *string `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type LocType } diff --git a/models/operations/addmultistreamtarget.go b/models/operations/addmultistreamtarget.go index 71c29b0..d75193b 100644 --- a/models/operations/addmultistreamtarget.go +++ b/models/operations/addmultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type AddMultistreamTargetRequest struct { @@ -30,7 +29,7 @@ func (o *AddMultistreamTargetRequest) GetTargetAddPayload() components.TargetAdd type AddMultistreamTargetResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *AddMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *AddMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *AddMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *AddMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createclip.go b/models/operations/createclip.go index 8a7479f..2f942d3 100644 --- a/models/operations/createclip.go +++ b/models/operations/createclip.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateClipTask struct { @@ -43,7 +42,7 @@ type CreateClipResponse struct { // Success Data *CreateClipData // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateClipResponse) GetHTTPMeta() components.HTTPMetadata { @@ -60,7 +59,7 @@ func (o *CreateClipResponse) GetData() *CreateClipData { return o.Data } -func (o *CreateClipResponse) GetError() *sdkerrors.Error { +func (o *CreateClipResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createmultistreamtarget.go b/models/operations/createmultistreamtarget.go index a433244..0eaad58 100644 --- a/models/operations/createmultistreamtarget.go +++ b/models/operations/createmultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateMultistreamTargetResponse struct { @@ -12,7 +11,7 @@ type CreateMultistreamTargetResponse struct { // Success MultistreamTarget *components.MultistreamTarget // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *CreateMultistreamTargetResponse) GetMultistreamTarget() *components.Mul return o.MultistreamTarget } -func (o *CreateMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *CreateMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createroom.go b/models/operations/createroom.go index 54febcc..4cbca0d 100644 --- a/models/operations/createroom.go +++ b/models/operations/createroom.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateRoomResponse struct { @@ -12,7 +11,7 @@ type CreateRoomResponse struct { // Success CreateRoomResponse *components.CreateRoomResponse // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateRoomResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *CreateRoomResponse) GetCreateRoomResponse() *components.CreateRoomRespo return o.CreateRoomResponse } -func (o *CreateRoomResponse) GetError() *sdkerrors.Error { +func (o *CreateRoomResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createroomuser.go b/models/operations/createroomuser.go index 97b9e06..da16d6c 100644 --- a/models/operations/createroomuser.go +++ b/models/operations/createroomuser.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateRoomUserRequest struct { @@ -31,7 +30,7 @@ type CreateRoomUserResponse struct { // Success RoomUserResponse *components.RoomUserResponse // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { @@ -48,7 +47,7 @@ func (o *CreateRoomUserResponse) GetRoomUserResponse() *components.RoomUserRespo return o.RoomUserResponse } -func (o *CreateRoomUserResponse) GetError() *sdkerrors.Error { +func (o *CreateRoomUserResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createsigningkey.go b/models/operations/createsigningkey.go index c4034de..db7f6e7 100644 --- a/models/operations/createsigningkey.go +++ b/models/operations/createsigningkey.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateSigningKeyResponse struct { @@ -12,7 +11,7 @@ type CreateSigningKeyResponse struct { // Success SigningKey *components.SigningKey // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *CreateSigningKeyResponse) GetSigningKey() *components.SigningKey { return o.SigningKey } -func (o *CreateSigningKeyResponse) GetError() *sdkerrors.Error { +func (o *CreateSigningKeyResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createstream.go b/models/operations/createstream.go index 990f1ce..6c168cf 100644 --- a/models/operations/createstream.go +++ b/models/operations/createstream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateStreamResponse struct { @@ -12,7 +11,7 @@ type CreateStreamResponse struct { // Success Stream *components.Stream // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *CreateStreamResponse) GetStream() *components.Stream { return o.Stream } -func (o *CreateStreamResponse) GetError() *sdkerrors.Error { +func (o *CreateStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/createwebhook.go b/models/operations/createwebhook.go index fc30762..d4d74f1 100644 --- a/models/operations/createwebhook.go +++ b/models/operations/createwebhook.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type CreateWebhookResponse struct { @@ -12,7 +11,7 @@ type CreateWebhookResponse struct { // Success Webhook *components.Webhook // Error - Error *sdkerrors.Error + Error *components.Error } func (o *CreateWebhookResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *CreateWebhookResponse) GetWebhook() *components.Webhook { return o.Webhook } -func (o *CreateWebhookResponse) GetError() *sdkerrors.Error { +func (o *CreateWebhookResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deleteasset.go b/models/operations/deleteasset.go index 321d124..33998ab 100644 --- a/models/operations/deleteasset.go +++ b/models/operations/deleteasset.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteAssetRequest struct { @@ -22,7 +21,7 @@ func (o *DeleteAssetRequest) GetAssetID() string { type DeleteAssetResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteAssetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *DeleteAssetResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *DeleteAssetResponse) GetError() *sdkerrors.Error { +func (o *DeleteAssetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deletemultistreamtarget.go b/models/operations/deletemultistreamtarget.go index a6835d4..48b2521 100644 --- a/models/operations/deletemultistreamtarget.go +++ b/models/operations/deletemultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteMultistreamTargetRequest struct { @@ -22,7 +21,7 @@ func (o *DeleteMultistreamTargetRequest) GetID() string { type DeleteMultistreamTargetResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *DeleteMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata return o.HTTPMeta } -func (o *DeleteMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *DeleteMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deleteroom.go b/models/operations/deleteroom.go index a6699b5..3943bf9 100644 --- a/models/operations/deleteroom.go +++ b/models/operations/deleteroom.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteRoomRequest struct { @@ -21,7 +20,7 @@ func (o *DeleteRoomRequest) GetID() string { type DeleteRoomResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteRoomResponse) GetHTTPMeta() components.HTTPMetadata { @@ -31,7 +30,7 @@ func (o *DeleteRoomResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *DeleteRoomResponse) GetError() *sdkerrors.Error { +func (o *DeleteRoomResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deleteroomuser.go b/models/operations/deleteroomuser.go index 83bc512..5adaa52 100644 --- a/models/operations/deleteroomuser.go +++ b/models/operations/deleteroomuser.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteRoomUserRequest struct { @@ -29,7 +28,7 @@ func (o *DeleteRoomUserRequest) GetUserID() string { type DeleteRoomUserResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { @@ -39,7 +38,7 @@ func (o *DeleteRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *DeleteRoomUserResponse) GetError() *sdkerrors.Error { +func (o *DeleteRoomUserResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deletesigningkey.go b/models/operations/deletesigningkey.go index 3544f4f..25167f8 100644 --- a/models/operations/deletesigningkey.go +++ b/models/operations/deletesigningkey.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteSigningKeyRequest struct { @@ -22,7 +21,7 @@ func (o *DeleteSigningKeyRequest) GetKeyID() string { type DeleteSigningKeyResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *DeleteSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *DeleteSigningKeyResponse) GetError() *sdkerrors.Error { +func (o *DeleteSigningKeyResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deletestream.go b/models/operations/deletestream.go index 2c1b86d..eee3cc6 100644 --- a/models/operations/deletestream.go +++ b/models/operations/deletestream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteStreamRequest struct { @@ -22,7 +21,7 @@ func (o *DeleteStreamRequest) GetID() string { type DeleteStreamResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *DeleteStreamResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *DeleteStreamResponse) GetError() *sdkerrors.Error { +func (o *DeleteStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/deletewebhook.go b/models/operations/deletewebhook.go index 382e418..18438b3 100644 --- a/models/operations/deletewebhook.go +++ b/models/operations/deletewebhook.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type DeleteWebhookRequest struct { @@ -23,7 +22,7 @@ type DeleteWebhookResponse struct { // Success Webhook *components.Webhook // Error - Error *sdkerrors.Error + Error *components.Error } func (o *DeleteWebhookResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *DeleteWebhookResponse) GetWebhook() *components.Webhook { return o.Webhook } -func (o *DeleteWebhookResponse) GetError() *sdkerrors.Error { +func (o *DeleteWebhookResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/genllm.go b/models/operations/genllm.go new file mode 100644 index 0000000..26bf99e --- /dev/null +++ b/models/operations/genllm.go @@ -0,0 +1,36 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/livepeer/livepeer-go/models/components" +) + +type GenLLMResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Successful Response + LLMResponse *components.LLMResponse + // Error + StudioAPIError *components.StudioAPIError +} + +func (o *GenLLMResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GenLLMResponse) GetLLMResponse() *components.LLMResponse { + if o == nil { + return nil + } + return o.LLMResponse +} + +func (o *GenLLMResponse) GetStudioAPIError() *components.StudioAPIError { + if o == nil { + return nil + } + return o.StudioAPIError +} diff --git a/models/operations/getasset.go b/models/operations/getasset.go index 4c7578d..30b89b1 100644 --- a/models/operations/getasset.go +++ b/models/operations/getasset.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetAssetRequest struct { @@ -24,7 +23,7 @@ type GetAssetResponse struct { // Success Asset *components.Asset // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetAssetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetAssetResponse) GetAsset() *components.Asset { return o.Asset } -func (o *GetAssetResponse) GetError() *sdkerrors.Error { +func (o *GetAssetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getassets.go b/models/operations/getassets.go index b61a9f3..9af0c81 100644 --- a/models/operations/getassets.go +++ b/models/operations/getassets.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetAssetsResponse struct { @@ -12,7 +11,7 @@ type GetAssetsResponse struct { // Success Data []components.Asset // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetAssetsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetAssetsResponse) GetData() []components.Asset { return o.Data } -func (o *GetAssetsResponse) GetError() *sdkerrors.Error { +func (o *GetAssetsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getclips.go b/models/operations/getclips.go index 91e2f38..63857b6 100644 --- a/models/operations/getclips.go +++ b/models/operations/getclips.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetClipsRequest struct { @@ -24,7 +23,7 @@ type GetClipsResponse struct { // Success Data []components.Asset // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetClipsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetClipsResponse) GetData() []components.Asset { return o.Data } -func (o *GetClipsResponse) GetError() *sdkerrors.Error { +func (o *GetClipsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getcreatorviewershipmetrics.go b/models/operations/getcreatorviewershipmetrics.go index 23acd8f..be5f035 100644 --- a/models/operations/getcreatorviewershipmetrics.go +++ b/models/operations/getcreatorviewershipmetrics.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" "time" ) @@ -21,8 +20,8 @@ const ( // QueryParamFrom - Start timestamp for the query range (inclusive) type QueryParamFrom struct { - DateTime *time.Time - Integer *int64 + DateTime *time.Time `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type QueryParamFromType } @@ -85,8 +84,8 @@ const ( // QueryParamTo - End timestamp for the query range (exclusive) type QueryParamTo struct { - DateTime *time.Time - Integer *int64 + DateTime *time.Time `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type QueryParamToType } @@ -302,7 +301,7 @@ type GetCreatorViewershipMetricsResponse struct { // A list of Metric objects Data []components.ViewershipMetric // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetCreatorViewershipMetricsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -319,7 +318,7 @@ func (o *GetCreatorViewershipMetricsResponse) GetData() []components.ViewershipM return o.Data } -func (o *GetCreatorViewershipMetricsResponse) GetError() *sdkerrors.Error { +func (o *GetCreatorViewershipMetricsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getmultistreamtarget.go b/models/operations/getmultistreamtarget.go index 74a6885..c96fa1d 100644 --- a/models/operations/getmultistreamtarget.go +++ b/models/operations/getmultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetMultistreamTargetRequest struct { @@ -24,7 +23,7 @@ type GetMultistreamTargetResponse struct { // Success MultistreamTarget *components.MultistreamTarget // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetMultistreamTargetResponse) GetMultistreamTarget() *components.Multis return o.MultistreamTarget } -func (o *GetMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *GetMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getmultistreamtargets.go b/models/operations/getmultistreamtargets.go index 08cf24d..867d6e9 100644 --- a/models/operations/getmultistreamtargets.go +++ b/models/operations/getmultistreamtargets.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetMultistreamTargetsResponse struct { @@ -12,7 +11,7 @@ type GetMultistreamTargetsResponse struct { // Success Data []components.MultistreamTarget // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetMultistreamTargetsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetMultistreamTargetsResponse) GetData() []components.MultistreamTarget return o.Data } -func (o *GetMultistreamTargetsResponse) GetError() *sdkerrors.Error { +func (o *GetMultistreamTargetsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getplaybackinfo.go b/models/operations/getplaybackinfo.go index cf96aec..473a456 100644 --- a/models/operations/getplaybackinfo.go +++ b/models/operations/getplaybackinfo.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetPlaybackInfoRequest struct { @@ -24,7 +23,7 @@ type GetPlaybackInfoResponse struct { // Successful response PlaybackInfo *components.PlaybackInfo // Playback not found - Error *sdkerrors.Error + Error *components.Error } func (o *GetPlaybackInfoResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetPlaybackInfoResponse) GetPlaybackInfo() *components.PlaybackInfo { return o.PlaybackInfo } -func (o *GetPlaybackInfoResponse) GetError() *sdkerrors.Error { +func (o *GetPlaybackInfoResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getpublicviewershipmetrics.go b/models/operations/getpublicviewershipmetrics.go index 44337ef..e5d4d90 100644 --- a/models/operations/getpublicviewershipmetrics.go +++ b/models/operations/getpublicviewershipmetrics.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetPublicViewershipMetricsRequest struct { @@ -68,7 +67,7 @@ type GetPublicViewershipMetricsResponse struct { // A single Metric object with the viewCount and playtimeMins metrics. Data *GetPublicViewershipMetricsData // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetPublicViewershipMetricsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -85,7 +84,7 @@ func (o *GetPublicViewershipMetricsResponse) GetData() *GetPublicViewershipMetri return o.Data } -func (o *GetPublicViewershipMetricsResponse) GetError() *sdkerrors.Error { +func (o *GetPublicViewershipMetricsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getrealtimeviewershipnow.go b/models/operations/getrealtimeviewershipnow.go index 853e212..5b1358c 100644 --- a/models/operations/getrealtimeviewershipnow.go +++ b/models/operations/getrealtimeviewershipnow.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type BreakdownBy string @@ -81,7 +80,7 @@ type GetRealtimeViewershipNowResponse struct { // A list of Metric objects Data []components.RealtimeViewershipMetric // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetRealtimeViewershipNowResponse) GetHTTPMeta() components.HTTPMetadata { @@ -98,7 +97,7 @@ func (o *GetRealtimeViewershipNowResponse) GetData() []components.RealtimeViewer return o.Data } -func (o *GetRealtimeViewershipNowResponse) GetError() *sdkerrors.Error { +func (o *GetRealtimeViewershipNowResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getrecordedsessions.go b/models/operations/getrecordedsessions.go index 39c76d5..32daf26 100644 --- a/models/operations/getrecordedsessions.go +++ b/models/operations/getrecordedsessions.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type RecordType string @@ -20,8 +19,8 @@ const ( // Record - Flag indicating if the response should only include recorded // sessions type Record struct { - Boolean *bool - Integer *int64 + Boolean *bool `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type RecordType } @@ -103,7 +102,7 @@ type GetRecordedSessionsResponse struct { // Success Data []components.Session // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetRecordedSessionsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -120,7 +119,7 @@ func (o *GetRecordedSessionsResponse) GetData() []components.Session { return o.Data } -func (o *GetRecordedSessionsResponse) GetError() *sdkerrors.Error { +func (o *GetRecordedSessionsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getroom.go b/models/operations/getroom.go index c61479f..0690974 100644 --- a/models/operations/getroom.go +++ b/models/operations/getroom.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetRoomRequest struct { @@ -23,7 +22,7 @@ type GetRoomResponse struct { // Success Room *components.Room // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetRoomResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *GetRoomResponse) GetRoom() *components.Room { return o.Room } -func (o *GetRoomResponse) GetError() *sdkerrors.Error { +func (o *GetRoomResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getroomuser.go b/models/operations/getroomuser.go index db354a1..1bd88d1 100644 --- a/models/operations/getroomuser.go +++ b/models/operations/getroomuser.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetRoomUserRequest struct { @@ -31,7 +30,7 @@ type GetRoomUserResponse struct { // Success GetRoomUserResponse *components.GetRoomUserResponse // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { @@ -48,7 +47,7 @@ func (o *GetRoomUserResponse) GetGetRoomUserResponse() *components.GetRoomUserRe return o.GetRoomUserResponse } -func (o *GetRoomUserResponse) GetError() *sdkerrors.Error { +func (o *GetRoomUserResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getsession.go b/models/operations/getsession.go index 8b9018f..110f5c5 100644 --- a/models/operations/getsession.go +++ b/models/operations/getsession.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetSessionRequest struct { @@ -24,7 +23,7 @@ type GetSessionResponse struct { // Success Session *components.Session // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetSessionResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetSessionResponse) GetSession() *components.Session { return o.Session } -func (o *GetSessionResponse) GetError() *sdkerrors.Error { +func (o *GetSessionResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getsessionclips.go b/models/operations/getsessionclips.go index 1be690f..591e723 100644 --- a/models/operations/getsessionclips.go +++ b/models/operations/getsessionclips.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetSessionClipsRequest struct { @@ -24,7 +23,7 @@ type GetSessionClipsResponse struct { // Success Data []components.Asset // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetSessionClipsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetSessionClipsResponse) GetData() []components.Asset { return o.Data } -func (o *GetSessionClipsResponse) GetError() *sdkerrors.Error { +func (o *GetSessionClipsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getsessions.go b/models/operations/getsessions.go index 619fecf..5e7de35 100644 --- a/models/operations/getsessions.go +++ b/models/operations/getsessions.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetSessionsResponse struct { @@ -12,7 +11,7 @@ type GetSessionsResponse struct { // Success Data []components.Session // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetSessionsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetSessionsResponse) GetData() []components.Session { return o.Data } -func (o *GetSessionsResponse) GetError() *sdkerrors.Error { +func (o *GetSessionsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getsigningkey.go b/models/operations/getsigningkey.go index cce5842..7896b52 100644 --- a/models/operations/getsigningkey.go +++ b/models/operations/getsigningkey.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetSigningKeyRequest struct { @@ -24,7 +23,7 @@ type GetSigningKeyResponse struct { // Success SigningKey *components.SigningKey // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetSigningKeyResponse) GetSigningKey() *components.SigningKey { return o.SigningKey } -func (o *GetSigningKeyResponse) GetError() *sdkerrors.Error { +func (o *GetSigningKeyResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getsigningkeys.go b/models/operations/getsigningkeys.go index f3b57b5..14f4b09 100644 --- a/models/operations/getsigningkeys.go +++ b/models/operations/getsigningkeys.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetSigningKeysResponse struct { @@ -12,7 +11,7 @@ type GetSigningKeysResponse struct { // Success Data []components.SigningKey // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetSigningKeysResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetSigningKeysResponse) GetData() []components.SigningKey { return o.Data } -func (o *GetSigningKeysResponse) GetError() *sdkerrors.Error { +func (o *GetSigningKeysResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getstream.go b/models/operations/getstream.go index ffc558d..b0162e0 100644 --- a/models/operations/getstream.go +++ b/models/operations/getstream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetStreamRequest struct { @@ -24,7 +23,7 @@ type GetStreamResponse struct { // Success Stream *components.Stream // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *GetStreamResponse) GetStream() *components.Stream { return o.Stream } -func (o *GetStreamResponse) GetError() *sdkerrors.Error { +func (o *GetStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getstreams.go b/models/operations/getstreams.go index 9dcd483..20e496d 100644 --- a/models/operations/getstreams.go +++ b/models/operations/getstreams.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetStreamsRequest struct { @@ -23,7 +22,7 @@ type GetStreamsResponse struct { // Success Data []components.Stream // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetStreamsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *GetStreamsResponse) GetData() []components.Stream { return o.Data } -func (o *GetStreamsResponse) GetError() *sdkerrors.Error { +func (o *GetStreamsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/gettasks.go b/models/operations/gettasks.go index bb8f347..ea5e576 100644 --- a/models/operations/gettasks.go +++ b/models/operations/gettasks.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetTasksResponse struct { @@ -12,7 +11,7 @@ type GetTasksResponse struct { // Success Data []components.Task // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetTasksResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetTasksResponse) GetData() []components.Task { return o.Data } -func (o *GetTasksResponse) GetError() *sdkerrors.Error { +func (o *GetTasksResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getusagemetrics.go b/models/operations/getusagemetrics.go index a66ca0c..e3721ec 100644 --- a/models/operations/getusagemetrics.go +++ b/models/operations/getusagemetrics.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) // GetUsageMetricsQueryParamTimeStep - The time step to aggregate viewership metrics by @@ -118,7 +117,7 @@ type GetUsageMetricsResponse struct { // A Usage Metric object UsageMetric *components.UsageMetric // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetUsageMetricsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -135,7 +134,7 @@ func (o *GetUsageMetricsResponse) GetUsageMetric() *components.UsageMetric { return o.UsageMetric } -func (o *GetUsageMetricsResponse) GetError() *sdkerrors.Error { +func (o *GetUsageMetricsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getviewershipmetrics.go b/models/operations/getviewershipmetrics.go index 469e11d..ccba97d 100644 --- a/models/operations/getviewershipmetrics.go +++ b/models/operations/getviewershipmetrics.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" "time" ) @@ -21,8 +20,8 @@ const ( // From - Start timestamp for the query range (inclusive) type From struct { - DateTime *time.Time - Integer *int64 + DateTime *time.Time `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type FromType } @@ -85,8 +84,8 @@ const ( // To - End timestamp for the query range (exclusive) type To struct { - DateTime *time.Time - Integer *int64 + DateTime *time.Time `queryParam:"inline"` + Integer *int64 `queryParam:"inline"` Type ToType } @@ -323,7 +322,7 @@ type GetViewershipMetricsResponse struct { // A list of Metric objects Data []components.ViewershipMetric // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetViewershipMetricsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -340,7 +339,7 @@ func (o *GetViewershipMetricsResponse) GetData() []components.ViewershipMetric { return o.Data } -func (o *GetViewershipMetricsResponse) GetError() *sdkerrors.Error { +func (o *GetViewershipMetricsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getwebhook.go b/models/operations/getwebhook.go index 716f6ae..4b42163 100644 --- a/models/operations/getwebhook.go +++ b/models/operations/getwebhook.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetWebhookRequest struct { @@ -23,7 +22,7 @@ type GetWebhookResponse struct { // Success Webhook *components.Webhook // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetWebhookResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *GetWebhookResponse) GetWebhook() *components.Webhook { return o.Webhook } -func (o *GetWebhookResponse) GetError() *sdkerrors.Error { +func (o *GetWebhookResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getwebhooklog.go b/models/operations/getwebhooklog.go index fd547f2..04f33a9 100644 --- a/models/operations/getwebhooklog.go +++ b/models/operations/getwebhooklog.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetWebhookLogRequest struct { @@ -31,7 +30,7 @@ type GetWebhookLogResponse struct { // Success WebhookLog *components.WebhookLog // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetWebhookLogResponse) GetHTTPMeta() components.HTTPMetadata { @@ -48,7 +47,7 @@ func (o *GetWebhookLogResponse) GetWebhookLog() *components.WebhookLog { return o.WebhookLog } -func (o *GetWebhookLogResponse) GetError() *sdkerrors.Error { +func (o *GetWebhookLogResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getwebhooklogs.go b/models/operations/getwebhooklogs.go index d5a2d10..64ffd91 100644 --- a/models/operations/getwebhooklogs.go +++ b/models/operations/getwebhooklogs.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetWebhookLogsRequest struct { @@ -23,7 +22,7 @@ type GetWebhookLogsResponse struct { // Success Data []components.WebhookLog // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetWebhookLogsResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *GetWebhookLogsResponse) GetData() []components.WebhookLog { return o.Data } -func (o *GetWebhookLogsResponse) GetError() *sdkerrors.Error { +func (o *GetWebhookLogsResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/getwebhooks.go b/models/operations/getwebhooks.go index 5cdde40..8969c0c 100644 --- a/models/operations/getwebhooks.go +++ b/models/operations/getwebhooks.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type GetWebhooksResponse struct { @@ -12,7 +11,7 @@ type GetWebhooksResponse struct { // Success Data []components.Webhook // Error - Error *sdkerrors.Error + Error *components.Error } func (o *GetWebhooksResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *GetWebhooksResponse) GetData() []components.Webhook { return o.Data } -func (o *GetWebhooksResponse) GetError() *sdkerrors.Error { +func (o *GetWebhooksResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/options.go b/models/operations/options.go index 21a7234..f23cebb 100644 --- a/models/operations/options.go +++ b/models/operations/options.go @@ -12,7 +12,6 @@ import ( var ErrUnsupportedOption = errors.New("unsupported option") const ( - SupportedOptionServerURL = "serverURL" SupportedOptionRetries = "retries" SupportedOptionTimeout = "timeout" SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" @@ -24,6 +23,7 @@ type Options struct { Retries *retry.Config Timeout *time.Duration URLOverride *string + SetHeaders map[string]string } type Option func(*Options, ...string) error @@ -31,10 +31,6 @@ type Option func(*Options, ...string) error // WithServerURL allows providing an alternative server URL. func WithServerURL(serverURL string) Option { return func(opts *Options, supportedOptions ...string) error { - if !utils.Contains(supportedOptions, SupportedOptionServerURL) { - return ErrUnsupportedOption - } - opts.ServerURL = &serverURL return nil } @@ -43,10 +39,6 @@ func WithServerURL(serverURL string) Option { // WithTemplatedServerURL allows providing an alternative server URL with templated parameters. func WithTemplatedServerURL(serverURL string, params map[string]string) Option { return func(opts *Options, supportedOptions ...string) error { - if !utils.Contains(supportedOptions, SupportedOptionServerURL) { - return ErrUnsupportedOption - } - if params != nil { serverURL = utils.ReplaceParameters(serverURL, params) } @@ -91,3 +83,12 @@ func WithURLOverride(urlOverride string) Option { return nil } } + +// WithSetHeaders takes a map of headers that will applied to a request. If the +// request contains headers that are in the map then they will be overwritten. +func WithSetHeaders(hdrs map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + opts.SetHeaders = hdrs + return nil + } +} diff --git a/models/operations/removemultistreamtarget.go b/models/operations/removemultistreamtarget.go index eee79b8..ad4e9cf 100644 --- a/models/operations/removemultistreamtarget.go +++ b/models/operations/removemultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type RemoveMultistreamTargetRequest struct { @@ -31,7 +30,7 @@ func (o *RemoveMultistreamTargetRequest) GetTargetID() string { type RemoveMultistreamTargetResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *RemoveMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -41,7 +40,7 @@ func (o *RemoveMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata return o.HTTPMeta } -func (o *RemoveMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *RemoveMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/requestupload.go b/models/operations/requestupload.go index a50da6c..c8c9a89 100644 --- a/models/operations/requestupload.go +++ b/models/operations/requestupload.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type Task struct { @@ -61,7 +60,7 @@ type RequestUploadResponse struct { // Success Data *RequestUploadData // Error - Error *sdkerrors.Error + Error *components.Error } func (o *RequestUploadResponse) GetHTTPMeta() components.HTTPMetadata { @@ -78,7 +77,7 @@ func (o *RequestUploadResponse) GetData() *RequestUploadData { return o.Data } -func (o *RequestUploadResponse) GetError() *sdkerrors.Error { +func (o *RequestUploadResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/resendwebhook.go b/models/operations/resendwebhook.go index 5fb19c6..cd9e539 100644 --- a/models/operations/resendwebhook.go +++ b/models/operations/resendwebhook.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type ResendWebhookRequest struct { @@ -31,7 +30,7 @@ type ResendWebhookResponse struct { // Success WebhookLog *components.WebhookLog // Error - Error *sdkerrors.Error + Error *components.Error } func (o *ResendWebhookResponse) GetHTTPMeta() components.HTTPMetadata { @@ -48,7 +47,7 @@ func (o *ResendWebhookResponse) GetWebhookLog() *components.WebhookLog { return o.WebhookLog } -func (o *ResendWebhookResponse) GetError() *sdkerrors.Error { +func (o *ResendWebhookResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/startpullstream.go b/models/operations/startpullstream.go index 4fc592c..96fd794 100644 --- a/models/operations/startpullstream.go +++ b/models/operations/startpullstream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type StartPullStreamRequest struct { @@ -22,7 +21,7 @@ func (o *StartPullStreamRequest) GetID() string { type StartPullStreamResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *StartPullStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *StartPullStreamResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *StartPullStreamResponse) GetError() *sdkerrors.Error { +func (o *StartPullStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/startroomegress.go b/models/operations/startroomegress.go index 39aab07..21a99cf 100644 --- a/models/operations/startroomegress.go +++ b/models/operations/startroomegress.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type StartRoomEgressRequest struct { @@ -29,7 +28,7 @@ func (o *StartRoomEgressRequest) GetRoomEgressPayload() components.RoomEgressPay type StartRoomEgressResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *StartRoomEgressResponse) GetHTTPMeta() components.HTTPMetadata { @@ -39,7 +38,7 @@ func (o *StartRoomEgressResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *StartRoomEgressResponse) GetError() *sdkerrors.Error { +func (o *StartRoomEgressResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/stoproomegress.go b/models/operations/stoproomegress.go index dd01d29..94f4705 100644 --- a/models/operations/stoproomegress.go +++ b/models/operations/stoproomegress.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type StopRoomEgressRequest struct { @@ -21,7 +20,7 @@ func (o *StopRoomEgressRequest) GetID() string { type StopRoomEgressResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *StopRoomEgressResponse) GetHTTPMeta() components.HTTPMetadata { @@ -31,7 +30,7 @@ func (o *StopRoomEgressResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *StopRoomEgressResponse) GetError() *sdkerrors.Error { +func (o *StopRoomEgressResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/terminatestream.go b/models/operations/terminatestream.go index c46a7c6..a2e1c7a 100644 --- a/models/operations/terminatestream.go +++ b/models/operations/terminatestream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type TerminateStreamRequest struct { @@ -22,7 +21,7 @@ func (o *TerminateStreamRequest) GetID() string { type TerminateStreamResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *TerminateStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -32,7 +31,7 @@ func (o *TerminateStreamResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *TerminateStreamResponse) GetError() *sdkerrors.Error { +func (o *TerminateStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/transcodevideo.go b/models/operations/transcodevideo.go index 957573e..350ad05 100644 --- a/models/operations/transcodevideo.go +++ b/models/operations/transcodevideo.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type TranscodeVideoResponse struct { @@ -12,7 +11,7 @@ type TranscodeVideoResponse struct { // Success Task *components.Task // Error - Error *sdkerrors.Error + Error *components.Error } func (o *TranscodeVideoResponse) GetHTTPMeta() components.HTTPMetadata { @@ -29,7 +28,7 @@ func (o *TranscodeVideoResponse) GetTask() *components.Task { return o.Task } -func (o *TranscodeVideoResponse) GetError() *sdkerrors.Error { +func (o *TranscodeVideoResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updateasset.go b/models/operations/updateasset.go index 4f83836..eb8965a 100644 --- a/models/operations/updateasset.go +++ b/models/operations/updateasset.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateAssetRequest struct { @@ -32,7 +31,7 @@ type UpdateAssetResponse struct { // Success Asset *components.Asset // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateAssetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -49,7 +48,7 @@ func (o *UpdateAssetResponse) GetAsset() *components.Asset { return o.Asset } -func (o *UpdateAssetResponse) GetError() *sdkerrors.Error { +func (o *UpdateAssetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updatemultistreamtarget.go b/models/operations/updatemultistreamtarget.go index 72e8d96..25dda2e 100644 --- a/models/operations/updatemultistreamtarget.go +++ b/models/operations/updatemultistreamtarget.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateMultistreamTargetRequest struct { @@ -30,7 +29,7 @@ func (o *UpdateMultistreamTargetRequest) GetMultistreamTargetPatchPayload() comp type UpdateMultistreamTargetResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *UpdateMultistreamTargetResponse) GetHTTPMeta() components.HTTPMetadata return o.HTTPMeta } -func (o *UpdateMultistreamTargetResponse) GetError() *sdkerrors.Error { +func (o *UpdateMultistreamTargetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updateroomuser.go b/models/operations/updateroomuser.go index 06e1bad..b643b4c 100644 --- a/models/operations/updateroomuser.go +++ b/models/operations/updateroomuser.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateRoomUserRequest struct { @@ -37,7 +36,7 @@ func (o *UpdateRoomUserRequest) GetRoomUserUpdatePayload() components.RoomUserUp type UpdateRoomUserResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { @@ -47,7 +46,7 @@ func (o *UpdateRoomUserResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *UpdateRoomUserResponse) GetError() *sdkerrors.Error { +func (o *UpdateRoomUserResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updatesigningkey.go b/models/operations/updatesigningkey.go index 0bd0bed..a99e0ba 100644 --- a/models/operations/updatesigningkey.go +++ b/models/operations/updatesigningkey.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateSigningKeyRequestBody struct { @@ -49,7 +48,7 @@ func (o *UpdateSigningKeyRequest) GetRequestBody() UpdateSigningKeyRequestBody { type UpdateSigningKeyResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { @@ -59,7 +58,7 @@ func (o *UpdateSigningKeyResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *UpdateSigningKeyResponse) GetError() *sdkerrors.Error { +func (o *UpdateSigningKeyResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updatestream.go b/models/operations/updatestream.go index fb2f050..257e067 100644 --- a/models/operations/updatestream.go +++ b/models/operations/updatestream.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateStreamRequest struct { @@ -30,7 +29,7 @@ func (o *UpdateStreamRequest) GetStreamPatchPayload() components.StreamPatchPayl type UpdateStreamResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateStreamResponse) GetHTTPMeta() components.HTTPMetadata { @@ -40,7 +39,7 @@ func (o *UpdateStreamResponse) GetHTTPMeta() components.HTTPMetadata { return o.HTTPMeta } -func (o *UpdateStreamResponse) GetError() *sdkerrors.Error { +func (o *UpdateStreamResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/updatewebhook.go b/models/operations/updatewebhook.go index c4876ca..3a5506d 100644 --- a/models/operations/updatewebhook.go +++ b/models/operations/updatewebhook.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UpdateWebhookRequest struct { @@ -31,7 +30,7 @@ type UpdateWebhookResponse struct { // Success Webhook *components.Webhook // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UpdateWebhookResponse) GetHTTPMeta() components.HTTPMetadata { @@ -48,7 +47,7 @@ func (o *UpdateWebhookResponse) GetWebhook() *components.Webhook { return o.Webhook } -func (o *UpdateWebhookResponse) GetError() *sdkerrors.Error { +func (o *UpdateWebhookResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/operations/uploadasset.go b/models/operations/uploadasset.go index 8e195f7..cf3da5c 100644 --- a/models/operations/uploadasset.go +++ b/models/operations/uploadasset.go @@ -4,7 +4,6 @@ package operations import ( "github.com/livepeer/livepeer-go/models/components" - "github.com/livepeer/livepeer-go/models/sdkerrors" ) type UploadAssetAssetTask struct { @@ -76,7 +75,7 @@ type UploadAssetResponse struct { // Upload started TwoHundredAndOneApplicationJSONData *UploadAssetDataOutput // Error - Error *sdkerrors.Error + Error *components.Error } func (o *UploadAssetResponse) GetHTTPMeta() components.HTTPMetadata { @@ -100,7 +99,7 @@ func (o *UploadAssetResponse) GetTwoHundredAndOneApplicationJSONData() *UploadAs return o.TwoHundredAndOneApplicationJSONData } -func (o *UploadAssetResponse) GetError() *sdkerrors.Error { +func (o *UploadAssetResponse) GetError() *components.Error { if o == nil { return nil } diff --git a/models/sdkerrors/genaudiototext.go b/models/sdkerrors/genaudiototext.go index 9da668e..1e3bf5e 100644 --- a/models/sdkerrors/genaudiototext.go +++ b/models/sdkerrors/genaudiototext.go @@ -19,8 +19,8 @@ const ( // GenAudioToTextGenerateResponse500ResponseBody - Internal Server Error type GenAudioToTextGenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenAudioToTextGenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenAudioToTextGenerateResponse422ResponseBody - Validation Error type GenAudioToTextGenerateResponse422ResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenAudioToTextGenerateResponse422ResponseBodyType @@ -172,6 +172,87 @@ func (u GenAudioToTextGenerateResponse422ResponseBody) Error() string { } } +type GenAudioToTextGenerateResponse415ResponseBodyType string + +const ( + GenAudioToTextGenerateResponse415ResponseBodyTypeHTTPError GenAudioToTextGenerateResponse415ResponseBodyType = "HTTPError" + GenAudioToTextGenerateResponse415ResponseBodyTypeStudioAPIError GenAudioToTextGenerateResponse415ResponseBodyType = "studio-api-error" +) + +// GenAudioToTextGenerateResponse415ResponseBody - Unsupported Media Type +type GenAudioToTextGenerateResponse415ResponseBody struct { + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` + + Type GenAudioToTextGenerateResponse415ResponseBodyType + + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &GenAudioToTextGenerateResponse415ResponseBody{} + +func CreateGenAudioToTextGenerateResponse415ResponseBodyHTTPError(httpError components.HTTPError) GenAudioToTextGenerateResponse415ResponseBody { + typ := GenAudioToTextGenerateResponse415ResponseBodyTypeHTTPError + + return GenAudioToTextGenerateResponse415ResponseBody{ + HTTPError: &httpError, + Type: typ, + } +} + +func CreateGenAudioToTextGenerateResponse415ResponseBodyStudioAPIError(studioAPIError components.StudioAPIError) GenAudioToTextGenerateResponse415ResponseBody { + typ := GenAudioToTextGenerateResponse415ResponseBodyTypeStudioAPIError + + return GenAudioToTextGenerateResponse415ResponseBody{ + StudioAPIError: &studioAPIError, + Type: typ, + } +} + +func (u *GenAudioToTextGenerateResponse415ResponseBody) UnmarshalJSON(data []byte) error { + + var httpError components.HTTPError = components.HTTPError{} + if err := utils.UnmarshalJSON(data, &httpError, "", true, true); err == nil { + u.HTTPError = &httpError + u.Type = GenAudioToTextGenerateResponse415ResponseBodyTypeHTTPError + return nil + } + + var studioAPIError components.StudioAPIError = components.StudioAPIError{} + if err := utils.UnmarshalJSON(data, &studioAPIError, "", true, true); err == nil { + u.StudioAPIError = &studioAPIError + u.Type = GenAudioToTextGenerateResponse415ResponseBodyTypeStudioAPIError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GenAudioToTextGenerateResponse415ResponseBody", string(data)) +} + +func (u GenAudioToTextGenerateResponse415ResponseBody) MarshalJSON() ([]byte, error) { + if u.HTTPError != nil { + return utils.MarshalJSON(u.HTTPError, "", true) + } + + if u.StudioAPIError != nil { + return utils.MarshalJSON(u.StudioAPIError, "", true) + } + + return nil, errors.New("could not marshal union type GenAudioToTextGenerateResponse415ResponseBody: all fields are null") +} + +func (u GenAudioToTextGenerateResponse415ResponseBody) Error() string { + switch u.Type { + case GenAudioToTextGenerateResponse415ResponseBodyTypeHTTPError: + data, _ := json.Marshal(u.HTTPError) + return string(data) + case GenAudioToTextGenerateResponse415ResponseBodyTypeStudioAPIError: + data, _ := json.Marshal(u.StudioAPIError) + return string(data) + default: + return "unknown error" + } +} + type GenAudioToTextGenerateResponseResponseBodyType string const ( @@ -181,8 +262,8 @@ const ( // GenAudioToTextGenerateResponseResponseBody - Request Entity Too Large type GenAudioToTextGenerateResponseResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenAudioToTextGenerateResponseResponseBodyType @@ -262,8 +343,8 @@ const ( // GenAudioToTextGenerateResponseBody - Unauthorized type GenAudioToTextGenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenAudioToTextGenerateResponseBodyType @@ -343,8 +424,8 @@ const ( // GenAudioToTextResponseBody - Bad Request type GenAudioToTextResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenAudioToTextResponseBodyType diff --git a/models/sdkerrors/genimagetoimage.go b/models/sdkerrors/genimagetoimage.go index 566a7ea..613c3a8 100644 --- a/models/sdkerrors/genimagetoimage.go +++ b/models/sdkerrors/genimagetoimage.go @@ -19,8 +19,8 @@ const ( // GenImageToImageGenerateResponse500ResponseBody - Internal Server Error type GenImageToImageGenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToImageGenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenImageToImageGenerateResponseResponseBody - Validation Error type GenImageToImageGenerateResponseResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToImageGenerateResponseResponseBodyType @@ -181,8 +181,8 @@ const ( // GenImageToImageGenerateResponseBody - Unauthorized type GenImageToImageGenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToImageGenerateResponseBodyType @@ -262,8 +262,8 @@ const ( // GenImageToImageResponseBody - Bad Request type GenImageToImageResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToImageResponseBodyType diff --git a/models/sdkerrors/genimagetovideo.go b/models/sdkerrors/genimagetovideo.go index a4c8c2b..278267a 100644 --- a/models/sdkerrors/genimagetovideo.go +++ b/models/sdkerrors/genimagetovideo.go @@ -19,8 +19,8 @@ const ( // GenImageToVideoGenerateResponse500ResponseBody - Internal Server Error type GenImageToVideoGenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToVideoGenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenImageToVideoGenerateResponseResponseBody - Validation Error type GenImageToVideoGenerateResponseResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToVideoGenerateResponseResponseBodyType @@ -181,8 +181,8 @@ const ( // GenImageToVideoGenerateResponseBody - Unauthorized type GenImageToVideoGenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToVideoGenerateResponseBodyType @@ -262,8 +262,8 @@ const ( // GenImageToVideoResponseBody - Bad Request type GenImageToVideoResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenImageToVideoResponseBodyType diff --git a/models/sdkerrors/genllm.go b/models/sdkerrors/genllm.go new file mode 100644 index 0000000..d9690be --- /dev/null +++ b/models/sdkerrors/genllm.go @@ -0,0 +1,335 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdkerrors + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/livepeer/livepeer-go/internal/utils" + "github.com/livepeer/livepeer-go/models/components" +) + +type GenLLMGenerateResponse500ResponseBodyType string + +const ( + GenLLMGenerateResponse500ResponseBodyTypeHTTPError GenLLMGenerateResponse500ResponseBodyType = "HTTPError" + GenLLMGenerateResponse500ResponseBodyTypeStudioAPIError GenLLMGenerateResponse500ResponseBodyType = "studio-api-error" +) + +// GenLLMGenerateResponse500ResponseBody - Internal Server Error +type GenLLMGenerateResponse500ResponseBody struct { + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` + + Type GenLLMGenerateResponse500ResponseBodyType + + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &GenLLMGenerateResponse500ResponseBody{} + +func CreateGenLLMGenerateResponse500ResponseBodyHTTPError(httpError components.HTTPError) GenLLMGenerateResponse500ResponseBody { + typ := GenLLMGenerateResponse500ResponseBodyTypeHTTPError + + return GenLLMGenerateResponse500ResponseBody{ + HTTPError: &httpError, + Type: typ, + } +} + +func CreateGenLLMGenerateResponse500ResponseBodyStudioAPIError(studioAPIError components.StudioAPIError) GenLLMGenerateResponse500ResponseBody { + typ := GenLLMGenerateResponse500ResponseBodyTypeStudioAPIError + + return GenLLMGenerateResponse500ResponseBody{ + StudioAPIError: &studioAPIError, + Type: typ, + } +} + +func (u *GenLLMGenerateResponse500ResponseBody) UnmarshalJSON(data []byte) error { + + var httpError components.HTTPError = components.HTTPError{} + if err := utils.UnmarshalJSON(data, &httpError, "", true, true); err == nil { + u.HTTPError = &httpError + u.Type = GenLLMGenerateResponse500ResponseBodyTypeHTTPError + return nil + } + + var studioAPIError components.StudioAPIError = components.StudioAPIError{} + if err := utils.UnmarshalJSON(data, &studioAPIError, "", true, true); err == nil { + u.StudioAPIError = &studioAPIError + u.Type = GenLLMGenerateResponse500ResponseBodyTypeStudioAPIError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GenLLMGenerateResponse500ResponseBody", string(data)) +} + +func (u GenLLMGenerateResponse500ResponseBody) MarshalJSON() ([]byte, error) { + if u.HTTPError != nil { + return utils.MarshalJSON(u.HTTPError, "", true) + } + + if u.StudioAPIError != nil { + return utils.MarshalJSON(u.StudioAPIError, "", true) + } + + return nil, errors.New("could not marshal union type GenLLMGenerateResponse500ResponseBody: all fields are null") +} + +func (u GenLLMGenerateResponse500ResponseBody) Error() string { + switch u.Type { + case GenLLMGenerateResponse500ResponseBodyTypeHTTPError: + data, _ := json.Marshal(u.HTTPError) + return string(data) + case GenLLMGenerateResponse500ResponseBodyTypeStudioAPIError: + data, _ := json.Marshal(u.StudioAPIError) + return string(data) + default: + return "unknown error" + } +} + +type GenLLMGenerateResponseResponseBodyType string + +const ( + GenLLMGenerateResponseResponseBodyTypeHTTPValidationError GenLLMGenerateResponseResponseBodyType = "HTTPValidationError" + GenLLMGenerateResponseResponseBodyTypeStudioAPIError GenLLMGenerateResponseResponseBodyType = "studio-api-error" +) + +// GenLLMGenerateResponseResponseBody - Validation Error +type GenLLMGenerateResponseResponseBody struct { + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` + + Type GenLLMGenerateResponseResponseBodyType + + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &GenLLMGenerateResponseResponseBody{} + +func CreateGenLLMGenerateResponseResponseBodyHTTPValidationError(httpValidationError components.HTTPValidationError) GenLLMGenerateResponseResponseBody { + typ := GenLLMGenerateResponseResponseBodyTypeHTTPValidationError + + return GenLLMGenerateResponseResponseBody{ + HTTPValidationError: &httpValidationError, + Type: typ, + } +} + +func CreateGenLLMGenerateResponseResponseBodyStudioAPIError(studioAPIError components.StudioAPIError) GenLLMGenerateResponseResponseBody { + typ := GenLLMGenerateResponseResponseBodyTypeStudioAPIError + + return GenLLMGenerateResponseResponseBody{ + StudioAPIError: &studioAPIError, + Type: typ, + } +} + +func (u *GenLLMGenerateResponseResponseBody) UnmarshalJSON(data []byte) error { + + var httpValidationError components.HTTPValidationError = components.HTTPValidationError{} + if err := utils.UnmarshalJSON(data, &httpValidationError, "", true, true); err == nil { + u.HTTPValidationError = &httpValidationError + u.Type = GenLLMGenerateResponseResponseBodyTypeHTTPValidationError + return nil + } + + var studioAPIError components.StudioAPIError = components.StudioAPIError{} + if err := utils.UnmarshalJSON(data, &studioAPIError, "", true, true); err == nil { + u.StudioAPIError = &studioAPIError + u.Type = GenLLMGenerateResponseResponseBodyTypeStudioAPIError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GenLLMGenerateResponseResponseBody", string(data)) +} + +func (u GenLLMGenerateResponseResponseBody) MarshalJSON() ([]byte, error) { + if u.HTTPValidationError != nil { + return utils.MarshalJSON(u.HTTPValidationError, "", true) + } + + if u.StudioAPIError != nil { + return utils.MarshalJSON(u.StudioAPIError, "", true) + } + + return nil, errors.New("could not marshal union type GenLLMGenerateResponseResponseBody: all fields are null") +} + +func (u GenLLMGenerateResponseResponseBody) Error() string { + switch u.Type { + case GenLLMGenerateResponseResponseBodyTypeHTTPValidationError: + data, _ := json.Marshal(u.HTTPValidationError) + return string(data) + case GenLLMGenerateResponseResponseBodyTypeStudioAPIError: + data, _ := json.Marshal(u.StudioAPIError) + return string(data) + default: + return "unknown error" + } +} + +type GenLLMGenerateResponseBodyType string + +const ( + GenLLMGenerateResponseBodyTypeHTTPError GenLLMGenerateResponseBodyType = "HTTPError" + GenLLMGenerateResponseBodyTypeStudioAPIError GenLLMGenerateResponseBodyType = "studio-api-error" +) + +// GenLLMGenerateResponseBody - Unauthorized +type GenLLMGenerateResponseBody struct { + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` + + Type GenLLMGenerateResponseBodyType + + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &GenLLMGenerateResponseBody{} + +func CreateGenLLMGenerateResponseBodyHTTPError(httpError components.HTTPError) GenLLMGenerateResponseBody { + typ := GenLLMGenerateResponseBodyTypeHTTPError + + return GenLLMGenerateResponseBody{ + HTTPError: &httpError, + Type: typ, + } +} + +func CreateGenLLMGenerateResponseBodyStudioAPIError(studioAPIError components.StudioAPIError) GenLLMGenerateResponseBody { + typ := GenLLMGenerateResponseBodyTypeStudioAPIError + + return GenLLMGenerateResponseBody{ + StudioAPIError: &studioAPIError, + Type: typ, + } +} + +func (u *GenLLMGenerateResponseBody) UnmarshalJSON(data []byte) error { + + var httpError components.HTTPError = components.HTTPError{} + if err := utils.UnmarshalJSON(data, &httpError, "", true, true); err == nil { + u.HTTPError = &httpError + u.Type = GenLLMGenerateResponseBodyTypeHTTPError + return nil + } + + var studioAPIError components.StudioAPIError = components.StudioAPIError{} + if err := utils.UnmarshalJSON(data, &studioAPIError, "", true, true); err == nil { + u.StudioAPIError = &studioAPIError + u.Type = GenLLMGenerateResponseBodyTypeStudioAPIError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GenLLMGenerateResponseBody", string(data)) +} + +func (u GenLLMGenerateResponseBody) MarshalJSON() ([]byte, error) { + if u.HTTPError != nil { + return utils.MarshalJSON(u.HTTPError, "", true) + } + + if u.StudioAPIError != nil { + return utils.MarshalJSON(u.StudioAPIError, "", true) + } + + return nil, errors.New("could not marshal union type GenLLMGenerateResponseBody: all fields are null") +} + +func (u GenLLMGenerateResponseBody) Error() string { + switch u.Type { + case GenLLMGenerateResponseBodyTypeHTTPError: + data, _ := json.Marshal(u.HTTPError) + return string(data) + case GenLLMGenerateResponseBodyTypeStudioAPIError: + data, _ := json.Marshal(u.StudioAPIError) + return string(data) + default: + return "unknown error" + } +} + +type GenLLMResponseBodyType string + +const ( + GenLLMResponseBodyTypeHTTPError GenLLMResponseBodyType = "HTTPError" + GenLLMResponseBodyTypeStudioAPIError GenLLMResponseBodyType = "studio-api-error" +) + +// GenLLMResponseBody - Bad Request +type GenLLMResponseBody struct { + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` + + Type GenLLMResponseBodyType + + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &GenLLMResponseBody{} + +func CreateGenLLMResponseBodyHTTPError(httpError components.HTTPError) GenLLMResponseBody { + typ := GenLLMResponseBodyTypeHTTPError + + return GenLLMResponseBody{ + HTTPError: &httpError, + Type: typ, + } +} + +func CreateGenLLMResponseBodyStudioAPIError(studioAPIError components.StudioAPIError) GenLLMResponseBody { + typ := GenLLMResponseBodyTypeStudioAPIError + + return GenLLMResponseBody{ + StudioAPIError: &studioAPIError, + Type: typ, + } +} + +func (u *GenLLMResponseBody) UnmarshalJSON(data []byte) error { + + var httpError components.HTTPError = components.HTTPError{} + if err := utils.UnmarshalJSON(data, &httpError, "", true, true); err == nil { + u.HTTPError = &httpError + u.Type = GenLLMResponseBodyTypeHTTPError + return nil + } + + var studioAPIError components.StudioAPIError = components.StudioAPIError{} + if err := utils.UnmarshalJSON(data, &studioAPIError, "", true, true); err == nil { + u.StudioAPIError = &studioAPIError + u.Type = GenLLMResponseBodyTypeStudioAPIError + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GenLLMResponseBody", string(data)) +} + +func (u GenLLMResponseBody) MarshalJSON() ([]byte, error) { + if u.HTTPError != nil { + return utils.MarshalJSON(u.HTTPError, "", true) + } + + if u.StudioAPIError != nil { + return utils.MarshalJSON(u.StudioAPIError, "", true) + } + + return nil, errors.New("could not marshal union type GenLLMResponseBody: all fields are null") +} + +func (u GenLLMResponseBody) Error() string { + switch u.Type { + case GenLLMResponseBodyTypeHTTPError: + data, _ := json.Marshal(u.HTTPError) + return string(data) + case GenLLMResponseBodyTypeStudioAPIError: + data, _ := json.Marshal(u.StudioAPIError) + return string(data) + default: + return "unknown error" + } +} diff --git a/models/sdkerrors/gensegmentanything2.go b/models/sdkerrors/gensegmentanything2.go index 8fb159a..339ce9a 100644 --- a/models/sdkerrors/gensegmentanything2.go +++ b/models/sdkerrors/gensegmentanything2.go @@ -19,8 +19,8 @@ const ( // GenSegmentAnything2GenerateResponse500ResponseBody - Internal Server Error type GenSegmentAnything2GenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenSegmentAnything2GenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenSegmentAnything2GenerateResponseResponseBody - Validation Error type GenSegmentAnything2GenerateResponseResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenSegmentAnything2GenerateResponseResponseBodyType @@ -181,8 +181,8 @@ const ( // GenSegmentAnything2GenerateResponseBody - Unauthorized type GenSegmentAnything2GenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenSegmentAnything2GenerateResponseBodyType @@ -262,8 +262,8 @@ const ( // GenSegmentAnything2ResponseBody - Bad Request type GenSegmentAnything2ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenSegmentAnything2ResponseBodyType diff --git a/models/sdkerrors/gentexttoimage.go b/models/sdkerrors/gentexttoimage.go index 6534398..05bab8f 100644 --- a/models/sdkerrors/gentexttoimage.go +++ b/models/sdkerrors/gentexttoimage.go @@ -19,8 +19,8 @@ const ( // GenTextToImageGenerateResponse500ResponseBody - Internal Server Error type GenTextToImageGenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenTextToImageGenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenTextToImageGenerateResponseResponseBody - Validation Error type GenTextToImageGenerateResponseResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenTextToImageGenerateResponseResponseBodyType @@ -181,8 +181,8 @@ const ( // GenTextToImageGenerateResponseBody - Unauthorized type GenTextToImageGenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenTextToImageGenerateResponseBodyType @@ -262,8 +262,8 @@ const ( // GenTextToImageResponseBody - Bad Request type GenTextToImageResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenTextToImageResponseBodyType diff --git a/models/sdkerrors/genupscale.go b/models/sdkerrors/genupscale.go index fa5d53d..f139409 100644 --- a/models/sdkerrors/genupscale.go +++ b/models/sdkerrors/genupscale.go @@ -19,8 +19,8 @@ const ( // GenUpscaleGenerateResponse500ResponseBody - Internal Server Error type GenUpscaleGenerateResponse500ResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenUpscaleGenerateResponse500ResponseBodyType @@ -100,8 +100,8 @@ const ( // GenUpscaleGenerateResponseResponseBody - Validation Error type GenUpscaleGenerateResponseResponseBody struct { - HTTPValidationError *components.HTTPValidationError - StudioAPIError *components.StudioAPIError + HTTPValidationError *components.HTTPValidationError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenUpscaleGenerateResponseResponseBodyType @@ -181,8 +181,8 @@ const ( // GenUpscaleGenerateResponseBody - Unauthorized type GenUpscaleGenerateResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenUpscaleGenerateResponseBodyType @@ -262,8 +262,8 @@ const ( // GenUpscaleResponseBody - Bad Request type GenUpscaleResponseBody struct { - HTTPError *components.HTTPError - StudioAPIError *components.StudioAPIError + HTTPError *components.HTTPError `queryParam:"inline"` + StudioAPIError *components.StudioAPIError `queryParam:"inline"` Type GenUpscaleResponseBodyType diff --git a/multistream.go b/multistream.go index ba5b924..d106489 100644 --- a/multistream.go +++ b/multistream.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -49,7 +48,12 @@ func (s *Multistream) GetAll(ctx context.Context, opts ...operations.Option) (*o } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/multistream/target") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -77,6 +81,10 @@ func (s *Multistream) GetAll(ctx context.Context, opts ...operations.Option) (*o return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -107,7 +115,11 @@ func (s *Multistream) GetAll(ctx context.Context, opts ...operations.Option) (*o req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -169,21 +181,11 @@ func (s *Multistream) GetAll(ctx context.Context, opts ...operations.Option) (*o }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -195,42 +197,39 @@ func (s *Multistream) GetAll(ctx context.Context, opts ...operations.Option) (*o res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -260,7 +259,12 @@ func (s *Multistream) Create(ctx context.Context, request components.Multistream } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/multistream/target") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -294,6 +298,10 @@ func (s *Multistream) Create(ctx context.Context, request components.Multistream return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -324,7 +332,11 @@ func (s *Multistream) Create(ctx context.Context, request components.Multistream req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -386,21 +398,11 @@ func (s *Multistream) Create(ctx context.Context, request components.Multistream }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -412,42 +414,39 @@ func (s *Multistream) Create(ctx context.Context, request components.Multistream res.MultistreamTarget = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -481,7 +480,12 @@ func (s *Multistream) Get(ctx context.Context, id string, opts ...operations.Opt } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/multistream/target/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -509,6 +513,10 @@ func (s *Multistream) Get(ctx context.Context, id string, opts ...operations.Opt return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -539,7 +547,11 @@ func (s *Multistream) Get(ctx context.Context, id string, opts ...operations.Opt req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -601,21 +613,11 @@ func (s *Multistream) Get(ctx context.Context, id string, opts ...operations.Opt }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -627,42 +629,39 @@ func (s *Multistream) Get(ctx context.Context, id string, opts ...operations.Opt res.MultistreamTarget = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -697,7 +696,12 @@ func (s *Multistream) Update(ctx context.Context, id string, multistreamTargetPa } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/multistream/target/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -731,6 +735,10 @@ func (s *Multistream) Update(ctx context.Context, id string, multistreamTargetPa return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -761,7 +769,11 @@ func (s *Multistream) Update(ctx context.Context, id string, multistreamTargetPa req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -823,47 +835,35 @@ func (s *Multistream) Update(ctx context.Context, id string, multistreamTargetPa }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -899,7 +899,12 @@ func (s *Multistream) Delete(ctx context.Context, id string, opts ...operations. } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/multistream/target/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -927,6 +932,10 @@ func (s *Multistream) Delete(ctx context.Context, id string, opts ...operations. return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -957,7 +966,11 @@ func (s *Multistream) Delete(ctx context.Context, id string, opts ...operations. req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1019,47 +1032,35 @@ func (s *Multistream) Delete(ctx context.Context, id string, opts ...operations. }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/playback.go b/playback.go index b6b3938..4322fda 100644 --- a/playback.go +++ b/playback.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" ) @@ -52,7 +51,12 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/playback/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -80,6 +84,10 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -110,7 +118,11 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -172,21 +184,11 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -198,17 +200,16 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option res.PlaybackInfo = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 404: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -220,42 +221,39 @@ func (s *Playback) Get(ctx context.Context, id string, opts ...operations.Option return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/retry/config.go b/retry/config.go index c051b0a..aa4b334 100644 --- a/retry/config.go +++ b/retry/config.go @@ -2,6 +2,15 @@ package retry +import ( + "errors" + "net/http" + "strconv" + "time" +) + +// BackoffStrategy defines the parameters for exponential backoff. This can be +// used to drive a retry loop for example. type BackoffStrategy struct { InitialInterval int MaxInterval int @@ -9,8 +18,128 @@ type BackoffStrategy struct { MaxElapsedTime int } +// Config configures a retry policy. type Config struct { Strategy string Backoff *BackoffStrategy RetryConnectionErrors bool } + +// PermanentError is an error that signals that some operation has terminally +// failed and should not be retried. +type PermanentError struct { + cause error +} + +// Permanent creates a PermanentError that signals to a retry loop that it +// should stop retrying an operation and return the underlying error. +func Permanent(cause error) error { + if IsPermanentError(cause) { + return cause + } + + return &PermanentError{ + cause: cause, + } +} + +func (e *PermanentError) Error() string { + return e.cause.Error() +} + +func (e *PermanentError) Unwrap() error { + return e.cause +} + +// TemporaryError represents a retryable error and signals to a retry loop that +// an operation may be retried with an optional wait interval. +type TemporaryError struct { + wait time.Duration + message string +} + +// Temporary creates a TemporaryError that signals to a retry loop that an +// operation can be retried. The error may also carry details about how long to +// wait before retrying. This wait interval may be used to override the retry +// policy in use. +func Temporary(message string) error { + return &TemporaryError{ + message: message, + } +} + +// TemporaryFromResponse creates a TemporaryError similar to Temporary but +// additionally parses the Retry-After header from a response to determine the +// wait interval before the next retry attempt. +func TemporaryFromResponse(message string, res *http.Response) error { + return &TemporaryError{ + wait: retryIntervalFromResponse(res), + message: message, + } +} + +func (e *TemporaryError) Error() string { + return e.message +} + +// RetryAfter returns the time to wait before retrying the request. The zero +// value should be interpreted by retry loops to mean they should fallback on +// their default policy whether expenonential, constant backoff or something +// else. It does not mean that an operation should be retried immediately. +func (e *TemporaryError) RetryAfter() time.Duration { + return e.wait +} + +func retryIntervalFromResponse(res *http.Response) time.Duration { + if res == nil { + return 0 + } + + retryVal := res.Header.Get("retry-after") + if retryVal == "" { + return 0 + } + + parsedNumber, err := strconv.ParseInt(retryVal, 10, 64) + if err == nil { + if parsedNumber < 0 { + return 0 + } else { + return time.Duration(parsedNumber) * time.Second + } + } + + parsedDate, err := time.Parse(time.RFC1123, retryVal) + if err == nil { + delta := parsedDate.Sub(time.Now()) + if delta < 0 { + return 0 + } else { + return delta + } + } + + return 0 +} + +// IsPermanentError returns true if an error value is or contains a +// PermanentError in its chain of errors. +func IsPermanentError(err error) bool { + if err == nil { + return false + } + + var pe *PermanentError + return errors.As(err, &pe) +} + +// IsTemporaryError returns true if an error value is or contains a +// TemporaryError in its chain of errors. +func IsTemporaryError(err error) bool { + if err == nil { + return false + } + + var pe *TemporaryError + return errors.As(err, &pe) +} diff --git a/room.go b/room.go index 5ad9da1..c022c23 100644 --- a/room.go +++ b/room.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -52,7 +51,12 @@ func (s *Room) Create(ctx context.Context, opts ...operations.Option) (*operatio } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/room") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -80,6 +84,10 @@ func (s *Room) Create(ctx context.Context, opts ...operations.Option) (*operatio return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -110,7 +118,11 @@ func (s *Room) Create(ctx context.Context, opts ...operations.Option) (*operatio req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -172,21 +184,11 @@ func (s *Room) Create(ctx context.Context, opts ...operations.Option) (*operatio }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -198,42 +200,39 @@ func (s *Room) Create(ctx context.Context, opts ...operations.Option) (*operatio res.CreateRoomResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -269,7 +268,12 @@ func (s *Room) Get(ctx context.Context, id string, opts ...operations.Option) (* } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -297,6 +301,10 @@ func (s *Room) Get(ctx context.Context, id string, opts ...operations.Option) (* return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -327,7 +335,11 @@ func (s *Room) Get(ctx context.Context, id string, opts ...operations.Option) (* req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -389,21 +401,11 @@ func (s *Room) Get(ctx context.Context, id string, opts ...operations.Option) (* }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -415,42 +417,39 @@ func (s *Room) Get(ctx context.Context, id string, opts ...operations.Option) (* res.Room = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -486,7 +485,12 @@ func (s *Room) Delete(ctx context.Context, id string, opts ...operations.Option) } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -514,6 +518,10 @@ func (s *Room) Delete(ctx context.Context, id string, opts ...operations.Option) return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -544,7 +552,11 @@ func (s *Room) Delete(ctx context.Context, id string, opts ...operations.Option) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -606,47 +618,35 @@ func (s *Room) Delete(ctx context.Context, id string, opts ...operations.Option) }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -685,7 +685,12 @@ func (s *Room) StartEgress(ctx context.Context, id string, roomEgressPayload com } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/egress", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -719,6 +724,10 @@ func (s *Room) StartEgress(ctx context.Context, id string, roomEgressPayload com return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -749,7 +758,11 @@ func (s *Room) StartEgress(ctx context.Context, id string, roomEgressPayload com req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -811,47 +824,35 @@ func (s *Room) StartEgress(ctx context.Context, id string, roomEgressPayload com }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -887,7 +888,12 @@ func (s *Room) StopEgress(ctx context.Context, id string, opts ...operations.Opt } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/egress", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -915,6 +921,10 @@ func (s *Room) StopEgress(ctx context.Context, id string, opts ...operations.Opt return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -945,7 +955,11 @@ func (s *Room) StopEgress(ctx context.Context, id string, opts ...operations.Opt req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1007,47 +1021,35 @@ func (s *Room) StopEgress(ctx context.Context, id string, opts ...operations.Opt }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1087,7 +1089,12 @@ func (s *Room) CreateUser(ctx context.Context, id string, roomUserPayload compon } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/user", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1121,6 +1128,10 @@ func (s *Room) CreateUser(ctx context.Context, id string, roomUserPayload compon return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1151,7 +1162,11 @@ func (s *Room) CreateUser(ctx context.Context, id string, roomUserPayload compon req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1213,21 +1228,11 @@ func (s *Room) CreateUser(ctx context.Context, id string, roomUserPayload compon }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1239,42 +1244,39 @@ func (s *Room) CreateUser(ctx context.Context, id string, roomUserPayload compon res.RoomUserResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1311,7 +1313,12 @@ func (s *Room) GetUser(ctx context.Context, id string, userID string, opts ...op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/user/{userId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1339,6 +1346,10 @@ func (s *Room) GetUser(ctx context.Context, id string, userID string, opts ...op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1369,7 +1380,11 @@ func (s *Room) GetUser(ctx context.Context, id string, userID string, opts ...op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1431,21 +1446,11 @@ func (s *Room) GetUser(ctx context.Context, id string, userID string, opts ...op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1457,42 +1462,39 @@ func (s *Room) GetUser(ctx context.Context, id string, userID string, opts ...op res.GetRoomUserResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1531,7 +1533,12 @@ func (s *Room) UpdateUser(ctx context.Context, id string, userID string, roomUse } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/user/{userId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1565,6 +1572,10 @@ func (s *Room) UpdateUser(ctx context.Context, id string, userID string, roomUse return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1595,7 +1606,11 @@ func (s *Room) UpdateUser(ctx context.Context, id string, userID string, roomUse req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1657,47 +1672,35 @@ func (s *Room) UpdateUser(ctx context.Context, id string, userID string, roomUse }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1734,7 +1737,12 @@ func (s *Room) DeleteUser(ctx context.Context, id string, userID string, opts .. } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/room/{id}/user/{userId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1762,6 +1770,10 @@ func (s *Room) DeleteUser(ctx context.Context, id string, userID string, opts .. return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1792,7 +1804,11 @@ func (s *Room) DeleteUser(ctx context.Context, id string, userID string, opts .. req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1854,47 +1870,35 @@ func (s *Room) DeleteUser(ctx context.Context, id string, userID string, opts .. }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/session.go b/session.go index bfc9acd..8e31eee 100644 --- a/session.go +++ b/session.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -53,7 +52,12 @@ func (s *Session) GetClips(ctx context.Context, id string, opts ...operations.Op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/session/{id}/clips", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -81,6 +85,10 @@ func (s *Session) GetClips(ctx context.Context, id string, opts ...operations.Op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -111,7 +119,11 @@ func (s *Session) GetClips(ctx context.Context, id string, opts ...operations.Op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -173,21 +185,11 @@ func (s *Session) GetClips(ctx context.Context, id string, opts ...operations.Op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -199,42 +201,39 @@ func (s *Session) GetClips(ctx context.Context, id string, opts ...operations.Op res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -264,7 +263,12 @@ func (s *Session) GetAll(ctx context.Context, opts ...operations.Option) (*opera } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/session") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -292,6 +296,10 @@ func (s *Session) GetAll(ctx context.Context, opts ...operations.Option) (*opera return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -322,7 +330,11 @@ func (s *Session) GetAll(ctx context.Context, opts ...operations.Option) (*opera req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -384,21 +396,11 @@ func (s *Session) GetAll(ctx context.Context, opts ...operations.Option) (*opera }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -410,42 +412,39 @@ func (s *Session) GetAll(ctx context.Context, opts ...operations.Option) (*opera res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -479,7 +478,12 @@ func (s *Session) Get(ctx context.Context, id string, opts ...operations.Option) } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/session/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -507,6 +511,10 @@ func (s *Session) Get(ctx context.Context, id string, opts ...operations.Option) return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -537,7 +545,11 @@ func (s *Session) Get(ctx context.Context, id string, opts ...operations.Option) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -599,21 +611,11 @@ func (s *Session) Get(ctx context.Context, id string, opts ...operations.Option) }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -625,42 +627,39 @@ func (s *Session) Get(ctx context.Context, id string, opts ...operations.Option) res.Session = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -695,7 +694,12 @@ func (s *Session) GetRecorded(ctx context.Context, parentID string, record *oper } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{parentId}/sessions", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -727,6 +731,10 @@ func (s *Session) GetRecorded(ctx context.Context, parentID string, record *oper return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -757,7 +765,11 @@ func (s *Session) GetRecorded(ctx context.Context, parentID string, record *oper req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -819,21 +831,11 @@ func (s *Session) GetRecorded(ctx context.Context, parentID string, record *oper }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -845,42 +847,39 @@ func (s *Session) GetRecorded(ctx context.Context, parentID string, record *oper res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/stream.go b/stream.go index 5bde925..e3d5a4f 100644 --- a/stream.go +++ b/stream.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -62,7 +61,12 @@ func (s *Stream) Create(ctx context.Context, request components.NewStreamPayload } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/stream") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -96,6 +100,10 @@ func (s *Stream) Create(ctx context.Context, request components.NewStreamPayload return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -126,7 +134,11 @@ func (s *Stream) Create(ctx context.Context, request components.NewStreamPayload req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -188,21 +200,11 @@ func (s *Stream) Create(ctx context.Context, request components.NewStreamPayload }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 201: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -214,42 +216,39 @@ func (s *Stream) Create(ctx context.Context, request components.NewStreamPayload res.Stream = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -283,7 +282,12 @@ func (s *Stream) GetAll(ctx context.Context, streamsonly *string, opts ...operat } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/stream") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -315,6 +319,10 @@ func (s *Stream) GetAll(ctx context.Context, streamsonly *string, opts ...operat return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -345,7 +353,11 @@ func (s *Stream) GetAll(ctx context.Context, streamsonly *string, opts ...operat req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -407,21 +419,11 @@ func (s *Stream) GetAll(ctx context.Context, streamsonly *string, opts ...operat }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -433,42 +435,39 @@ func (s *Stream) GetAll(ctx context.Context, streamsonly *string, opts ...operat res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -502,7 +501,12 @@ func (s *Stream) Get(ctx context.Context, id string, opts ...operations.Option) } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -530,6 +534,10 @@ func (s *Stream) Get(ctx context.Context, id string, opts ...operations.Option) return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -560,7 +568,11 @@ func (s *Stream) Get(ctx context.Context, id string, opts ...operations.Option) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -622,21 +634,11 @@ func (s *Stream) Get(ctx context.Context, id string, opts ...operations.Option) }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -648,42 +650,39 @@ func (s *Stream) Get(ctx context.Context, id string, opts ...operations.Option) res.Stream = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -718,7 +717,12 @@ func (s *Stream) Update(ctx context.Context, id string, streamPatchPayload compo } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -752,6 +756,10 @@ func (s *Stream) Update(ctx context.Context, id string, streamPatchPayload compo return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -782,7 +790,11 @@ func (s *Stream) Update(ctx context.Context, id string, streamPatchPayload compo req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -844,47 +856,35 @@ func (s *Stream) Update(ctx context.Context, id string, streamPatchPayload compo }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -922,7 +922,12 @@ func (s *Stream) Delete(ctx context.Context, id string, opts ...operations.Optio } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -950,6 +955,10 @@ func (s *Stream) Delete(ctx context.Context, id string, opts ...operations.Optio return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -980,7 +989,11 @@ func (s *Stream) Delete(ctx context.Context, id string, opts ...operations.Optio req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1042,47 +1055,35 @@ func (s *Stream) Delete(ctx context.Context, id string, opts ...operations.Optio }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1124,7 +1125,12 @@ func (s *Stream) Terminate(ctx context.Context, id string, opts ...operations.Op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}/terminate", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1152,6 +1158,10 @@ func (s *Stream) Terminate(ctx context.Context, id string, opts ...operations.Op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1182,7 +1192,11 @@ func (s *Stream) Terminate(ctx context.Context, id string, opts ...operations.Op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1244,47 +1258,35 @@ func (s *Stream) Terminate(ctx context.Context, id string, opts ...operations.Op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1325,7 +1327,12 @@ func (s *Stream) StartPull(ctx context.Context, id string, opts ...operations.Op } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}/start-pull", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1353,6 +1360,10 @@ func (s *Stream) StartPull(ctx context.Context, id string, opts ...operations.Op return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1383,7 +1394,11 @@ func (s *Stream) StartPull(ctx context.Context, id string, opts ...operations.Op req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1445,47 +1460,35 @@ func (s *Stream) StartPull(ctx context.Context, id string, opts ...operations.Op }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1515,7 +1518,12 @@ func (s *Stream) CreateClip(ctx context.Context, request components.ClipPayload, } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/clip") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1549,6 +1557,10 @@ func (s *Stream) CreateClip(ctx context.Context, request components.ClipPayload, return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1579,7 +1591,11 @@ func (s *Stream) CreateClip(ctx context.Context, request components.ClipPayload, req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1641,21 +1657,11 @@ func (s *Stream) CreateClip(ctx context.Context, request components.ClipPayload, }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1667,42 +1673,39 @@ func (s *Stream) CreateClip(ctx context.Context, request components.ClipPayload, res.Data = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1736,7 +1739,12 @@ func (s *Stream) GetClips(ctx context.Context, id string, opts ...operations.Opt } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}/clips", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1764,6 +1772,10 @@ func (s *Stream) GetClips(ctx context.Context, id string, opts ...operations.Opt return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1794,7 +1806,11 @@ func (s *Stream) GetClips(ctx context.Context, id string, opts ...operations.Opt req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1856,21 +1872,11 @@ func (s *Stream) GetClips(ctx context.Context, id string, opts ...operations.Opt }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1882,42 +1888,39 @@ func (s *Stream) GetClips(ctx context.Context, id string, opts ...operations.Opt res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1952,7 +1955,12 @@ func (s *Stream) AddMultistreamTarget(ctx context.Context, id string, targetAddP } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}/create-multistream-target", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1986,6 +1994,10 @@ func (s *Stream) AddMultistreamTarget(ctx context.Context, id string, targetAddP return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2016,7 +2028,11 @@ func (s *Stream) AddMultistreamTarget(ctx context.Context, id string, targetAddP req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -2078,47 +2094,35 @@ func (s *Stream) AddMultistreamTarget(ctx context.Context, id string, targetAddP }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -2153,7 +2157,12 @@ func (s *Stream) RemoveMultistreamTarget(ctx context.Context, id string, targetI } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/stream/{id}/multistream/{targetId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -2181,6 +2190,10 @@ func (s *Stream) RemoveMultistreamTarget(ctx context.Context, id string, targetI return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2211,7 +2224,11 @@ func (s *Stream) RemoveMultistreamTarget(ctx context.Context, id string, targetI req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -2273,47 +2290,35 @@ func (s *Stream) RemoveMultistreamTarget(ctx context.Context, id string, targetI }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 204: case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/task.go b/task.go index f992671..85fb5ad 100644 --- a/task.go +++ b/task.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -49,7 +48,12 @@ func (s *Task) GetAll(ctx context.Context, opts ...operations.Option) (*operatio } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/task") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -77,6 +81,10 @@ func (s *Task) GetAll(ctx context.Context, opts ...operations.Option) (*operatio return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -107,7 +115,11 @@ func (s *Task) GetAll(ctx context.Context, opts ...operations.Option) (*operatio req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -169,21 +181,11 @@ func (s *Task) GetAll(ctx context.Context, opts ...operations.Option) (*operatio }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -195,42 +197,39 @@ func (s *Task) GetAll(ctx context.Context, opts ...operations.Option) (*operatio res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -264,7 +263,12 @@ func (s *Task) Get(ctx context.Context, taskID string, opts ...operations.Option } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/task/{taskId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -292,6 +296,10 @@ func (s *Task) Get(ctx context.Context, taskID string, opts ...operations.Option return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -322,7 +330,11 @@ func (s *Task) Get(ctx context.Context, taskID string, opts ...operations.Option req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -384,21 +396,11 @@ func (s *Task) Get(ctx context.Context, taskID string, opts ...operations.Option }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -410,21 +412,19 @@ func (s *Task) Get(ctx context.Context, taskID string, opts ...operations.Option res.Task = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: } diff --git a/transcode.go b/transcode.go index 045470e..f4d355a 100644 --- a/transcode.go +++ b/transcode.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -178,7 +177,12 @@ func (s *Transcode) Create(ctx context.Context, request components.TranscodePayl } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/transcode") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -212,6 +216,10 @@ func (s *Transcode) Create(ctx context.Context, request components.TranscodePayl return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -242,7 +250,11 @@ func (s *Transcode) Create(ctx context.Context, request components.TranscodePayl req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -304,21 +316,11 @@ func (s *Transcode) Create(ctx context.Context, request components.TranscodePayl }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -330,42 +332,39 @@ func (s *Transcode) Create(ctx context.Context, request components.TranscodePayl res.Task = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } diff --git a/webhook.go b/webhook.go index a675382..6b51dab 100644 --- a/webhook.go +++ b/webhook.go @@ -6,13 +6,12 @@ import ( "bytes" "context" "fmt" - "github.com/cenkalti/backoff/v4" "github.com/livepeer/livepeer-go/internal/hooks" "github.com/livepeer/livepeer-go/internal/utils" "github.com/livepeer/livepeer-go/models/components" "github.com/livepeer/livepeer-go/models/operations" "github.com/livepeer/livepeer-go/models/sdkerrors" - "io" + "github.com/livepeer/livepeer-go/retry" "net/http" "net/url" ) @@ -49,7 +48,12 @@ func (s *Webhook) GetAll(ctx context.Context, opts ...operations.Option) (*opera } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/webhook") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -77,6 +81,10 @@ func (s *Webhook) GetAll(ctx context.Context, opts ...operations.Option) (*opera return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -107,7 +115,11 @@ func (s *Webhook) GetAll(ctx context.Context, opts ...operations.Option) (*opera req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -169,21 +181,11 @@ func (s *Webhook) GetAll(ctx context.Context, opts ...operations.Option) (*opera }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -195,42 +197,39 @@ func (s *Webhook) GetAll(ctx context.Context, opts ...operations.Option) (*opera res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -261,7 +260,12 @@ func (s *Webhook) Create(ctx context.Context, request components.WebhookInput, o } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := url.JoinPath(baseURL, "/webhook") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -295,6 +299,10 @@ func (s *Webhook) Create(ctx context.Context, request components.WebhookInput, o return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -325,7 +333,11 @@ func (s *Webhook) Create(ctx context.Context, request components.WebhookInput, o req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -387,21 +399,11 @@ func (s *Webhook) Create(ctx context.Context, request components.WebhookInput, o }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -413,42 +415,39 @@ func (s *Webhook) Create(ctx context.Context, request components.WebhookInput, o res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -482,7 +481,12 @@ func (s *Webhook) Get(ctx context.Context, id string, opts ...operations.Option) } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -510,6 +514,10 @@ func (s *Webhook) Get(ctx context.Context, id string, opts ...operations.Option) return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -540,7 +548,11 @@ func (s *Webhook) Get(ctx context.Context, id string, opts ...operations.Option) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -602,21 +614,11 @@ func (s *Webhook) Get(ctx context.Context, id string, opts ...operations.Option) }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -628,42 +630,39 @@ func (s *Webhook) Get(ctx context.Context, id string, opts ...operations.Option) res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -698,7 +697,12 @@ func (s *Webhook) Update(ctx context.Context, id string, webhook components.Webh } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -732,6 +736,10 @@ func (s *Webhook) Update(ctx context.Context, id string, webhook components.Webh return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -762,7 +770,11 @@ func (s *Webhook) Update(ctx context.Context, id string, webhook components.Webh req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -824,21 +836,11 @@ func (s *Webhook) Update(ctx context.Context, id string, webhook components.Webh }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -850,42 +852,39 @@ func (s *Webhook) Update(ctx context.Context, id string, webhook components.Webh res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -919,7 +918,12 @@ func (s *Webhook) Delete(ctx context.Context, id string, opts ...operations.Opti } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -947,6 +951,10 @@ func (s *Webhook) Delete(ctx context.Context, id string, opts ...operations.Opti return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -977,7 +985,11 @@ func (s *Webhook) Delete(ctx context.Context, id string, opts ...operations.Opti req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1039,21 +1051,11 @@ func (s *Webhook) Delete(ctx context.Context, id string, opts ...operations.Opti }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1065,42 +1067,39 @@ func (s *Webhook) Delete(ctx context.Context, id string, opts ...operations.Opti res.Webhook = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1134,7 +1133,12 @@ func (s *Webhook) GetLogs(ctx context.Context, id string, opts ...operations.Opt } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}/log", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1162,6 +1166,10 @@ func (s *Webhook) GetLogs(ctx context.Context, id string, opts ...operations.Opt return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1192,7 +1200,11 @@ func (s *Webhook) GetLogs(ctx context.Context, id string, opts ...operations.Opt req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1254,21 +1266,11 @@ func (s *Webhook) GetLogs(ctx context.Context, id string, opts ...operations.Opt }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1280,42 +1282,39 @@ func (s *Webhook) GetLogs(ctx context.Context, id string, opts ...operations.Opt res.Data = out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1350,7 +1349,12 @@ func (s *Webhook) GetLog(ctx context.Context, id string, logID string, opts ...o } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}/log/{logId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1378,6 +1382,10 @@ func (s *Webhook) GetLog(ctx context.Context, id string, logID string, opts ...o return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1408,7 +1416,11 @@ func (s *Webhook) GetLog(ctx context.Context, id string, logID string, opts ...o req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1470,21 +1482,11 @@ func (s *Webhook) GetLog(ctx context.Context, id string, logID string, opts ...o }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1496,42 +1498,39 @@ func (s *Webhook) GetLog(ctx context.Context, id string, logID string, opts ...o res.WebhookLog = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } } @@ -1569,7 +1568,12 @@ func (s *Webhook) ResendLog(ctx context.Context, id string, logID string, opts . } } - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } opURL, err := utils.GenerateURL(ctx, baseURL, "/webhook/{id}/log/{logId}/resend", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) @@ -1597,6 +1601,10 @@ func (s *Webhook) ResendLog(ctx context.Context, id string, logID string, opts . return nil, err } + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1627,7 +1635,11 @@ func (s *Webhook) ResendLog(ctx context.Context, id string, logID string, opts . req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { - return nil, backoff.Permanent(err) + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) } httpRes, err := s.sdkConfiguration.Client.Do(req) @@ -1689,21 +1701,11 @@ func (s *Webhook) ResendLog(ctx context.Context, id string, logID string, opts . }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1715,42 +1717,39 @@ func (s *Webhook) ResendLog(ctx context.Context, id string, logID string, opts . res.WebhookLog = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out sdkerrors.Error + var out components.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } res.Error = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } }