Compare commits

...

44 Commits

Author SHA1 Message Date
speakeasybot
a34f15746e ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.285.0 2024-05-08 18:15:46 +00:00
speakeasybot
12afbc6467 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.283.1 2024-05-08 00:39:09 +00:00
speakeasybot
8267c3fcbd ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.280.1 2024-05-07 00:47:31 +00:00
speakeasybot
3f2fc4fe8c ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.279.0 2024-05-06 00:48:33 +00:00
speakeasybot
21517ca298 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.279.0 2024-05-05 00:51:13 +00:00
speakeasybot
d7fe60ed91 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.279.0 2024-05-04 00:47:01 +00:00
speakeasybot
b09c6ad37a ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.8 2024-05-03 00:50:55 +00:00
speakeasybot
6a5cd06342 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.4 2024-05-02 00:46:14 +00:00
speakeasybot
9531527f23 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.4 2024-05-01 00:51:24 +00:00
speakeasybot
db2b15241c ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.0 2024-04-30 00:46:14 +00:00
speakeasybot
344db7cbcb ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.276.0 2024-04-29 00:47:45 +00:00
speakeasybot
af9748433a ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.276.0 2024-04-28 00:51:17 +00:00
speakeasybot
8f332b739e ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.276.0 2024-04-27 00:45:49 +00:00
speakeasybot
c504a2d46e ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.274.1 2024-04-26 00:46:33 +00:00
speakeasybot
95d64024f2 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.274.1 2024-04-25 00:49:21 +00:00
speakeasybot
457b36fb49 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.271.0 2024-04-24 00:45:46 +00:00
Luke Hagar
8691720920 Added code samples and regenerated 2024-04-23 13:50:17 -05:00
Luke Hagar
205c454485 Update gen.yaml 2024-04-23 13:49:15 -05:00
Luke Hagar
71b5f4f4b7 Migrated to workflows 2024-04-23 13:48:49 -05:00
Luke Hagar
f3779b0079 Moved gen.yaml 2024-04-23 13:48:40 -05:00
Luke Hagar
0eaf609b40 Updated generation action 2024-04-23 13:48:31 -05:00
speakeasy-github[bot]
b0931cba2e chore: update dependencies 2024-04-22 16:15:36 +00:00
speakeasybot
d09f9292ce ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.267.2 2024-04-22 16:15:05 +00:00
speakeasy-github
9a382342e4 chore: update dependencies 2024-04-10 00:45:49 +00:00
speakeasybot
b8b984dc14 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.245.0 2024-04-10 00:45:10 +00:00
speakeasy-github
0de5991239 chore: update dependencies 2024-04-09 00:45:54 +00:00
speakeasybot
0ff88615e0 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.244.0 2024-04-09 00:45:22 +00:00
speakeasy-github
0eb6f2c692 chore: update dependencies 2024-04-03 00:45:14 +00:00
speakeasybot
0adacc0e13 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.235.0 2024-04-03 00:44:28 +00:00
speakeasy-github[bot]
ec6ef7db64 chore: update dependencies 2024-03-29 16:38:18 +00:00
speakeasybot
32a5beaae6 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.228.1 2024-03-29 16:37:36 +00:00
speakeasy-github
ea30334a95 chore: update dependencies 2024-03-27 00:44:58 +00:00
speakeasybot
f3eb760757 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.227.0 2024-03-27 00:44:22 +00:00
speakeasy-github
683823eab9 chore: update dependencies 2024-03-20 00:44:38 +00:00
speakeasybot
6942d6b905 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.213.0 2024-03-20 00:43:58 +00:00
speakeasy-github
1a7051235f chore: update dependencies 2024-03-13 00:46:09 +00:00
speakeasybot
68fedfa8fc ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.207.1 2024-03-13 00:44:54 +00:00
speakeasy-github
5916d2ace5 chore: update dependencies 2024-03-08 00:44:44 +00:00
speakeasybot
417454ebb2 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.204.1 2024-03-08 00:44:04 +00:00
Luke Hagar
992291fe20 Update LICENSE.md 2024-03-06 07:50:44 -06:00
speakeasy-github
515f318f05 chore: update dependencies 2024-03-02 00:43:31 +00:00
speakeasybot
8b81bc5692 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.200.0 2024-03-02 00:43:01 +00:00
speakeasy-github
9dd356ea91 chore: update dependencies 2024-02-27 00:44:01 +00:00
speakeasybot
efe42104bc ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.194.0 2024-02-27 00:43:22 +00:00
77 changed files with 2354 additions and 2492 deletions

View File

@@ -1,29 +1,25 @@
name: Generate
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
checks: write
contents: write
pull-requests: write
statuses: write
"on":
workflow_dispatch:
inputs:
force:
description: Force generation of SDKs
type: boolean
default: false
schedule:
- cron: 0 0 * * *
workflow_dispatch:
inputs:
force:
description: Force generation of SDKs
type: boolean
default: false
schedule:
- cron: 0 0 * * *
jobs:
generate:
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-generation.yaml@v14
with:
force: ${{ github.event.inputs.force }}
languages: |
- go
mode: direct
openapi_docs: |
- https://raw.githubusercontent.com/LukeHagar/plex-api-spec/main/plex-media-server-spec-dereferenced.yaml
speakeasy_version: latest
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
generate:
uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15
with:
force: ${{ github.event.inputs.force }}
mode: direct
speakeasy_version: latest
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

View File

@@ -1,25 +1,33 @@
lockVersion: 2.0.0
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
management:
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
docChecksum: 543cb95355401d2e3c2ba11a50d9dd94
docVersion: 0.0.3
speakeasyVersion: internal
generationVersion: 2.272.4
releaseVersion: 0.4.1
configChecksum: 181fc3f925a145abd1f8441c7a0c7cda
speakeasyVersion: 1.285.0
generationVersion: 2.326.3
releaseVersion: 0.7.0
configChecksum: 98c0e864ba8f7c2e3b366fd643dd90ab
repoURL: https://github.com/LukeHagar/plexgo.git
repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexgo
published: true
features:
go:
constsAndDefaults: 0.1.3
core: 3.4.3
additionalDependencies: 0.1.0
constsAndDefaults: 0.1.4
core: 3.4.7
flattening: 2.81.1
globalSecurity: 2.82.7
globalServerURLs: 2.82.1
globalSecurity: 2.82.9
globalSecurityCallbacks: 0.1.0
globalSecurityFlattening: 0.1.0
globalServerURLs: 2.82.2
globals: 2.82.2
intellisenseMarkdownSupport: 0.1.0
methodServerURLs: 2.82.1
nameOverrides: 2.81.1
nameOverrides: 2.81.2
responseFormat: 0.1.1
sdkHooks: 0.1.0
unions: 2.85.5
generatedFiles:
- server.go
- media.go
@@ -54,6 +62,7 @@ generatedFiles:
- internal/utils/retries.go
- internal/utils/security.go
- internal/utils/utils.go
- internal/globals/globals.go
- /models/operations/getservercapabilities.go
- /models/operations/getserverpreferences.go
- /models/operations/getavailableclients.go
@@ -84,7 +93,6 @@ generatedFiles:
- /models/operations/getlibraries.go
- /models/operations/getlibrary.go
- /models/operations/deletelibrary.go
- /models/operations/getlibraryitems.go
- /models/operations/refreshlibrary.go
- /models/operations/searchlibrary.go
- /models/operations/getmetadata.go
@@ -304,19 +312,6 @@ generatedFiles:
- docs/models/operations/getlibraryresponse.md
- docs/models/operations/deletelibraryrequest.md
- docs/models/operations/deletelibraryresponse.md
- docs/models/operations/tag.md
- docs/models/operations/getlibraryitemsrequest.md
- docs/models/operations/getlibraryitemspart.md
- docs/models/operations/getlibraryitemsmedia.md
- docs/models/operations/getlibraryitemsgenre.md
- docs/models/operations/getlibraryitemscountry.md
- docs/models/operations/getlibraryitemsdirector.md
- docs/models/operations/getlibraryitemswriter.md
- docs/models/operations/getlibraryitemsrole.md
- docs/models/operations/getlibraryitemsmetadata.md
- docs/models/operations/getlibraryitemsmediacontainer.md
- docs/models/operations/getlibraryitemsresponsebody.md
- docs/models/operations/getlibraryitemsresponse.md
- docs/models/operations/refreshlibraryrequest.md
- docs/models/operations/refreshlibraryresponse.md
- docs/models/operations/type.md
@@ -360,10 +355,12 @@ generatedFiles:
- docs/models/operations/loglineresponse.md
- docs/models/operations/logmultilineresponse.md
- docs/models/operations/enablepapertrailresponse.md
- docs/models/operations/getpinglobals.md
- docs/models/operations/getpinrequest.md
- docs/models/operations/location.md
- docs/models/operations/getpinresponsebody.md
- docs/models/operations/getpinresponse.md
- docs/models/operations/gettokenglobals.md
- docs/models/operations/gettokenrequest.md
- docs/models/operations/gettokenresponse.md
- docs/models/operations/queryparamtype.md

View File

@@ -6,13 +6,13 @@ generation:
optionalPropertyRendering: withExample
useClassNamesForArrayFields: true
fixes:
nameResolutionDec2023: false
parameterOrderingFeb2024: false
requestResponseComponentNamesFeb2024: false
nameResolutionDec2023: true
parameterOrderingFeb2024: true
requestResponseComponentNamesFeb2024: true
auth:
oAuth2ClientCredentialsEnabled: false
oAuth2ClientCredentialsEnabled: true
go:
version: 0.4.1
version: 0.7.0
additionalDependencies: {}
clientServerStatusCodesAsErrors: true
flattenGlobalSecurity: true
@@ -26,5 +26,7 @@ go:
webhooks: models/webhooks
inputModelSuffix: input
maxMethodParams: 4
methodArguments: require-security-and-request
outputModelSuffix: output
packageName: github.com/LukeHagar/plexgo
responseFormat: envelope

16
.speakeasy/workflow.lock Normal file
View File

@@ -0,0 +1,16 @@
speakeasyVersion: 1.285.0
sources: {}
targets: {}
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
sources:
my-source:
inputs:
- location: https://raw.githubusercontent.com/LukeHagar/plex-api-spec/main/plex-media-server-spec-dereferenced.yaml
targets:
plexgo:
target: go
source: my-source
codeSamples:
output: codeSamples.yaml

12
.speakeasy/workflow.yaml Normal file
View File

@@ -0,0 +1,12 @@
workflowVersion: 1.0.0
speakeasyVersion: latest
sources:
my-source:
inputs:
- location: https://raw.githubusercontent.com/LukeHagar/plex-api-spec/main/plex-media-server-spec-dereferenced.yaml
targets:
plexgo:
target: go
source: my-source
codeSamples:
output: codeSamples.yaml

View File

@@ -1,21 +1,7 @@
MIT License
Copyright 2024 Luke Hagar
Copyright (c) 2023 LukeHagar
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -33,6 +33,7 @@ import (
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -40,7 +41,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -105,7 +105,6 @@ func main() {
* [GetLibraries](docs/sdks/library/README.md#getlibraries) - Get All Libraries
* [GetLibrary](docs/sdks/library/README.md#getlibrary) - Get Library Details
* [DeleteLibrary](docs/sdks/library/README.md#deletelibrary) - Delete Library Section
* [GetLibraryItems](docs/sdks/library/README.md#getlibraryitems) - Get Library Items
* [RefreshLibrary](docs/sdks/library/README.md#refreshlibrary) - Refresh Library
* [SearchLibrary](docs/sdks/library/README.md#searchlibrary) - Search Library
* [GetMetadata](docs/sdks/library/README.md#getmetadata) - Get Items Metadata
@@ -185,6 +184,7 @@ import (
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -235,6 +235,7 @@ func main() {
s := plexgo.New(
plexgo.WithServerIndex(0),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -242,7 +243,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -274,6 +274,7 @@ func main() {
s := plexgo.New(
plexgo.WithServerURL("{protocol}://{ip}:{port}"),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -281,7 +282,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -302,18 +302,19 @@ import (
)
func main() {
s := plexgo.New()
var xPlexClientIdentifier string = "<value>"
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), xPlexClientIdentifier, strong)
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier, operations.WithServerURL("https://plex.tv/api/v2"))
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -375,6 +376,7 @@ import (
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -382,7 +384,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -417,6 +418,59 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on
```
<!-- End Special Types [types] -->
<!-- Start Global Parameters [global-parameters] -->
## Global Parameters
A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set `X-Plex-Client-Identifier` to `"Postman"` at SDK initialization and then you do not have to pass the same value on calls to operations like `GetPin`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
### Available Globals
The following global parameter is available. The required parameter must be set when you initialize the SDK client.
| Name | Type | Required | Description |
| ---- | ---- |:--------:| ----------- |
| XPlexClientIdentifier | string | ✔️ | The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
|
### Example
```go
package main
import (
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
<!-- End Global Parameters [global-parameters] -->
<!-- Placeholder for Future Speakeasy SDK Sections -->
# Development

View File

@@ -139,3 +139,267 @@ Based on:
- [go v0.4.1] .
### Releases
- [Go v0.4.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.1 - .
## 2024-02-27 00:43:09
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.194.0 (2.272.7) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.4.2] .
### Releases
- [Go v0.4.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.2 - .
## 2024-03-02 00:42:48
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.200.0 (2.277.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.4.3] .
### Releases
- [Go v0.4.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.3 - .
## 2024-03-08 00:43:49
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.204.1 (2.279.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.5.0] .
### Releases
- [Go v0.5.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.0 - .
## 2024-03-13 00:44:38
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.207.1 (2.280.6) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.5.1] .
### Releases
- [Go v0.5.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.1 - .
## 2024-03-20 00:43:42
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.213.0 (2.283.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.5.2] .
### Releases
- [Go v0.5.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.2 - .
## 2024-03-27 00:44:06
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.227.0 (2.291.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.5.3] .
### Releases
- [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - .
## 2024-03-29 16:37:06
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.228.1 (2.292.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.0] .
### Releases
- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - .
## 2024-04-03 00:44:02
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.235.0 (2.298.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.1] .
### Releases
- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - .
## 2024-04-09 00:44:53
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.244.0 (2.301.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.2] .
### Releases
- [Go v0.6.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.2 - .
## 2024-04-10 00:44:38
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.245.0 (2.301.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.3] .
### Releases
- [Go v0.6.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.3 - .
## 2024-04-22 16:14:47
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.267.2 (2.312.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.4] .
### Releases
- [Go v0.6.4] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.4 - .
## 2024-04-24 00:45:20
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.271.0 (2.312.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
## 2024-04-25 00:48:55
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.274.1 (2.314.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
## 2024-04-26 00:46:09
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.274.1 (2.314.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
## 2024-04-27 00:45:23
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.276.0 (2.314.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-04-28 00:50:52
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.276.0 (2.314.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-04-29 00:47:20
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.276.0 (2.314.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-04-30 00:45:49
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.277.0 (2.317.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-05-01 00:50:59
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.277.4 (2.318.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-05-02 00:45:48
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.277.4 (2.318.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.5] .
### Releases
- [Go v0.6.5] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.5 - .
## 2024-05-03 00:50:00
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.277.8 (2.319.10) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.6] .
### Releases
- [Go v0.6.6] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.6 - .
## 2024-05-04 00:46:06
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.279.0 (2.322.5) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.7] .
### Releases
- [Go v0.6.7] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.7 - .
## 2024-05-05 00:50:48
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.279.0 (2.322.5) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.7] .
### Releases
- [Go v0.6.7] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.7 - .
## 2024-05-06 00:48:07
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.279.0 (2.322.5) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.7] .
### Releases
- [Go v0.6.7] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.7 - .
## 2024-05-07 00:47:05
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.280.1 (2.322.5) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.7] .
### Releases
- [Go v0.6.7] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.7 - .
## 2024-05-08 00:38:43
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.283.1 (2.324.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.7] .
### Releases
- [Go v0.6.7] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.7 - .
## 2024-05-08 18:14:51
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.285.0 (2.326.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.7.0] .
### Releases
- [Go v0.7.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.7.0 - .

View File

@@ -12,6 +12,7 @@ import (
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
@@ -19,7 +20,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}

View File

@@ -38,6 +38,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getServerActivities",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -54,14 +55,16 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -72,9 +75,11 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -82,11 +87,10 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetServerActivitiesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -100,7 +104,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetServerActivitiesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -108,7 +112,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -118,17 +122,19 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetServerActivitiesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -140,6 +146,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "cancelServerActivities",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -160,14 +167,16 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -178,9 +187,11 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -188,11 +199,10 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.CancelServerActivitiesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -213,17 +223,19 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.CancelServerActivitiesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -32,6 +32,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getTransientToken",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -57,14 +58,16 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -75,9 +78,11 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -85,11 +90,10 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetTransientTokenResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -110,17 +114,19 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetTransientTokenResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -133,6 +139,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getSourceConnectionInformation",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -157,14 +164,16 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -175,9 +184,11 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -185,11 +196,10 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetSourceConnectionInformationResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -210,17 +220,19 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetSourceConnectionInformationResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

114
butler.go
View File

@@ -32,6 +32,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getButlerTasks",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -48,14 +49,16 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -66,9 +69,11 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -76,11 +81,10 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetButlerTasksResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -94,7 +98,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetButlerTasksResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -102,7 +106,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -112,17 +116,19 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetButlerTasksResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -138,6 +144,7 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "startAllTasks",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -154,14 +161,16 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -172,9 +181,11 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -182,11 +193,10 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StartAllTasksResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -207,17 +217,19 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StartAllTasksResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -229,6 +241,7 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "stopAllTasks",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -245,14 +258,16 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -263,9 +278,11 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -273,11 +290,10 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StopAllTasksResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -298,17 +314,19 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StopAllTasksResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -324,6 +342,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "startTask",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -344,14 +363,16 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -362,9 +383,11 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -372,11 +395,10 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StartTaskResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -399,17 +421,19 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StartTaskResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -421,6 +445,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "stopTask",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -441,14 +466,16 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -459,9 +486,11 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "404", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -469,11 +498,10 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StopTaskResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -496,17 +524,19 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StopTaskResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

359
codeSamples.yaml Normal file
View File

@@ -0,0 +1,359 @@
overlay: 1.0.0
info:
title: CodeSamples overlay for go target
version: 0.0.0
actions:
- target: $["paths"]["/pins"]["post"]
update:
x-codeSamples:
- lang: go
label: getPin
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var strong *bool = plexgo.Bool(false)\n\n var xPlexClientIdentifier *string = plexgo.String(\"Postman\")\n \n ctx := context.Background()\n res, err := s.GetPin(ctx, strong, xPlexClientIdentifier)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/pins/{pinID}"]["get"]
update:
x-codeSamples:
- lang: go
label: getToken
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var pinID string = \"<value>\"\n\n var xPlexClientIdentifier *string = plexgo.String(\"Postman\")\n \n ctx := context.Background()\n res, err := s.GetToken(ctx, pinID, xPlexClientIdentifier)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/devices"]["get"]
update:
x-codeSamples:
- lang: go
label: getDevices
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetDevices(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/hubs/search"]["get"]
update:
x-codeSamples:
- lang: go
label: performSearch
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var query string = \"dylan\"\n\n var sectionID *float64 = plexgo.Float64(1516.53)\n\n var limit *float64 = plexgo.Float64(5)\n \n ctx := context.Background()\n res, err := s.PerformSearch(ctx, query, sectionID, limit)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/log"]["post"]
update:
x-codeSamples:
- lang: go
label: logMultiLine
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var request string = \"level=4&message=Test%20message%201&source=postman\nlevel=3&message=Test%20message%202&source=postman\nlevel=1&message=Test%20message%203&source=postman\"\n \n ctx := context.Background()\n res, err := s.LogMultiLine(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/sections"]["get"]
update:
x-codeSamples:
- lang: go
label: getLibraries
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetLibraries(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/metadata/{ratingKey}"]["get"]
update:
x-codeSamples:
- lang: go
label: getMetadata
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var ratingKey float64 = 8382.31\n \n ctx := context.Background()\n res, err := s.GetMetadata(ctx, ratingKey)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/myplex/account"]["get"]
update:
x-codeSamples:
- lang: go
label: getMyPlexAccount
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetMyPlexAccount(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/activities"]["get"]
update:
x-codeSamples:
- lang: go
label: getServerActivities
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetServerActivities(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}/items"]["delete"]
update:
x-codeSamples:
- lang: go
label: clearPlaylistContents
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 1893.18\n \n ctx := context.Background()\n res, err := s.ClearPlaylistContents(ctx, playlistID)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/:/scrobble"]["get"]
update:
x-codeSamples:
- lang: go
label: markPlayed
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var key float64 = 59398\n \n ctx := context.Background()\n res, err := s.MarkPlayed(ctx, key)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/search"]["get"]
update:
x-codeSamples:
- lang: go
label: getSearchResults
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var query string = \"110\"\n \n ctx := context.Background()\n res, err := s.GetSearchResults(ctx, query)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/recentlyAdded"]["get"]
update:
x-codeSamples:
- lang: go
label: getRecentlyAdded
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetRecentlyAdded(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"]
update:
x-codeSamples:
- lang: go
label: getMetadataChildren
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var ratingKey float64 = 1539.14\n \n ctx := context.Background()\n res, err := s.GetMetadataChildren(ctx, ratingKey)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}"]["put"]
update:
x-codeSamples:
- lang: go
label: updatePlaylist
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 3915\n\n var title *string = plexgo.String(\"<value>\")\n\n var summary *string = plexgo.String(\"<value>\")\n \n ctx := context.Background()\n res, err := s.UpdatePlaylist(ctx, playlistID, title, summary)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/identity"]["get"]
update:
x-codeSamples:
- lang: go
label: getServerIdentity
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetServerIdentity(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"]
update:
x-codeSamples:
- lang: go
label: startUniversalTranscode
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n request := operations.StartUniversalTranscodeRequest{\n HasMDE: 1,\n Path: \"/library/metadata/23409\",\n MediaIndex: 0,\n PartIndex: 0,\n Protocol: \"hls\",\n FastSeek: plexgo.Float64(0),\n DirectPlay: plexgo.Float64(0),\n DirectStream: plexgo.Float64(0),\n SubtitleSize: plexgo.Float64(100),\n Subtites: plexgo.String(\"burn\"),\n AudioBoost: plexgo.Float64(100),\n Location: plexgo.String(\"lan\"),\n MediaBufferSize: plexgo.Float64(102400),\n Session: plexgo.String(\"zvcage8b7rkioqcm8f4uns4c\"),\n AddDebugOverlay: plexgo.Float64(0),\n AutoAdjustQuality: plexgo.Float64(0),\n }\n \n ctx := context.Background()\n res, err := s.StartUniversalTranscode(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/butler"]["delete"]
update:
x-codeSamples:
- lang: go
label: stopAllTasks
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.StopAllTasks(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"]
update:
x-codeSamples:
- lang: go
label: refreshLibrary
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sectionID float64 = 934.16\n \n ctx := context.Background()\n res, err := s.RefreshLibrary(ctx, sectionID)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists"]["get"]
update:
x-codeSamples:
- lang: go
label: getPlaylists
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistType *operations.PlaylistType = operations.PlaylistTypeAudio.ToPointer()\n\n var smart *operations.QueryParamSmart = operations.QueryParamSmartZero.ToPointer()\n \n ctx := context.Background()\n res, err := s.GetPlaylists(ctx, playlistType, smart)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}"]["delete"]
update:
x-codeSamples:
- lang: go
label: deletePlaylist
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 216.22\n \n ctx := context.Background()\n res, err := s.DeletePlaylist(ctx, playlistID)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}/items"]["put"]
update:
x-codeSamples:
- lang: go
label: addPlaylistContents
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 8502.01\n\n var uri string = \"server://12345/com.plexapp.plugins.library/library/metadata/1\"\n\n var playQueueID *float64 = plexgo.Float64(123)\n \n ctx := context.Background()\n res, err := s.AddPlaylistContents(ctx, playlistID, uri, playQueueID)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/butler/{taskName}"]["delete"]
update:
x-codeSamples:
- lang: go
label: stopTask
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var taskName operations.PathParamTaskName = operations.PathParamTaskNameBackupDatabase\n \n ctx := context.Background()\n res, err := s.StopTask(ctx, taskName)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/hashes"]["get"]
update:
x-codeSamples:
- lang: go
label: getFileHash
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var url_ string = \"file://C:\\Image.png&type=13\"\n\n var type_ *float64 = plexgo.Float64(4462.17)\n \n ctx := context.Background()\n res, err := s.GetFileHash(ctx, url_, type_)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/transcode/sessions"]["get"]
update:
x-codeSamples:
- lang: go
label: getTranscodeSessions
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetTranscodeSessions(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/hubs"]["get"]
update:
x-codeSamples:
- lang: go
label: getGlobalHubs
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var count *float64 = plexgo.Float64(1262.49)\n\n var onlyTransient *operations.OnlyTransient = operations.OnlyTransientOne.ToPointer()\n \n ctx := context.Background()\n res, err := s.GetGlobalHubs(ctx, count, onlyTransient)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/sections/{sectionId}"]["delete"]
update:
x-codeSamples:
- lang: go
label: deleteLibrary
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sectionID float64 = 1000\n \n ctx := context.Background()\n res, err := s.DeleteLibrary(ctx, sectionID)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists"]["post"]
update:
x-codeSamples:
- lang: go
label: createPlaylist
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n request := operations.CreatePlaylistRequest{\n Title: \"<value>\",\n Type: operations.QueryParamTypePhoto,\n Smart: operations.SmartOne,\n URI: \"https://inborn-brochure.biz\",\n }\n \n ctx := context.Background()\n res, err := s.CreatePlaylist(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/:/prefs"]["get"]
update:
x-codeSamples:
- lang: go
label: getServerPreferences
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetServerPreferences(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/butler/{taskName}"]["post"]
update:
x-codeSamples:
- lang: go
label: startTask
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var taskName operations.TaskName = operations.TaskNameCleanOldBundles\n \n ctx := context.Background()\n res, err := s.StartTask(ctx, taskName)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/log"]["get"]
update:
x-codeSamples:
- lang: go
label: logLine
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var level operations.Level = operations.LevelThree\n\n var message string = \"Test log message\"\n\n var source string = \"Postman\"\n \n ctx := context.Background()\n res, err := s.LogLine(ctx, level, message, source)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/:/timeline"]["get"]
update:
x-codeSamples:
- lang: go
label: getTimeline
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n request := operations.GetTimelineRequest{\n RatingKey: 23409,\n Key: \"/library/metadata/23409\",\n State: operations.StatePlaying,\n HasMDE: 1,\n Time: 2000,\n Duration: 10000,\n Context: \"home:hub.continueWatching\",\n PlayQueueItemID: 1,\n PlayBackTime: 2000,\n Row: 1,\n }\n \n ctx := context.Background()\n res, err := s.GetTimeline(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/butler"]["post"]
update:
x-codeSamples:
- lang: go
label: startAllTasks
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.StartAllTasks(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/hubs/search/voice"]["get"]
update:
x-codeSamples:
- lang: go
label: performVoiceSearch
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var query string = \"dead+poop\"\n\n var sectionID *float64 = plexgo.Float64(4094.8)\n\n var limit *float64 = plexgo.Float64(5)\n \n ctx := context.Background()\n res, err := s.PerformVoiceSearch(ctx, query, sectionID, limit)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/sections/{sectionId}/search"]["get"]
update:
x-codeSamples:
- lang: go
label: searchLibrary
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sectionID int64 = 933505\n\n var type_ operations.Type = operations.TypeFour\n \n ctx := context.Background()\n res, err := s.SearchLibrary(ctx, sectionID, type_)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/status/sessions"]["get"]
update:
x-codeSamples:
- lang: go
label: getSessions
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetSessions(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/updater/apply"]["put"]
update:
x-codeSamples:
- lang: go
label: applyUpdates
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var tonight *operations.Tonight = operations.TonightOne.ToPointer()\n\n var skip *operations.Skip = operations.SkipOne.ToPointer()\n \n ctx := context.Background()\n res, err := s.ApplyUpdates(ctx, tonight, skip)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/clients"]["get"]
update:
x-codeSamples:
- lang: go
label: getAvailableClients
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetAvailableClients(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/:/progress"]["post"]
update:
x-codeSamples:
- lang: go
label: updatePlayProgress
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var key string = \"<value>\"\n\n var time float64 = 90000\n\n var state string = \"played\"\n \n ctx := context.Background()\n res, err := s.UpdatePlayProgress(ctx, key, time, state)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/hubs/sections/{sectionId}"]["get"]
update:
x-codeSamples:
- lang: go
label: getLibraryHubs
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sectionID float64 = 6728.76\n\n var count *float64 = plexgo.Float64(9010.22)\n\n var onlyTransient *operations.QueryParamOnlyTransient = operations.QueryParamOnlyTransientZero.ToPointer()\n \n ctx := context.Background()\n res, err := s.GetLibraryHubs(ctx, sectionID, count, onlyTransient)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/security/resources"]["get"]
update:
x-codeSamples:
- lang: go
label: getSourceConnectionInformation
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var source string = \"server://client-identifier\"\n \n ctx := context.Background()\n res, err := s.GetSourceConnectionInformation(ctx, source)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/updater/status"]["get"]
update:
x-codeSamples:
- lang: go
label: getUpdateStatus
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetUpdateStatus(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/servers"]["get"]
update:
x-codeSamples:
- lang: go
label: getServerList
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetServerList(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/activities/{activityUUID}"]["delete"]
update:
x-codeSamples:
- lang: go
label: cancelServerActivities
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var activityUUID string = \"25b71ed5-0f9d-461c-baa7-d404e9e10d3e\"\n \n ctx := context.Background()\n res, err := s.CancelServerActivities(ctx, activityUUID)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/log/networked"]["get"]
update:
x-codeSamples:
- lang: go
label: enablePaperTrail
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.EnablePaperTrail(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}/items"]["get"]
update:
x-codeSamples:
- lang: go
label: getPlaylistContents
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 5004.46\n\n var type_ float64 = 9403.59\n \n ctx := context.Background()\n res, err := s.GetPlaylistContents(ctx, playlistID, type_)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/upload"]["post"]
update:
x-codeSamples:
- lang: go
label: uploadPlaylist
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var path string = \"/home/barkley/playlist.m3u\"\n\n var force operations.Force = operations.ForceZero\n \n ctx := context.Background()\n res, err := s.UploadPlaylist(ctx, path, force)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/statistics/media"]["get"]
update:
x-codeSamples:
- lang: go
label: getStatistics
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var timespan *int64 = plexgo.Int64(4)\n \n ctx := context.Background()\n res, err := s.GetStatistics(ctx, timespan)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/butler"]["get"]
update:
x-codeSamples:
- lang: go
label: getButlerTasks
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetButlerTasks(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/security/token"]["get"]
update:
x-codeSamples:
- lang: go
label: getTransientToken
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var type_ operations.GetTransientTokenQueryParamType = operations.GetTransientTokenQueryParamTypeDelegation\n\n var scope operations.Scope = operations.ScopeAll\n \n ctx := context.Background()\n res, err := s.GetTransientToken(ctx, type_, scope)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/status/sessions/history/all"]["get"]
update:
x-codeSamples:
- lang: go
label: getSessionHistory
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetSessionHistory(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/"]["get"]
update:
x-codeSamples:
- lang: go
label: getServerCapabilities
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetServerCapabilities(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/photo/:/transcode"]["get"]
update:
x-codeSamples:
- lang: go
label: getResizedPhoto
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n request := operations.GetResizedPhotoRequest{\n Width: 110,\n Height: 165,\n Opacity: 100,\n Blur: 20,\n MinSize: operations.MinSizeOne,\n Upscale: operations.UpscaleZero,\n URL: \"/library/metadata/49564/thumb/1654258204\",\n }\n \n ctx := context.Background()\n res, err := s.GetResizedPhoto(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/:/unscrobble"]["get"]
update:
x-codeSamples:
- lang: go
label: markUnplayed
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var key float64 = 59398\n \n ctx := context.Background()\n res, err := s.MarkUnplayed(ctx, key)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/sections/{sectionId}"]["get"]
update:
x-codeSamples:
- lang: go
label: getLibrary
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sectionID float64 = 1000\n\n var includeDetails *operations.IncludeDetails = operations.IncludeDetailsZero.ToPointer()\n \n ctx := context.Background()\n res, err := s.GetLibrary(ctx, sectionID, includeDetails)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/library/onDeck"]["get"]
update:
x-codeSamples:
- lang: go
label: getOnDeck
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.GetOnDeck(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/playlists/{playlistID}"]["get"]
update:
x-codeSamples:
- lang: go
label: getPlaylist
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var playlistID float64 = 4109.48\n \n ctx := context.Background()\n res, err := s.GetPlaylist(ctx, playlistID)\n if err != nil {\n log.Fatal(err)\n }\n if res.Object != nil {\n // handle response\n }\n}"
- target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"]
update:
x-codeSamples:
- lang: go
label: stopTranscodeSession
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var sessionKey string = \"zz7llzqlx8w9vnrsbnwhbmep\"\n \n ctx := context.Background()\n res, err := s.StopTranscodeSession(ctx, sessionKey)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"
- target: $["paths"]["/updater/check"]["put"]
update:
x-codeSamples:
- lang: go
label: checkForUpdates
source: "package main\n\nimport(\n\t\"github.com/LukeHagar/plexgo/models/components\"\n\t\"github.com/LukeHagar/plexgo\"\n\t\"github.com/LukeHagar/plexgo/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := plexgo.New(\n plexgo.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n plexgo.WithXPlexClientIdentifier(\"Postman\"),\n )\n\n var download *operations.Download = operations.DownloadOne.ToPointer()\n \n ctx := context.Background()\n res, err := s.CheckForUpdates(ctx, download)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}"

View File

@@ -3,7 +3,7 @@
## Fields
| Field | Type | Required | Description |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Tonight` | [*operations.Tonight](../../models/operations/tonight.md) | :heavy_minus_sign: | Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install |
| `Skip` | [*operations.Skip](../../models/operations/skip.md) | :heavy_minus_sign: | Indicate that the latest version should be marked as skipped. The <Release> entry for this version will have the `state` set to `skipped`. |
| Field | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Tonight` | [*operations.Tonight](../../models/operations/tonight.md) | :heavy_minus_sign: | Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install | 1 |
| `Skip` | [*operations.Skip](../../models/operations/skip.md) | :heavy_minus_sign: | Indicate that the latest version should be marked as skipped. The <Release> entry for this version will have the `state` set to `skipped`. | 1 |

View File

@@ -3,6 +3,6 @@
## Fields
| Field | Type | Required | Description |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| `ActivityUUID` | *string* | :heavy_check_mark: | The UUID of the activity to cancel. |
| Field | Type | Required | Description | Example |
| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ |
| `ActivityUUID` | *string* | :heavy_check_mark: | The UUID of the activity to cancel. | 25b71ed5-0f9d-461c-baa7-d404e9e10d3e |

View File

@@ -3,6 +3,6 @@
## Fields
| Field | Type | Required | Description |
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| `Download` | [*operations.Download](../../models/operations/download.md) | :heavy_minus_sign: | Indicate that you want to start download any updates found. |
| Field | Type | Required | Description | Example |
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| `Download` | [*operations.Download](../../models/operations/download.md) | :heavy_minus_sign: | Indicate that you want to start download any updates found. | 1 |

View File

@@ -1,8 +0,0 @@
# GetLibraryItemsCountry
## Fields
| Field | Type | Required | Description | Example |
| ------------------------ | ------------------------ | ------------------------ | ------------------------ | ------------------------ |
| `Tag` | **string* | :heavy_minus_sign: | N/A | United States of America |

View File

@@ -1,8 +0,0 @@
# GetLibraryItemsDirector
## Fields
| Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| `Tag` | **string* | :heavy_minus_sign: | N/A | James Cameron |

View File

@@ -1,8 +0,0 @@
# GetLibraryItemsGenre
## Fields
| Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| `Tag` | **string* | :heavy_minus_sign: | N/A | Adventure |

View File

@@ -1,21 +0,0 @@
# GetLibraryItemsMedia
## Fields
| Field | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ID` | **int* | :heavy_minus_sign: | N/A | 119534 |
| `Duration` | **int* | :heavy_minus_sign: | N/A | 11558112 |
| `Bitrate` | **int* | :heavy_minus_sign: | N/A | 25025 |
| `Width` | **int* | :heavy_minus_sign: | N/A | 3840 |
| `Height` | **int* | :heavy_minus_sign: | N/A | 2072 |
| `AspectRatio` | **float64* | :heavy_minus_sign: | N/A | 1.85 |
| `AudioChannels` | **int* | :heavy_minus_sign: | N/A | 6 |
| `AudioCodec` | **string* | :heavy_minus_sign: | N/A | eac3 |
| `VideoCodec` | **string* | :heavy_minus_sign: | N/A | hevc |
| `VideoResolution` | **string* | :heavy_minus_sign: | N/A | 4k |
| `Container` | **string* | :heavy_minus_sign: | N/A | mkv |
| `VideoFrameRate` | **string* | :heavy_minus_sign: | N/A | 24p |
| `VideoProfile` | **string* | :heavy_minus_sign: | N/A | main 10 |
| `Part` | [][operations.GetLibraryItemsPart](../../models/operations/getlibraryitemspart.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"id": 119542,<br/>"key": "/library/parts/119542/1680457526/file.mkv",<br/>"duration": 11558112,<br/>"file": "/movies/Avatar The Way of Water (2022)/Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG.mkv",<br/>"size": 36158371307,<br/>"container": "mkv",<br/>"videoProfile": "main 10"<br/>}<br/>] |

File diff suppressed because one or more lines are too long

View File

@@ -1,64 +0,0 @@
# GetLibraryItemsMetadata
## Fields
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `RatingKey` | **string* | :heavy_minus_sign: | N/A | 58683 |
| `Key` | **string* | :heavy_minus_sign: | N/A | /library/metadata/58683 |
| `GUID` | **string* | :heavy_minus_sign: | N/A | plex://movie/5d7768ba96b655001fdc0408 |
| `Studio` | **string* | :heavy_minus_sign: | N/A | 20th Century Studios |
| `Type` | **string* | :heavy_minus_sign: | N/A | movie |
| `Title` | **string* | :heavy_minus_sign: | N/A | Avatar: The Way of Water |
| `ContentRating` | **string* | :heavy_minus_sign: | N/A | PG-13 |
| `Summary` | **string* | :heavy_minus_sign: | N/A | Jake Sully lives with his newfound family formed on the extrasolar moon Pandora. Once a familiar threat returns to finish what was previously started, Jake must work with Neytiri and the army of the Na'vi race to protect their home. |
| `Rating` | **float64* | :heavy_minus_sign: | N/A | 7.6 |
| `AudienceRating` | **float64* | :heavy_minus_sign: | N/A | 9.2 |
| `Year` | **int* | :heavy_minus_sign: | N/A | 2022 |
| `Tagline` | **string* | :heavy_minus_sign: | N/A | Return to Pandora. |
| `Thumb` | **string* | :heavy_minus_sign: | N/A | /library/metadata/58683/thumb/1703239236 |
| `Art` | **string* | :heavy_minus_sign: | N/A | /library/metadata/58683/art/1703239236 |
| `Duration` | **int* | :heavy_minus_sign: | N/A | 11558112 |
| `OriginallyAvailableAt` | [*types.Date](../../types/date.md) | :heavy_minus_sign: | N/A | 2022-12-14 00:00:00 +0000 UTC |
| `AddedAt` | **int* | :heavy_minus_sign: | N/A | 1680457607 |
| `UpdatedAt` | **int* | :heavy_minus_sign: | N/A | 1703239236 |
| `AudienceRatingImage` | **string* | :heavy_minus_sign: | N/A | rottentomatoes://image.rating.upright |
| `ChapterSource` | **string* | :heavy_minus_sign: | N/A | media |
| `PrimaryExtraKey` | **string* | :heavy_minus_sign: | N/A | /library/metadata/58684 |
| `RatingImage` | **string* | :heavy_minus_sign: | N/A | rottentomatoes://image.rating.ripe |
| `GrandparentRatingKey` | **string* | :heavy_minus_sign: | N/A | 66 |
| `GrandparentGUID` | **string* | :heavy_minus_sign: | N/A | plex://show/5d9c081b170e24001f2a7be4 |
| `GrandparentKey` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66 |
| `GrandparentTitle` | **string* | :heavy_minus_sign: | N/A | Caprica |
| `GrandparentThumb` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66/thumb/1705716261 |
| `GrandparentArt` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66/art/1705716261 |
| `GrandparentTheme` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66/theme/1705716261 |
| `Media` | [][operations.GetLibraryItemsMedia](../../models/operations/getlibraryitemsmedia.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"id": 119534,<br/>"duration": 11558112,<br/>"bitrate": 25025,<br/>"width": 3840,<br/>"height": 2072,<br/>"aspectRatio": 1.85,<br/>"audioChannels": 6,<br/>"audioCodec": "eac3",<br/>"videoCodec": "hevc",<br/>"videoResolution": "4k",<br/>"container": "mkv",<br/>"videoFrameRate": "24p",<br/>"videoProfile": "main 10",<br/>"Part": [<br/>{<br/>"id": 119542,<br/>"key": "/library/parts/119542/1680457526/file.mkv",<br/>"duration": 11558112,<br/>"file": "/movies/Avatar The Way of Water (2022)/Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG.mkv",<br/>"size": 36158371307,<br/>"container": "mkv",<br/>"videoProfile": "main 10"<br/>}<br/>]<br/>}<br/>] |
| `Genre` | [][operations.GetLibraryItemsGenre](../../models/operations/getlibraryitemsgenre.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"tag": "Adventure"<br/>}<br/>] |
| `Country` | [][operations.GetLibraryItemsCountry](../../models/operations/getlibraryitemscountry.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"tag": "United States of America"<br/>}<br/>] |
| `Director` | [][operations.GetLibraryItemsDirector](../../models/operations/getlibraryitemsdirector.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"tag": "James Cameron"<br/>}<br/>] |
| `Writer` | [][operations.GetLibraryItemsWriter](../../models/operations/getlibraryitemswriter.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"tag": "James Cameron"<br/>}<br/>] |
| `Role` | [][operations.GetLibraryItemsRole](../../models/operations/getlibraryitemsrole.md) | :heavy_minus_sign: | N/A | [<br/>{<br/>"tag": "Sigourney Weaver"<br/>}<br/>] |
| `TitleSort` | **string* | :heavy_minus_sign: | N/A | Whale |
| `ViewCount` | **int* | :heavy_minus_sign: | N/A | 1 |
| `LastViewedAt` | **int* | :heavy_minus_sign: | N/A | 1682752242 |
| `OriginalTitle` | **string* | :heavy_minus_sign: | N/A | 映画 ブラッククローバー 魔法帝の剣 |
| `ViewOffset` | **int* | :heavy_minus_sign: | N/A | 5222500 |
| `SkipCount` | **int* | :heavy_minus_sign: | N/A | 1 |
| `Index` | **int* | :heavy_minus_sign: | N/A | 1 |
| `Theme` | **string* | :heavy_minus_sign: | N/A | /library/metadata/1/theme/1705636920 |
| `LeafCount` | **int* | :heavy_minus_sign: | N/A | 14 |
| `ViewedLeafCount` | **int* | :heavy_minus_sign: | N/A | 0 |
| `ChildCount` | **int* | :heavy_minus_sign: | N/A | 1 |
| `HasPremiumExtras` | **string* | :heavy_minus_sign: | N/A | 1 |
| `HasPremiumPrimaryExtra` | **string* | :heavy_minus_sign: | N/A | 1 |
| `ParentRatingKey` | **string* | :heavy_minus_sign: | N/A | 66 |
| `ParentGUID` | **string* | :heavy_minus_sign: | N/A | plex://show/5d9c081b170e24001f2a7be4 |
| `ParentStudio` | **string* | :heavy_minus_sign: | N/A | UCP |
| `ParentKey` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66 |
| `ParentTitle` | **string* | :heavy_minus_sign: | N/A | Caprica |
| `ParentIndex` | **int* | :heavy_minus_sign: | N/A | 1 |
| `ParentYear` | **int* | :heavy_minus_sign: | N/A | 2010 |
| `ParentThumb` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66/thumb/1705716261 |
| `ParentTheme` | **string* | :heavy_minus_sign: | N/A | /library/metadata/66/theme/1705716261 |

View File

@@ -1,14 +0,0 @@
# GetLibraryItemsPart
## Fields
| Field | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `ID` | **int* | :heavy_minus_sign: | N/A | 119542 |
| `Key` | **string* | :heavy_minus_sign: | N/A | /library/parts/119542/1680457526/file.mkv |
| `Duration` | **int* | :heavy_minus_sign: | N/A | 11558112 |
| `File` | **string* | :heavy_minus_sign: | N/A | /movies/Avatar The Way of Water (2022)/Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG.mkv |
| `Size` | **int64* | :heavy_minus_sign: | N/A | 36158371307 |
| `Container` | **string* | :heavy_minus_sign: | N/A | mkv |
| `VideoProfile` | **string* | :heavy_minus_sign: | N/A | main 10 |

View File

@@ -1,9 +0,0 @@
# GetLibraryItemsRequest
## Fields
| Field | Type | Required | Description |
| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
| `SectionID` | *int64* | :heavy_check_mark: | the Id of the library to query |
| `Tag` | [operations.Tag](../../models/operations/tag.md) | :heavy_check_mark: | A key representing a specific tag within the section. |

View File

@@ -1,11 +0,0 @@
# GetLibraryItemsResponse
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation |
| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation |
| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |
| `Object` | [*operations.GetLibraryItemsResponseBody](../../models/operations/getlibraryitemsresponsebody.md) | :heavy_minus_sign: | The contents of the library by section and tag |

View File

@@ -1,10 +0,0 @@
# GetLibraryItemsResponseBody
The contents of the library by section and tag
## Fields
| Field | Type | Required | Description |
| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `MediaContainer` | [*operations.GetLibraryItemsMediaContainer](../../models/operations/getlibraryitemsmediacontainer.md) | :heavy_minus_sign: | N/A |

View File

@@ -1,8 +0,0 @@
# GetLibraryItemsRole
## Fields
| Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| `Tag` | **string* | :heavy_minus_sign: | N/A | Sigourney Weaver |

View File

@@ -1,8 +0,0 @@
# GetLibraryItemsWriter
## Fields
| Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| `Tag` | **string* | :heavy_minus_sign: | N/A | James Cameron |

View File

@@ -0,0 +1,8 @@
# GetPinGlobals
## Fields
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |

View File

@@ -3,7 +3,7 @@
## Fields
| Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | |
| `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |

View File

@@ -3,6 +3,6 @@
## Fields
| Field | Type | Required | Description |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `Timespan` | **int64* | :heavy_minus_sign: | The timespan to retrieve statistics for<br/>the exact meaning of this parameter is not known<br/> |
| Field | Type | Required | Description | Example |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `Timespan` | **int64* | :heavy_minus_sign: | The timespan to retrieve statistics for<br/>the exact meaning of this parameter is not known<br/> | 4 |

View File

@@ -3,15 +3,15 @@
## Fields
| Field | Type | Required | Description |
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
| `RatingKey` | *float64* | :heavy_check_mark: | The rating key of the media item |
| `Key` | *string* | :heavy_check_mark: | The key of the media item to get the timeline for |
| `State` | [operations.State](../../models/operations/state.md) | :heavy_check_mark: | The state of the media item |
| `HasMDE` | *float64* | :heavy_check_mark: | Whether the media item has MDE |
| `Time` | *float64* | :heavy_check_mark: | The time of the media item |
| `Duration` | *float64* | :heavy_check_mark: | The duration of the media item |
| `Context` | *string* | :heavy_check_mark: | The context of the media item |
| `PlayQueueItemID` | *float64* | :heavy_check_mark: | The play queue item ID of the media item |
| `PlayBackTime` | *float64* | :heavy_check_mark: | The playback time of the media item |
| `Row` | *float64* | :heavy_check_mark: | The row of the media item |
| Field | Type | Required | Description | Example |
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
| `RatingKey` | *float64* | :heavy_check_mark: | The rating key of the media item | 23409 |
| `Key` | *string* | :heavy_check_mark: | The key of the media item to get the timeline for | /library/metadata/23409 |
| `State` | [operations.State](../../models/operations/state.md) | :heavy_check_mark: | The state of the media item | playing |
| `HasMDE` | *float64* | :heavy_check_mark: | Whether the media item has MDE | 1 |
| `Time` | *float64* | :heavy_check_mark: | The time of the media item | 2000 |
| `Duration` | *float64* | :heavy_check_mark: | The duration of the media item | 10000 |
| `Context` | *string* | :heavy_check_mark: | The context of the media item | home:hub.continueWatching |
| `PlayQueueItemID` | *float64* | :heavy_check_mark: | The play queue item ID of the media item | 1 |
| `PlayBackTime` | *float64* | :heavy_check_mark: | The playback time of the media item | 2000 |
| `Row` | *float64* | :heavy_check_mark: | The row of the media item | 1 |

View File

@@ -0,0 +1,8 @@
# GetTokenGlobals
## Fields
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |

View File

@@ -3,7 +3,7 @@
## Fields
| Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | |
| `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |

View File

@@ -3,21 +3,21 @@
## Fields
| Field | Type | Required | Description |
| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
| `HasMDE` | *float64* | :heavy_check_mark: | Whether the media item has MDE |
| `Path` | *string* | :heavy_check_mark: | The path to the media item to transcode |
| `MediaIndex` | *float64* | :heavy_check_mark: | The index of the media item to transcode |
| `PartIndex` | *float64* | :heavy_check_mark: | The index of the part to transcode |
| `Protocol` | *string* | :heavy_check_mark: | The protocol to use for the transcode session |
| `FastSeek` | **float64* | :heavy_minus_sign: | Whether to use fast seek or not |
| `DirectPlay` | **float64* | :heavy_minus_sign: | Whether to use direct play or not |
| `DirectStream` | **float64* | :heavy_minus_sign: | Whether to use direct stream or not |
| `SubtitleSize` | **float64* | :heavy_minus_sign: | The size of the subtitles |
| `Subtites` | **string* | :heavy_minus_sign: | The subtitles |
| `AudioBoost` | **float64* | :heavy_minus_sign: | The audio boost |
| `Location` | **string* | :heavy_minus_sign: | The location of the transcode session |
| `MediaBufferSize` | **float64* | :heavy_minus_sign: | The size of the media buffer |
| `Session` | **string* | :heavy_minus_sign: | The session ID |
| `AddDebugOverlay` | **float64* | :heavy_minus_sign: | Whether to add a debug overlay or not |
| `AutoAdjustQuality` | **float64* | :heavy_minus_sign: | Whether to auto adjust quality or not |
| Field | Type | Required | Description | Example |
| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
| `HasMDE` | *float64* | :heavy_check_mark: | Whether the media item has MDE | 1 |
| `Path` | *string* | :heavy_check_mark: | The path to the media item to transcode | /library/metadata/23409 |
| `MediaIndex` | *float64* | :heavy_check_mark: | The index of the media item to transcode | 0 |
| `PartIndex` | *float64* | :heavy_check_mark: | The index of the part to transcode | 0 |
| `Protocol` | *string* | :heavy_check_mark: | The protocol to use for the transcode session | hls |
| `FastSeek` | **float64* | :heavy_minus_sign: | Whether to use fast seek or not | 0 |
| `DirectPlay` | **float64* | :heavy_minus_sign: | Whether to use direct play or not | 0 |
| `DirectStream` | **float64* | :heavy_minus_sign: | Whether to use direct stream or not | 0 |
| `SubtitleSize` | **float64* | :heavy_minus_sign: | The size of the subtitles | 100 |
| `Subtites` | **string* | :heavy_minus_sign: | The subtitles | burn |
| `AudioBoost` | **float64* | :heavy_minus_sign: | The audio boost | 100 |
| `Location` | **string* | :heavy_minus_sign: | The location of the transcode session | lan |
| `MediaBufferSize` | **float64* | :heavy_minus_sign: | The size of the media buffer | 102400 |
| `Session` | **string* | :heavy_minus_sign: | The session ID | zvcage8b7rkioqcm8f4uns4c |
| `AddDebugOverlay` | **float64* | :heavy_minus_sign: | Whether to add a debug overlay or not | 0 |
| `AutoAdjustQuality` | **float64* | :heavy_minus_sign: | Whether to auto adjust quality or not | 0 |

View File

@@ -1,28 +0,0 @@
# Tag
A key representing a specific tag within the section.
## Values
| Name | Value |
| ------------------- | ------------------- |
| `TagAll` | all |
| `TagUnwatched` | unwatched |
| `TagNewest` | newest |
| `TagRecentlyAdded` | recentlyAdded |
| `TagRecentlyViewed` | recentlyViewed |
| `TagOnDeck` | onDeck |
| `TagCollection` | collection |
| `TagEdition` | edition |
| `TagGenre` | genre |
| `TagYear` | year |
| `TagDecade` | decade |
| `TagDirector` | director |
| `TagActor` | actor |
| `TagCountry` | country |
| `TagContentRating` | contentRating |
| `TagRating` | rating |
| `TagResolution` | resolution |
| `TagFirstCharacter` | firstCharacter |
| `TagFolder` | folder |

View File

@@ -3,8 +3,8 @@
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `Key` | *string* | :heavy_check_mark: | the media key |
| `Time` | *float64* | :heavy_check_mark: | The time, in milliseconds, used to set the media playback progress. |
| `State` | *string* | :heavy_check_mark: | The playback state of the media item. |
| Field | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `Key` | *string* | :heavy_check_mark: | the media key | |
| `Time` | *float64* | :heavy_check_mark: | The time, in milliseconds, used to set the media playback progress. | 90000 |
| `State` | *string* | :heavy_check_mark: | The playback state of the media item. | played |

View File

@@ -36,14 +36,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Activities.GetServerActivities(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -79,24 +81,22 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var activityUUID string = "<value>"
var activityUUID string = "25b71ed5-0f9d-461c-baa7-d404e9e10d3e"
ctx := context.Background()
res, err := s.Activities.CancelServerActivities(ctx, activityUUID)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -104,10 +104,10 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `activityUUID` | *string* | :heavy_check_mark: | The UUID of the activity to cancel. |
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `activityUUID` | *string* | :heavy_check_mark: | The UUID of the activity to cancel. | 25b71ed5-0f9d-461c-baa7-d404e9e10d3e |
### Response

View File

@@ -27,15 +27,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var type_ operations.GetTransientTokenQueryParamType = operations.GetTransientTokenQueryParamTypeDelegation
var scope operations.Scope = operations.ScopeAll
@@ -45,8 +44,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -85,15 +83,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var source string = "server://client-identifier"
ctx := context.Background()
@@ -101,8 +98,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

View File

@@ -33,14 +33,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Butler.GetButlerTasks(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -81,21 +83,22 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Butler.StartAllTasks(ctx)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -131,21 +134,22 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Butler.StopAllTasks(ctx)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -186,15 +190,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var taskName operations.TaskName = operations.TaskNameCleanOldBundles
ctx := context.Background()
@@ -202,8 +205,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -241,15 +243,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var taskName operations.PathParamTaskName = operations.PathParamTaskNameBackupDatabase
ctx := context.Background()
@@ -257,8 +258,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

View File

@@ -31,9 +31,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var count *float64 = plexgo.Float64(1262.49)
var onlyTransient *operations.OnlyTransient = operations.OnlyTransientOne.ToPointer()
@@ -43,7 +43,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -88,9 +87,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sectionID float64 = 6728.76
var count *float64 = plexgo.Float64(9010.22)
@@ -102,7 +101,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}

View File

@@ -13,7 +13,6 @@ API Calls interacting with Plex Media Server Libraries
* [GetLibraries](#getlibraries) - Get All Libraries
* [GetLibrary](#getlibrary) - Get Library Details
* [DeleteLibrary](#deletelibrary) - Delete Library Section
* [GetLibraryItems](#getlibraryitems) - Get Library Items
* [RefreshLibrary](#refreshlibrary) - Refresh Library
* [SearchLibrary](#searchlibrary) - Search Library
* [GetMetadata](#getmetadata) - Get Items Metadata
@@ -34,15 +33,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var url_ string = "file://C:\Image.png&type=13"
var type_ *float64 = plexgo.Float64(4462.17)
@@ -52,8 +50,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -96,14 +93,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Library.GetRecentlyAdded(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -150,14 +149,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Library.GetLibraries(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -238,9 +239,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sectionID float64 = 1000
var includeDetails *operations.IncludeDetails = operations.IncludeDetailsZero.ToPointer()
@@ -250,7 +251,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -288,15 +288,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sectionID float64 = 1000
ctx := context.Background()
@@ -304,8 +303,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -327,81 +325,6 @@ func main() {
| sdkerrors.DeleteLibraryResponseBody | 401 | application/json |
| sdkerrors.SDKError | 4xx-5xx | */* |
## GetLibraryItems
Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
- `all`: All items in the section.
- `unwatched`: Items that have not been played.
- `newest`: Items that are recently released.
- `recentlyAdded`: Items that are recently added to the library.
- `recentlyViewed`: Items that were recently viewed.
- `onDeck`: Items to continue watching.
- `collection`: Items categorized by collection.
- `edition`: Items categorized by edition.
- `genre`: Items categorized by genre.
- `year`: Items categorized by year of release.
- `decade`: Items categorized by decade.
- `director`: Items categorized by director.
- `actor`: Items categorized by starring actor.
- `country`: Items categorized by country of origin.
- `contentRating`: Items categorized by content rating.
- `rating`: Items categorized by rating.
- `resolution`: Items categorized by resolution.
- `firstCharacter`: Items categorized by the first letter.
- `folder`: Items categorized by folder.
### Example Usage
```go
package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var sectionID int64 = 451092
var tag operations.Tag = operations.TagUnwatched
ctx := context.Background()
res, err := s.Library.GetLibraryItems(ctx, sectionID, tag)
if err != nil {
log.Fatal(err)
}
if res.Object != 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. |
| `sectionID` | *int64* | :heavy_check_mark: | the Id of the library to query |
| `tag` | [operations.Tag](../../models/operations/tag.md) | :heavy_check_mark: | A key representing a specific tag within the section. |
### Response
**[*operations.GetLibraryItemsResponse](../../models/operations/getlibraryitemsresponse.md), error**
| Error Object | Status Code | Content Type |
| ------------------ | ------------------ | ------------------ |
| sdkerrors.SDKError | 4xx-5xx | */* |
## RefreshLibrary
This endpoint Refreshes the library.
@@ -417,15 +340,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sectionID float64 = 934.16
ctx := context.Background()
@@ -433,8 +355,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -494,9 +415,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sectionID int64 = 933505
var type_ operations.Type = operations.TypeFour
@@ -506,7 +427,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -549,9 +469,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var ratingKey float64 = 8382.31
ctx := context.Background()
@@ -559,7 +479,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -602,9 +521,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var ratingKey float64 = 1539.14
ctx := context.Background()
@@ -612,7 +531,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -655,14 +573,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Library.GetOnDeck(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}

View File

@@ -28,15 +28,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var level operations.Level = operations.LevelThree
var message string = "Test log message"
@@ -48,8 +47,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -108,23 +106,24 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Log.LogMultiLine(ctx, "level=4&message=Test%20message%201&source=postman
var request string = "level=4&message=Test%20message%201&source=postman
level=3&message=Test%20message%202&source=postman
level=1&message=Test%20message%203&source=postman")
level=1&message=Test%20message%203&source=postman"
ctx := context.Background()
res, err := s.Log.LogMultiLine(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -161,21 +160,22 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Log.EnablePaperTrail(ctx)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

View File

@@ -26,15 +26,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var key float64 = 59398
ctx := context.Background()
@@ -42,8 +41,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -79,15 +77,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var key float64 = 59398
ctx := context.Background()
@@ -95,8 +92,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -133,28 +129,26 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var key string = "<value>"
var time float64 = 6900.91
var time float64 = 90000
var state string = "<value>"
var state string = "played"
ctx := context.Background()
res, err := s.Media.UpdatePlayProgress(ctx, key, time, state)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -162,12 +156,12 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `key` | *string* | :heavy_check_mark: | the media key |
| `time` | *float64* | :heavy_check_mark: | The time, in milliseconds, used to set the media playback progress. |
| `state` | *string* | :heavy_check_mark: | The playback state of the media item. |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `key` | *string* | :heavy_check_mark: | the media key | |
| `time` | *float64* | :heavy_check_mark: | The time, in milliseconds, used to set the media playback progress. | 90000 |
| `state` | *string* | :heavy_check_mark: | The playback state of the media item. | played |
### Response

View File

@@ -36,27 +36,29 @@ package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Playlists.CreatePlaylist(ctx, operations.CreatePlaylistRequest{
request := operations.CreatePlaylistRequest{
Title: "<value>",
Type: operations.QueryParamTypePhoto,
Smart: operations.SmartOne,
URI: "https://inborn-brochure.biz",
})
}
ctx := context.Background()
res, err := s.Playlists.CreatePlaylist(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -99,9 +101,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistType *operations.PlaylistType = operations.PlaylistTypeAudio.ToPointer()
var smart *operations.QueryParamSmart = operations.QueryParamSmartZero.ToPointer()
@@ -111,7 +113,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -156,9 +157,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 4109.48
ctx := context.Background()
@@ -166,7 +167,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -204,15 +204,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 216.22
ctx := context.Background()
@@ -220,8 +219,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -258,15 +256,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 3915
var title *string = plexgo.String("<value>")
@@ -278,8 +275,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -326,9 +322,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 5004.46
var type_ float64 = 9403.59
@@ -338,7 +334,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -377,15 +372,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 1893.18
ctx := context.Background()
@@ -393,8 +387,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -437,9 +430,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var playlistID float64 = 8502.01
var uri string = "server://12345/com.plexapp.plugins.library/library/metadata/1"
@@ -451,7 +444,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -492,15 +484,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var path string = "/home/barkley/playlist.m3u"
var force operations.Force = operations.ForceZero
@@ -510,8 +501,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

View File

@@ -27,19 +27,19 @@ import(
)
func main() {
s := plexgo.New()
var xPlexClientIdentifier string = "<value>"
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, xPlexClientIdentifier, strong)
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -48,12 +48,12 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | |
| `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
@@ -77,24 +77,23 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New()
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("Postman"),
)
var pinID string = "<value>"
var xPlexClientIdentifier string = "<value>"
var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background()
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -102,12 +101,12 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | |
| `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | Postman |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response

View File

@@ -38,15 +38,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var query string = "dylan"
var sectionID *float64 = plexgo.Float64(1516.53)
@@ -58,8 +57,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -101,15 +99,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var query string = "dead+poop"
var sectionID *float64 = plexgo.Float64(4094.8)
@@ -121,8 +118,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -165,9 +161,9 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var query string = "110"
ctx := context.Background()
@@ -175,7 +171,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}

View File

@@ -36,14 +36,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetServerCapabilities(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -84,14 +86,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetServerPreferences(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -132,14 +136,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetAvailableClients(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -180,14 +186,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetDevices(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -228,14 +236,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetServerIdentity(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -276,14 +286,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetMyPlexAccount(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -318,32 +330,33 @@ package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetResizedPhoto(ctx, operations.GetResizedPhotoRequest{
request := operations.GetResizedPhotoRequest{
Width: 110,
Height: 165,
Opacity: 643869,
Blur: 4000,
MinSize: operations.MinSizeZero,
Opacity: 100,
Blur: 20,
MinSize: operations.MinSizeOne,
Upscale: operations.UpscaleZero,
URL: "/library/metadata/49564/thumb/1654258204",
})
}
ctx := context.Background()
res, err := s.Server.GetResizedPhoto(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -384,14 +397,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Server.GetServerList(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}

View File

@@ -32,14 +32,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Sessions.GetSessions(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -80,14 +82,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Sessions.GetSessionHistory(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -128,14 +132,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Sessions.GetTranscodeSessions(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -171,15 +177,14 @@ import(
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var sessionKey string = "zz7llzqlx8w9vnrsbnwhbmep"
ctx := context.Background()
@@ -187,8 +192,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

View File

@@ -29,17 +29,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var timespan *int64 = plexgo.Int64(411769)
var timespan *int64 = plexgo.Int64(4)
ctx := context.Background()
res, err := s.Statistics.GetStatistics(ctx, timespan)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -48,10 +47,10 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `timespan` | **int64* | :heavy_minus_sign: | The timespan to retrieve statistics for<br/>the exact meaning of this parameter is not known<br/> |
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `timespan` | **int64* | :heavy_minus_sign: | The timespan to retrieve statistics for<br/>the exact meaning of this parameter is not known<br/> | 4 |
### Response

View File

@@ -32,14 +32,16 @@ import(
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
ctx := context.Background()
res, err := s.Updater.GetUpdateStatus(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
@@ -76,15 +78,14 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var download *operations.Download = operations.DownloadOne.ToPointer()
ctx := context.Background()
@@ -92,8 +93,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -101,10 +101,10 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `download` | [*operations.Download](../../models/operations/download.md) | :heavy_minus_sign: | Indicate that you want to start download any updates found. |
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `download` | [*operations.Download](../../models/operations/download.md) | :heavy_minus_sign: | Indicate that you want to start download any updates found. | 1 |
### Response
@@ -131,26 +131,24 @@ import(
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
var tonight *operations.Tonight = operations.TonightOne.ToPointer()
var skip *operations.Skip = operations.SkipZero.ToPointer()
var skip *operations.Skip = operations.SkipOne.ToPointer()
ctx := context.Background()
res, err := s.Updater.ApplyUpdates(ctx, tonight, skip)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -158,11 +156,11 @@ func main() {
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `tonight` | [*operations.Tonight](../../models/operations/tonight.md) | :heavy_minus_sign: | Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install |
| `skip` | [*operations.Skip](../../models/operations/skip.md) | :heavy_minus_sign: | Indicate that the latest version should be marked as skipped. The <Release> entry for this version will have the `state` set to `skipped`. |
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `tonight` | [*operations.Tonight](../../models/operations/tonight.md) | :heavy_minus_sign: | Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install | 1 |
| `skip` | [*operations.Skip](../../models/operations/skip.md) | :heavy_minus_sign: | Indicate that the latest version should be marked as skipped. The <Release> entry for this version will have the `state` set to `skipped`. | 1 |
### Response

View File

@@ -23,35 +23,36 @@ package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
request := operations.GetTimelineRequest{
RatingKey: 23409,
Key: "/library/metadata/23409",
State: operations.StatePlaying,
HasMDE: 1,
Time: 2000,
Duration: 10000,
Context: "home:hub.continueWatching",
PlayQueueItemID: 1,
PlayBackTime: 2000,
Row: 1,
}
ctx := context.Background()
res, err := s.Video.GetTimeline(ctx, operations.GetTimelineRequest{
RatingKey: 716.56,
Key: "<key>",
State: operations.StatePaused,
HasMDE: 7574.33,
Time: 3327.51,
Duration: 7585.39,
Context: "<value>",
PlayQueueItemID: 1406.21,
PlayBackTime: 2699.34,
Row: 3536.42,
})
res, err := s.Video.GetTimeline(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}
@@ -85,30 +86,42 @@ package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"github.com/LukeHagar/plexgo/models/operations"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("Postman"),
)
request := operations.StartUniversalTranscodeRequest{
HasMDE: 1,
Path: "/library/metadata/23409",
MediaIndex: 0,
PartIndex: 0,
Protocol: "hls",
FastSeek: plexgo.Float64(0),
DirectPlay: plexgo.Float64(0),
DirectStream: plexgo.Float64(0),
SubtitleSize: plexgo.Float64(100),
Subtites: plexgo.String("burn"),
AudioBoost: plexgo.Float64(100),
Location: plexgo.String("lan"),
MediaBufferSize: plexgo.Float64(102400),
Session: plexgo.String("zvcage8b7rkioqcm8f4uns4c"),
AddDebugOverlay: plexgo.Float64(0),
AutoAdjustQuality: plexgo.Float64(0),
}
ctx := context.Background()
res, err := s.Video.StartUniversalTranscode(ctx, operations.StartUniversalTranscodeRequest{
HasMDE: 8924.99,
Path: "/etc/mail",
MediaIndex: 9962.95,
PartIndex: 1232.82,
Protocol: "<value>",
})
res, err := s.Video.StartUniversalTranscode(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
if res != nil {
// handle response
}
}

52
hubs.go
View File

@@ -32,6 +32,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getGlobalHubs",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -57,14 +58,16 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -75,9 +78,11 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -85,11 +90,10 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetGlobalHubsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -103,7 +107,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetGlobalHubsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -111,7 +115,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -121,17 +125,19 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetGlobalHubsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -143,6 +149,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getLibraryHubs",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -169,14 +176,16 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -187,9 +196,11 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -197,11 +208,10 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetLibraryHubsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -215,7 +225,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetLibraryHubsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -223,7 +233,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -233,17 +243,19 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetLibraryHubsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -0,0 +1,18 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package globals
type Globals struct {
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *Globals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}

View File

@@ -78,6 +78,8 @@ func New() *Hooks {
afterErrorHook: []afterErrorHook{},
}
initHooks(h)
return h
}

View File

@@ -10,14 +10,35 @@ import (
"strings"
)
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}) {
func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) {
globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{})
if globals != nil {
_ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated)
}
}
func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string {
headerParamsStructType := reflect.TypeOf(headers)
headerParamsValType := reflect.ValueOf(headers)
globalsAlreadyPopulated := []string{}
for i := 0; i < headerParamsStructType.NumField(); i++ {
fieldType := headerParamsStructType.Field(i)
valType := headerParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
if tag == nil {
continue
@@ -25,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
value := serializeHeader(fieldType.Type, valType, tag.Explode)
if value != "" {
req.Header.Add(tag.ParamName, value)
reqHeaders.Add(tag.ParamName, value)
}
}
return globalsAlreadyPopulated
}
func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {

View File

@@ -8,6 +8,7 @@ import (
"fmt"
"math/big"
"reflect"
"strconv"
"strings"
"time"
"unsafe"
@@ -260,6 +261,18 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error)
typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v))
switch typ.Kind() {
case reflect.Int64:
format := tag.Get("integer")
if format == "string" {
b := val.Interface().(int64)
return []byte(fmt.Sprintf(`"%d"`, b)), nil
}
case reflect.Float64:
format := tag.Get("number")
if format == "string" {
b := val.Interface().(float64)
return []byte(fmt.Sprintf(`"%g"`, b)), nil
}
case reflect.Map:
if isNil(typ, val) {
return []byte("null"), nil
@@ -349,6 +362,16 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc
if bigIntTag == "string" {
return []byte(fmt.Sprintf(`"%s"`, tagValue))
}
case reflect.TypeOf(int64(0)):
format := tag.Get("integer")
if format == "string" {
return []byte(fmt.Sprintf(`"%s"`, tagValue))
}
case reflect.TypeOf(float64(0)):
format := tag.Get("number")
if format == "string" {
return []byte(fmt.Sprintf(`"%s"`, tagValue))
}
case reflect.TypeOf(decimal.Big{}):
decimalTag := tag.Get("decimal")
if decimalTag != "number" {
@@ -377,6 +400,57 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa
typ := dereferenceTypePointer(v.Type())
switch typ.Kind() {
case reflect.Int64:
var b int64
format := tag.Get("integer")
if format == "string" {
var s string
if err := json.Unmarshal(value, &s); err != nil {
return err
}
var err error
b, err = strconv.ParseInt(s, 10, 64)
if err != nil {
return fmt.Errorf("failed to parse string as int64: %w", err)
}
if v.Kind() == reflect.Ptr {
if v.IsNil() {
v.Set(reflect.New(typ))
}
v = v.Elem()
}
v.Set(reflect.ValueOf(b))
return nil
}
case reflect.Float64:
var b float64
format := tag.Get("number")
if format == "string" {
var s string
if err := json.Unmarshal(value, &s); err != nil {
return err
}
var err error
b, err = strconv.ParseFloat(s, 64)
if err != nil {
return fmt.Errorf("failed to parse string as float64: %w", err)
}
if v.Kind() == reflect.Ptr {
if v.IsNil() {
v.Set(reflect.New(typ))
}
v = v.Elem()
}
v.Set(reflect.ValueOf(b))
return nil
}
case reflect.Map:
if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) {
if v.CanAddr() {

View File

@@ -16,18 +16,41 @@ import (
"github.com/LukeHagar/plexgo/types"
)
func GenerateURL(ctx context.Context, serverURL, path string, pathParams interface{}, globals map[string]map[string]map[string]interface{}) (string, error) {
func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) {
uri := strings.TrimSuffix(serverURL, "/") + path
parsedParameters := map[string]string{}
globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{})
if err != nil {
return "", err
}
if globals != nil {
_, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated)
if err != nil {
return "", err
}
}
// TODO should we handle the case where there are no matching path params?
return ReplaceParameters(uri, parsedParameters), nil
}
func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) {
pathParamsStructType := reflect.TypeOf(pathParams)
pathParamsValType := reflect.ValueOf(pathParams)
parsedParameters := map[string]string{}
globalsAlreadyPopulated := []string{}
for i := 0; i < pathParamsStructType.NumField(); i++ {
fieldType := pathParamsStructType.Field(i)
valType := pathParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
requestTag := getRequestTag(fieldType)
if requestTag != nil {
continue
@@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
continue
}
valType = populateFromGlobals(fieldType, valType, "pathParam", globals)
if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
if ppTag.Serialization != "" {
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
if err != nil {
return "", err
return nil, err
}
for k, v := range vals {
parsedParameters[k] = url.PathEscape(v)
@@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
// TODO: support other styles
switch ppTag.Style {
case "simple":
simpleParams := getSimplePathParams(ctx, ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
for k, v := range simpleParams {
parsedParameters[k] = v
}
@@ -60,11 +89,10 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
}
}
// TODO should we handle the case where there are no matching path params?
return ReplaceParameters(uri, parsedParameters), nil
return globalsAlreadyPopulated, nil
}
func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
pathParams := make(map[string]string)
if isNil(objType, objValue) {

View File

@@ -11,16 +11,40 @@ import (
"reflect"
)
func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams interface{}, globals map[string]map[string]map[string]interface{}) error {
func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error {
values := url.Values{}
globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{})
if err != nil {
return err
}
if globals != nil {
_, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated)
if err != nil {
return err
}
}
req.URL.RawQuery = values.Encode()
return nil
}
func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) {
queryParamsStructType := reflect.TypeOf(queryParams)
queryParamsValType := reflect.ValueOf(queryParams)
values := url.Values{}
globalsAlreadyPopulated := []string{}
for i := 0; i < queryParamsStructType.NumField(); i++ {
fieldType := queryParamsStructType.Field(i)
valType := queryParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
requestTag := getRequestTag(fieldType)
if requestTag != nil {
continue
@@ -31,12 +55,18 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
continue
}
valType = populateFromGlobals(fieldType, valType, "queryParam", globals)
if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
if qpTag.Serialization != "" {
vals, err := populateSerializedParams(qpTag, fieldType.Type, valType)
if err != nil {
return err
return nil, err
}
for k, v := range vals {
values.Add(k, v)
@@ -44,35 +74,33 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
} else {
switch qpTag.Style {
case "deepObject":
vals := populateDeepObjectParams(req, qpTag, fieldType.Type, valType)
vals := populateDeepObjectParams(qpTag, fieldType.Type, valType)
for k, v := range vals {
for _, vv := range v {
values.Add(k, vv)
}
}
case "form":
vals := populateFormParams(req, qpTag, fieldType.Type, valType, ",")
vals := populateFormParams(qpTag, fieldType.Type, valType, ",")
for k, v := range vals {
for _, vv := range v {
values.Add(k, vv)
}
}
case "pipeDelimited":
vals := populateFormParams(req, qpTag, fieldType.Type, valType, "|")
vals := populateFormParams(qpTag, fieldType.Type, valType, "|")
for k, v := range vals {
for _, vv := range v {
values.Add(k, vv)
}
}
default:
return fmt.Errorf("unsupported style: %s", qpTag.Style)
return nil, fmt.Errorf("unsupported style: %s", qpTag.Style)
}
}
}
req.URL.RawQuery = values.Encode()
return nil
return globalsAlreadyPopulated, nil
}
func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) {
@@ -98,7 +126,7 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl
return values, nil
}
func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
values := url.Values{}
if isNil(objType, objValue) {
@@ -155,7 +183,7 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.
return values
}
func populateFormParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string {
qpTag := parseQueryParamTag(fieldType)
if qpTag == nil {

View File

@@ -25,8 +25,8 @@ var (
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`)
)
func SerializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
bodyReader, contentType, err := serializeRequestBody(ctx, request, nullable, optional, requestFieldName, serializationMethod, tag)
func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag)
if err != nil {
return nil, "", fmt.Errorf("error serializing request body: %w", err)
}
@@ -38,7 +38,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, nullable, op
return bodyReader, contentType, nil
}
func serializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
requestStructType := reflect.TypeOf(request)
requestValType := reflect.ValueOf(request)

View File

@@ -11,10 +11,6 @@ import (
"strings"
)
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
const (
securityTagKey = "security"
)
@@ -27,73 +23,24 @@ type securityTag struct {
SubType string
}
type securityConfig struct {
headers map[string]string
queryParams map[string]string
}
type SecurityClient struct {
HTTPClient
security func(ctx context.Context) (interface{}, error)
}
func newSecurityClient(client HTTPClient, security func(ctx context.Context) (interface{}, error)) *SecurityClient {
return &SecurityClient{
HTTPClient: client,
security: security,
func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error {
if securitySource == nil {
return nil
}
}
func (c *SecurityClient) Do(req *http.Request) (*http.Response, error) {
securityCtx, err := c.security(req.Context())
security, err := securitySource(ctx)
if err != nil {
return nil, err
return err
}
ctx := securityConfig{
headers: make(map[string]string),
queryParams: make(map[string]string),
}
parseSecurityStruct(&ctx, securityCtx)
headers := make(map[string]string)
queryParams := make(map[string]string)
for k, v := range ctx.headers {
req.Header.Set(k, v)
}
queryParams := req.URL.Query()
for k, v := range ctx.queryParams {
queryParams.Add(k, v)
}
req.URL.RawQuery = queryParams.Encode()
return c.HTTPClient.Do(req)
}
func ConfigureSecurityClient(c HTTPClient, security func(ctx context.Context) (interface{}, error)) *SecurityClient {
return newSecurityClient(c, security)
}
func trueReflectValue(val reflect.Value) reflect.Value {
kind := val.Type().Kind()
for kind == reflect.Interface || kind == reflect.Ptr {
innerVal := val.Elem()
if !innerVal.IsValid() {
break
}
val = innerVal
kind = val.Type().Kind()
}
return val
}
func parseSecurityStruct(c *securityConfig, security interface{}) {
securityValType := trueReflectValue(reflect.ValueOf(security))
securityStructType := securityValType.Type()
if isNil(securityStructType, securityValType) {
return
return nil
}
if securityStructType.Kind() == reflect.Ptr {
@@ -118,20 +65,32 @@ func parseSecurityStruct(c *securityConfig, security interface{}) {
secTag := parseSecurityTag(fieldType)
if secTag != nil {
if secTag.Option {
handleSecurityOption(c, valType.Interface())
handleSecurityOption(headers, queryParams, valType.Interface())
} else if secTag.Scheme {
// Special case for basic auth which could be a flattened struct
if secTag.SubType == "basic" && kind != reflect.Struct {
parseSecurityScheme(c, secTag, security)
parseSecurityScheme(headers, queryParams, secTag, security)
} else {
parseSecurityScheme(c, secTag, valType.Interface())
parseSecurityScheme(headers, queryParams, secTag, valType.Interface())
}
}
}
}
for key, value := range headers {
req.Header.Add(key, value)
}
query := req.URL.Query()
for key, value := range queryParams {
query.Add(key, value)
}
req.URL.RawQuery = query.Encode()
return nil
}
func handleSecurityOption(c *securityConfig, option interface{}) {
func handleSecurityOption(headers, queryParams map[string]string, option interface{}) {
optionValType := trueReflectValue(reflect.ValueOf(option))
optionStructType := optionValType.Type()
@@ -145,12 +104,12 @@ func handleSecurityOption(c *securityConfig, option interface{}) {
secTag := parseSecurityTag(fieldType)
if secTag != nil && secTag.Scheme {
parseSecurityScheme(c, secTag, valType.Interface())
parseSecurityScheme(headers, queryParams, secTag, valType.Interface())
}
}
}
func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme interface{}) {
func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *securityTag, scheme interface{}) {
schemeVal := trueReflectValue(reflect.ValueOf(scheme))
schemeType := schemeVal.Type()
@@ -160,7 +119,7 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
if schemeType.Kind() == reflect.Struct {
if schemeTag.Type == "http" && schemeTag.SubType == "basic" {
handleBasicAuthScheme(client, schemeVal.Interface())
handleBasicAuthScheme(headers, schemeVal.Interface())
return
}
@@ -181,36 +140,36 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
return
}
parseSecuritySchemeValue(client, schemeTag, secTag, valType.Interface())
parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface())
}
} else {
parseSecuritySchemeValue(client, schemeTag, schemeTag, schemeVal.Interface())
parseSecuritySchemeValue(headers, queryParams, schemeTag, schemeTag, schemeVal.Interface())
}
}
func parseSecuritySchemeValue(client *securityConfig, schemeTag *securityTag, secTag *securityTag, val interface{}) {
func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag *securityTag, secTag *securityTag, val interface{}) {
switch schemeTag.Type {
case "apiKey":
switch schemeTag.SubType {
case "header":
client.headers[secTag.Name] = valToString(val)
headers[secTag.Name] = valToString(val)
case "query":
client.queryParams[secTag.Name] = valToString(val)
queryParams[secTag.Name] = valToString(val)
case "cookie":
client.headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
default:
panic("not supported")
}
case "openIdConnect":
client.headers[secTag.Name] = prefixBearer(valToString(val))
headers[secTag.Name] = prefixBearer(valToString(val))
case "oauth2":
if schemeTag.SubType != "client_credentials" {
client.headers[secTag.Name] = prefixBearer(valToString(val))
headers[secTag.Name] = prefixBearer(valToString(val))
}
case "http":
switch schemeTag.SubType {
case "bearer":
client.headers[secTag.Name] = prefixBearer(valToString(val))
headers[secTag.Name] = prefixBearer(valToString(val))
default:
panic("not supported")
}
@@ -227,7 +186,7 @@ func prefixBearer(authHeaderValue string) string {
return fmt.Sprintf("Bearer %s", authHeaderValue)
}
func handleBasicAuthScheme(client *securityConfig, scheme interface{}) {
func handleBasicAuthScheme(headers map[string]string, scheme interface{}) {
schemeStructType := reflect.TypeOf(scheme)
schemeValType := reflect.ValueOf(scheme)
@@ -250,7 +209,7 @@ func handleBasicAuthScheme(client *securityConfig, scheme interface{}) {
}
}
client.headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password))))
headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password))))
}
func parseSecurityTag(field reflect.StructField) *securityTag {
@@ -296,3 +255,16 @@ func parseSecurityTag(field reflect.StructField) *securityTag {
SubType: securitySubType,
}
}
func trueReflectValue(val reflect.Value) reflect.Value {
kind := val.Type().Kind()
for kind == reflect.Interface || kind == reflect.Ptr {
innerVal := val.Elem()
if !innerVal.IsValid() {
break
}
val = innerVal
kind = val.Type().Kind()
}
return val
}

View File

@@ -158,23 +158,43 @@ func valToString(val interface{}) string {
}
}
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals map[string]map[string]map[string]interface{}) reflect.Value {
if globals != nil && fieldType.Type.Kind() == reflect.Ptr {
parameters, ok := globals["parameters"]
if ok {
paramsOfType, ok := parameters[paramType]
if ok {
globalVal, ok := paramsOfType[fieldType.Name]
if ok {
if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() {
valType = reflect.ValueOf(&globalVal)
}
}
}
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) {
if globals == nil {
return fieldType, valType, false
}
globalsStruct := reflect.TypeOf(globals)
globalsStructVal := reflect.ValueOf(globals)
globalsField, found := globalsStruct.FieldByName(fieldType.Name)
if !found {
return fieldType, valType, false
}
if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() {
return fieldType, valType, true
}
globalsVal := globalsStructVal.FieldByName(fieldType.Name)
if !globalsVal.IsValid() {
return fieldType, valType, false
}
switch paramType {
case queryParamTagKey:
qpTag := parseQueryParamTag(globalsField)
if qpTag == nil {
return fieldType, valType, false
}
default:
tag := parseParamTag(paramType, fieldType, "simple", false)
if tag == nil {
return fieldType, valType, false
}
}
return valType
return globalsField, globalsVal, true
}
func isNil(typ reflect.Type, val reflect.Value) bool {
@@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool {
return false
}
func contains(arr []string, str string) bool {
for _, a := range arr {
if a == str {
return true
}
}
return false
}

View File

@@ -32,6 +32,7 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getFileHash",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -57,14 +58,16 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -75,9 +78,11 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -85,11 +90,10 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetFileHashResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -110,17 +114,19 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetFileHashResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -132,6 +138,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getRecentlyAdded",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -148,14 +155,16 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -166,9 +175,11 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -176,11 +187,10 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetRecentlyAddedResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -194,7 +204,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetRecentlyAddedResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -202,7 +212,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -212,17 +222,19 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetRecentlyAddedResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -239,6 +251,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getLibraries",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -255,14 +268,16 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -273,9 +288,11 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -283,11 +300,10 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetLibrariesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -301,7 +317,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetLibrariesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -309,7 +325,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -319,17 +335,19 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetLibrariesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -379,6 +397,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getLibrary",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -404,14 +423,16 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -422,9 +443,11 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -432,11 +455,10 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetLibraryResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -450,7 +472,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetLibraryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -458,7 +480,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -468,17 +490,19 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetLibraryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -490,6 +514,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "deleteLibrary",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -510,14 +535,16 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -528,9 +555,11 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -538,11 +567,10 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.DeleteLibraryResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -563,128 +591,19 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.DeleteLibraryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
}
return res, nil
}
// GetLibraryItems - Get Library Items
// Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
// - `all`: All items in the section.
// - `unwatched`: Items that have not been played.
// - `newest`: Items that are recently released.
// - `recentlyAdded`: Items that are recently added to the library.
// - `recentlyViewed`: Items that were recently viewed.
// - `onDeck`: Items to continue watching.
// - `collection`: Items categorized by collection.
// - `edition`: Items categorized by edition.
// - `genre`: Items categorized by genre.
// - `year`: Items categorized by year of release.
// - `decade`: Items categorized by decade.
// - `director`: Items categorized by director.
// - `actor`: Items categorized by starring actor.
// - `country`: Items categorized by country of origin.
// - `contentRating`: Items categorized by content rating.
// - `rating`: Items categorized by rating.
// - `resolution`: Items categorized by resolution.
// - `firstCharacter`: Items categorized by the first letter.
// - `folder`: Items categorized by folder.
func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag operations.Tag) (*operations.GetLibraryItemsResponse, error) {
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getLibraryItems",
SecuritySource: s.sdkConfiguration.Security,
}
request := operations.GetLibraryItemsRequest{
SectionID: sectionID,
Tag: tag,
}
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, nil)
if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err)
}
req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil)
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)
client := s.sdkConfiguration.SecurityClient
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := 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{"4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
if err != nil {
return nil, err
}
} else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
if err != nil {
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetLibraryItemsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
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))
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.GetLibraryItemsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -696,6 +615,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "refreshLibrary",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -716,14 +636,16 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -734,9 +656,11 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -744,11 +668,10 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.RefreshLibraryResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -769,17 +692,19 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.RefreshLibraryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -808,6 +733,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "searchLibrary",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -833,14 +759,16 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -851,9 +779,11 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -861,11 +791,10 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.SearchLibraryResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -879,7 +808,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.SearchLibraryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -887,12 +816,14 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -904,6 +835,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getMetadata",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -924,14 +856,16 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -942,9 +876,11 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -952,11 +888,10 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetMetadataResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -970,7 +905,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetMetadataResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -978,7 +913,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -988,17 +923,19 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetMetadataResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -1010,6 +947,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getMetadataChildren",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -1030,14 +968,16 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -1048,9 +988,11 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -1058,11 +1000,10 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetMetadataChildrenResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -1076,7 +1017,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetMetadataChildrenResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -1084,7 +1025,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -1094,17 +1035,19 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetMetadataChildrenResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -1116,6 +1059,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getOnDeck",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -1132,14 +1076,16 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -1150,9 +1096,11 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -1160,11 +1108,10 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetOnDeckResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -1178,7 +1125,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetOnDeckResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -1186,7 +1133,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -1196,17 +1143,19 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetOnDeckResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

66
log.go
View File

@@ -32,6 +32,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "logLine",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -58,14 +59,16 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -76,9 +79,11 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -86,11 +91,10 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.LogLineResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -111,17 +115,19 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.LogLineResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -153,6 +159,7 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "logMultiLine",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -175,14 +182,16 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
req.Header.Set("Content-Type", reqContentType)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -193,9 +202,11 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -203,11 +214,10 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.LogMultiLineResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -228,17 +238,19 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.LogMultiLineResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -250,6 +262,7 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "enablePaperTrail",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -266,14 +279,16 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -284,9 +299,11 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "403", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -294,11 +311,10 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.EnablePaperTrailResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -321,17 +337,19 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.EnablePaperTrailResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -32,6 +32,7 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "markPlayed",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -56,14 +57,16 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -74,9 +77,11 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -84,11 +89,10 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.MarkPlayedResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -109,17 +113,19 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.MarkPlayedResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -131,6 +137,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "markUnplayed",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -155,14 +162,16 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -173,9 +182,11 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -183,11 +194,10 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.MarkUnplayedResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -208,17 +218,19 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.MarkUnplayedResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -230,6 +242,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "updatePlayProgress",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -256,14 +269,16 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -274,9 +289,11 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -284,11 +301,10 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.UpdatePlayProgressResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -309,17 +325,19 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.UpdatePlayProgressResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -1,992 +0,0 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package operations
import (
"encoding/json"
"fmt"
"github.com/LukeHagar/plexgo/internal/utils"
"github.com/LukeHagar/plexgo/types"
"net/http"
)
// Tag - A key representing a specific tag within the section.
type Tag string
const (
TagAll Tag = "all"
TagUnwatched Tag = "unwatched"
TagNewest Tag = "newest"
TagRecentlyAdded Tag = "recentlyAdded"
TagRecentlyViewed Tag = "recentlyViewed"
TagOnDeck Tag = "onDeck"
TagCollection Tag = "collection"
TagEdition Tag = "edition"
TagGenre Tag = "genre"
TagYear Tag = "year"
TagDecade Tag = "decade"
TagDirector Tag = "director"
TagActor Tag = "actor"
TagCountry Tag = "country"
TagContentRating Tag = "contentRating"
TagRating Tag = "rating"
TagResolution Tag = "resolution"
TagFirstCharacter Tag = "firstCharacter"
TagFolder Tag = "folder"
)
func (e Tag) ToPointer() *Tag {
return &e
}
func (e *Tag) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "all":
fallthrough
case "unwatched":
fallthrough
case "newest":
fallthrough
case "recentlyAdded":
fallthrough
case "recentlyViewed":
fallthrough
case "onDeck":
fallthrough
case "collection":
fallthrough
case "edition":
fallthrough
case "genre":
fallthrough
case "year":
fallthrough
case "decade":
fallthrough
case "director":
fallthrough
case "actor":
fallthrough
case "country":
fallthrough
case "contentRating":
fallthrough
case "rating":
fallthrough
case "resolution":
fallthrough
case "firstCharacter":
fallthrough
case "folder":
*e = Tag(v)
return nil
default:
return fmt.Errorf("invalid value for Tag: %v", v)
}
}
type GetLibraryItemsRequest struct {
// the Id of the library to query
SectionID int64 `pathParam:"style=simple,explode=false,name=sectionId"`
// A key representing a specific tag within the section.
Tag Tag `pathParam:"style=simple,explode=false,name=tag"`
}
func (o *GetLibraryItemsRequest) GetSectionID() int64 {
if o == nil {
return 0
}
return o.SectionID
}
func (o *GetLibraryItemsRequest) GetTag() Tag {
if o == nil {
return Tag("")
}
return o.Tag
}
type GetLibraryItemsPart struct {
ID *int `json:"id,omitempty"`
Key *string `json:"key,omitempty"`
Duration *int `json:"duration,omitempty"`
File *string `json:"file,omitempty"`
Size *int64 `json:"size,omitempty"`
Container *string `json:"container,omitempty"`
VideoProfile *string `json:"videoProfile,omitempty"`
}
func (o *GetLibraryItemsPart) GetID() *int {
if o == nil {
return nil
}
return o.ID
}
func (o *GetLibraryItemsPart) GetKey() *string {
if o == nil {
return nil
}
return o.Key
}
func (o *GetLibraryItemsPart) GetDuration() *int {
if o == nil {
return nil
}
return o.Duration
}
func (o *GetLibraryItemsPart) GetFile() *string {
if o == nil {
return nil
}
return o.File
}
func (o *GetLibraryItemsPart) GetSize() *int64 {
if o == nil {
return nil
}
return o.Size
}
func (o *GetLibraryItemsPart) GetContainer() *string {
if o == nil {
return nil
}
return o.Container
}
func (o *GetLibraryItemsPart) GetVideoProfile() *string {
if o == nil {
return nil
}
return o.VideoProfile
}
type GetLibraryItemsMedia struct {
ID *int `json:"id,omitempty"`
Duration *int `json:"duration,omitempty"`
Bitrate *int `json:"bitrate,omitempty"`
Width *int `json:"width,omitempty"`
Height *int `json:"height,omitempty"`
AspectRatio *float64 `json:"aspectRatio,omitempty"`
AudioChannels *int `json:"audioChannels,omitempty"`
AudioCodec *string `json:"audioCodec,omitempty"`
VideoCodec *string `json:"videoCodec,omitempty"`
VideoResolution *string `json:"videoResolution,omitempty"`
Container *string `json:"container,omitempty"`
VideoFrameRate *string `json:"videoFrameRate,omitempty"`
VideoProfile *string `json:"videoProfile,omitempty"`
Part []GetLibraryItemsPart `json:"Part,omitempty"`
}
func (o *GetLibraryItemsMedia) GetID() *int {
if o == nil {
return nil
}
return o.ID
}
func (o *GetLibraryItemsMedia) GetDuration() *int {
if o == nil {
return nil
}
return o.Duration
}
func (o *GetLibraryItemsMedia) GetBitrate() *int {
if o == nil {
return nil
}
return o.Bitrate
}
func (o *GetLibraryItemsMedia) GetWidth() *int {
if o == nil {
return nil
}
return o.Width
}
func (o *GetLibraryItemsMedia) GetHeight() *int {
if o == nil {
return nil
}
return o.Height
}
func (o *GetLibraryItemsMedia) GetAspectRatio() *float64 {
if o == nil {
return nil
}
return o.AspectRatio
}
func (o *GetLibraryItemsMedia) GetAudioChannels() *int {
if o == nil {
return nil
}
return o.AudioChannels
}
func (o *GetLibraryItemsMedia) GetAudioCodec() *string {
if o == nil {
return nil
}
return o.AudioCodec
}
func (o *GetLibraryItemsMedia) GetVideoCodec() *string {
if o == nil {
return nil
}
return o.VideoCodec
}
func (o *GetLibraryItemsMedia) GetVideoResolution() *string {
if o == nil {
return nil
}
return o.VideoResolution
}
func (o *GetLibraryItemsMedia) GetContainer() *string {
if o == nil {
return nil
}
return o.Container
}
func (o *GetLibraryItemsMedia) GetVideoFrameRate() *string {
if o == nil {
return nil
}
return o.VideoFrameRate
}
func (o *GetLibraryItemsMedia) GetVideoProfile() *string {
if o == nil {
return nil
}
return o.VideoProfile
}
func (o *GetLibraryItemsMedia) GetPart() []GetLibraryItemsPart {
if o == nil {
return nil
}
return o.Part
}
type GetLibraryItemsGenre struct {
Tag *string `json:"tag,omitempty"`
}
func (o *GetLibraryItemsGenre) GetTag() *string {
if o == nil {
return nil
}
return o.Tag
}
type GetLibraryItemsCountry struct {
Tag *string `json:"tag,omitempty"`
}
func (o *GetLibraryItemsCountry) GetTag() *string {
if o == nil {
return nil
}
return o.Tag
}
type GetLibraryItemsDirector struct {
Tag *string `json:"tag,omitempty"`
}
func (o *GetLibraryItemsDirector) GetTag() *string {
if o == nil {
return nil
}
return o.Tag
}
type GetLibraryItemsWriter struct {
Tag *string `json:"tag,omitempty"`
}
func (o *GetLibraryItemsWriter) GetTag() *string {
if o == nil {
return nil
}
return o.Tag
}
type GetLibraryItemsRole struct {
Tag *string `json:"tag,omitempty"`
}
func (o *GetLibraryItemsRole) GetTag() *string {
if o == nil {
return nil
}
return o.Tag
}
type GetLibraryItemsMetadata struct {
RatingKey *string `json:"ratingKey,omitempty"`
Key *string `json:"key,omitempty"`
GUID *string `json:"guid,omitempty"`
Studio *string `json:"studio,omitempty"`
Type *string `json:"type,omitempty"`
Title *string `json:"title,omitempty"`
ContentRating *string `json:"contentRating,omitempty"`
Summary *string `json:"summary,omitempty"`
Rating *float64 `json:"rating,omitempty"`
AudienceRating *float64 `json:"audienceRating,omitempty"`
Year *int `json:"year,omitempty"`
Tagline *string `json:"tagline,omitempty"`
Thumb *string `json:"thumb,omitempty"`
Art *string `json:"art,omitempty"`
Duration *int `json:"duration,omitempty"`
OriginallyAvailableAt *types.Date `json:"originallyAvailableAt,omitempty"`
AddedAt *int `json:"addedAt,omitempty"`
UpdatedAt *int `json:"updatedAt,omitempty"`
AudienceRatingImage *string `json:"audienceRatingImage,omitempty"`
ChapterSource *string `json:"chapterSource,omitempty"`
PrimaryExtraKey *string `json:"primaryExtraKey,omitempty"`
RatingImage *string `json:"ratingImage,omitempty"`
GrandparentRatingKey *string `json:"grandparentRatingKey,omitempty"`
GrandparentGUID *string `json:"grandparentGuid,omitempty"`
GrandparentKey *string `json:"grandparentKey,omitempty"`
GrandparentTitle *string `json:"grandparentTitle,omitempty"`
GrandparentThumb *string `json:"grandparentThumb,omitempty"`
GrandparentArt *string `json:"grandparentArt,omitempty"`
GrandparentTheme *string `json:"grandparentTheme,omitempty"`
Media []GetLibraryItemsMedia `json:"Media,omitempty"`
Genre []GetLibraryItemsGenre `json:"Genre,omitempty"`
Country []GetLibraryItemsCountry `json:"Country,omitempty"`
Director []GetLibraryItemsDirector `json:"Director,omitempty"`
Writer []GetLibraryItemsWriter `json:"Writer,omitempty"`
Role []GetLibraryItemsRole `json:"Role,omitempty"`
TitleSort *string `json:"titleSort,omitempty"`
ViewCount *int `json:"viewCount,omitempty"`
LastViewedAt *int `json:"lastViewedAt,omitempty"`
OriginalTitle *string `json:"originalTitle,omitempty"`
ViewOffset *int `json:"viewOffset,omitempty"`
SkipCount *int `json:"skipCount,omitempty"`
Index *int `json:"index,omitempty"`
Theme *string `json:"theme,omitempty"`
LeafCount *int `json:"leafCount,omitempty"`
ViewedLeafCount *int `json:"viewedLeafCount,omitempty"`
ChildCount *int `json:"childCount,omitempty"`
HasPremiumExtras *string `json:"hasPremiumExtras,omitempty"`
HasPremiumPrimaryExtra *string `json:"hasPremiumPrimaryExtra,omitempty"`
ParentRatingKey *string `json:"parentRatingKey,omitempty"`
ParentGUID *string `json:"parentGuid,omitempty"`
ParentStudio *string `json:"parentStudio,omitempty"`
ParentKey *string `json:"parentKey,omitempty"`
ParentTitle *string `json:"parentTitle,omitempty"`
ParentIndex *int `json:"parentIndex,omitempty"`
ParentYear *int `json:"parentYear,omitempty"`
ParentThumb *string `json:"parentThumb,omitempty"`
ParentTheme *string `json:"parentTheme,omitempty"`
}
func (g GetLibraryItemsMetadata) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(g, "", false)
}
func (g *GetLibraryItemsMetadata) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil {
return err
}
return nil
}
func (o *GetLibraryItemsMetadata) GetRatingKey() *string {
if o == nil {
return nil
}
return o.RatingKey
}
func (o *GetLibraryItemsMetadata) GetKey() *string {
if o == nil {
return nil
}
return o.Key
}
func (o *GetLibraryItemsMetadata) GetGUID() *string {
if o == nil {
return nil
}
return o.GUID
}
func (o *GetLibraryItemsMetadata) GetStudio() *string {
if o == nil {
return nil
}
return o.Studio
}
func (o *GetLibraryItemsMetadata) GetType() *string {
if o == nil {
return nil
}
return o.Type
}
func (o *GetLibraryItemsMetadata) GetTitle() *string {
if o == nil {
return nil
}
return o.Title
}
func (o *GetLibraryItemsMetadata) GetContentRating() *string {
if o == nil {
return nil
}
return o.ContentRating
}
func (o *GetLibraryItemsMetadata) GetSummary() *string {
if o == nil {
return nil
}
return o.Summary
}
func (o *GetLibraryItemsMetadata) GetRating() *float64 {
if o == nil {
return nil
}
return o.Rating
}
func (o *GetLibraryItemsMetadata) GetAudienceRating() *float64 {
if o == nil {
return nil
}
return o.AudienceRating
}
func (o *GetLibraryItemsMetadata) GetYear() *int {
if o == nil {
return nil
}
return o.Year
}
func (o *GetLibraryItemsMetadata) GetTagline() *string {
if o == nil {
return nil
}
return o.Tagline
}
func (o *GetLibraryItemsMetadata) GetThumb() *string {
if o == nil {
return nil
}
return o.Thumb
}
func (o *GetLibraryItemsMetadata) GetArt() *string {
if o == nil {
return nil
}
return o.Art
}
func (o *GetLibraryItemsMetadata) GetDuration() *int {
if o == nil {
return nil
}
return o.Duration
}
func (o *GetLibraryItemsMetadata) GetOriginallyAvailableAt() *types.Date {
if o == nil {
return nil
}
return o.OriginallyAvailableAt
}
func (o *GetLibraryItemsMetadata) GetAddedAt() *int {
if o == nil {
return nil
}
return o.AddedAt
}
func (o *GetLibraryItemsMetadata) GetUpdatedAt() *int {
if o == nil {
return nil
}
return o.UpdatedAt
}
func (o *GetLibraryItemsMetadata) GetAudienceRatingImage() *string {
if o == nil {
return nil
}
return o.AudienceRatingImage
}
func (o *GetLibraryItemsMetadata) GetChapterSource() *string {
if o == nil {
return nil
}
return o.ChapterSource
}
func (o *GetLibraryItemsMetadata) GetPrimaryExtraKey() *string {
if o == nil {
return nil
}
return o.PrimaryExtraKey
}
func (o *GetLibraryItemsMetadata) GetRatingImage() *string {
if o == nil {
return nil
}
return o.RatingImage
}
func (o *GetLibraryItemsMetadata) GetGrandparentRatingKey() *string {
if o == nil {
return nil
}
return o.GrandparentRatingKey
}
func (o *GetLibraryItemsMetadata) GetGrandparentGUID() *string {
if o == nil {
return nil
}
return o.GrandparentGUID
}
func (o *GetLibraryItemsMetadata) GetGrandparentKey() *string {
if o == nil {
return nil
}
return o.GrandparentKey
}
func (o *GetLibraryItemsMetadata) GetGrandparentTitle() *string {
if o == nil {
return nil
}
return o.GrandparentTitle
}
func (o *GetLibraryItemsMetadata) GetGrandparentThumb() *string {
if o == nil {
return nil
}
return o.GrandparentThumb
}
func (o *GetLibraryItemsMetadata) GetGrandparentArt() *string {
if o == nil {
return nil
}
return o.GrandparentArt
}
func (o *GetLibraryItemsMetadata) GetGrandparentTheme() *string {
if o == nil {
return nil
}
return o.GrandparentTheme
}
func (o *GetLibraryItemsMetadata) GetMedia() []GetLibraryItemsMedia {
if o == nil {
return nil
}
return o.Media
}
func (o *GetLibraryItemsMetadata) GetGenre() []GetLibraryItemsGenre {
if o == nil {
return nil
}
return o.Genre
}
func (o *GetLibraryItemsMetadata) GetCountry() []GetLibraryItemsCountry {
if o == nil {
return nil
}
return o.Country
}
func (o *GetLibraryItemsMetadata) GetDirector() []GetLibraryItemsDirector {
if o == nil {
return nil
}
return o.Director
}
func (o *GetLibraryItemsMetadata) GetWriter() []GetLibraryItemsWriter {
if o == nil {
return nil
}
return o.Writer
}
func (o *GetLibraryItemsMetadata) GetRole() []GetLibraryItemsRole {
if o == nil {
return nil
}
return o.Role
}
func (o *GetLibraryItemsMetadata) GetTitleSort() *string {
if o == nil {
return nil
}
return o.TitleSort
}
func (o *GetLibraryItemsMetadata) GetViewCount() *int {
if o == nil {
return nil
}
return o.ViewCount
}
func (o *GetLibraryItemsMetadata) GetLastViewedAt() *int {
if o == nil {
return nil
}
return o.LastViewedAt
}
func (o *GetLibraryItemsMetadata) GetOriginalTitle() *string {
if o == nil {
return nil
}
return o.OriginalTitle
}
func (o *GetLibraryItemsMetadata) GetViewOffset() *int {
if o == nil {
return nil
}
return o.ViewOffset
}
func (o *GetLibraryItemsMetadata) GetSkipCount() *int {
if o == nil {
return nil
}
return o.SkipCount
}
func (o *GetLibraryItemsMetadata) GetIndex() *int {
if o == nil {
return nil
}
return o.Index
}
func (o *GetLibraryItemsMetadata) GetTheme() *string {
if o == nil {
return nil
}
return o.Theme
}
func (o *GetLibraryItemsMetadata) GetLeafCount() *int {
if o == nil {
return nil
}
return o.LeafCount
}
func (o *GetLibraryItemsMetadata) GetViewedLeafCount() *int {
if o == nil {
return nil
}
return o.ViewedLeafCount
}
func (o *GetLibraryItemsMetadata) GetChildCount() *int {
if o == nil {
return nil
}
return o.ChildCount
}
func (o *GetLibraryItemsMetadata) GetHasPremiumExtras() *string {
if o == nil {
return nil
}
return o.HasPremiumExtras
}
func (o *GetLibraryItemsMetadata) GetHasPremiumPrimaryExtra() *string {
if o == nil {
return nil
}
return o.HasPremiumPrimaryExtra
}
func (o *GetLibraryItemsMetadata) GetParentRatingKey() *string {
if o == nil {
return nil
}
return o.ParentRatingKey
}
func (o *GetLibraryItemsMetadata) GetParentGUID() *string {
if o == nil {
return nil
}
return o.ParentGUID
}
func (o *GetLibraryItemsMetadata) GetParentStudio() *string {
if o == nil {
return nil
}
return o.ParentStudio
}
func (o *GetLibraryItemsMetadata) GetParentKey() *string {
if o == nil {
return nil
}
return o.ParentKey
}
func (o *GetLibraryItemsMetadata) GetParentTitle() *string {
if o == nil {
return nil
}
return o.ParentTitle
}
func (o *GetLibraryItemsMetadata) GetParentIndex() *int {
if o == nil {
return nil
}
return o.ParentIndex
}
func (o *GetLibraryItemsMetadata) GetParentYear() *int {
if o == nil {
return nil
}
return o.ParentYear
}
func (o *GetLibraryItemsMetadata) GetParentThumb() *string {
if o == nil {
return nil
}
return o.ParentThumb
}
func (o *GetLibraryItemsMetadata) GetParentTheme() *string {
if o == nil {
return nil
}
return o.ParentTheme
}
type GetLibraryItemsMediaContainer struct {
Size *int `json:"size,omitempty"`
AllowSync *bool `json:"allowSync,omitempty"`
Art *string `json:"art,omitempty"`
Identifier *string `json:"identifier,omitempty"`
LibrarySectionID *int `json:"librarySectionID,omitempty"`
LibrarySectionTitle *string `json:"librarySectionTitle,omitempty"`
LibrarySectionUUID *string `json:"librarySectionUUID,omitempty"`
MediaTagPrefix *string `json:"mediaTagPrefix,omitempty"`
MediaTagVersion *int `json:"mediaTagVersion,omitempty"`
Thumb *string `json:"thumb,omitempty"`
Title1 *string `json:"title1,omitempty"`
Title2 *string `json:"title2,omitempty"`
ViewGroup *string `json:"viewGroup,omitempty"`
ViewMode *int `json:"viewMode,omitempty"`
MixedParents *bool `json:"mixedParents,omitempty"`
Metadata []GetLibraryItemsMetadata `json:"Metadata,omitempty"`
}
func (o *GetLibraryItemsMediaContainer) GetSize() *int {
if o == nil {
return nil
}
return o.Size
}
func (o *GetLibraryItemsMediaContainer) GetAllowSync() *bool {
if o == nil {
return nil
}
return o.AllowSync
}
func (o *GetLibraryItemsMediaContainer) GetArt() *string {
if o == nil {
return nil
}
return o.Art
}
func (o *GetLibraryItemsMediaContainer) GetIdentifier() *string {
if o == nil {
return nil
}
return o.Identifier
}
func (o *GetLibraryItemsMediaContainer) GetLibrarySectionID() *int {
if o == nil {
return nil
}
return o.LibrarySectionID
}
func (o *GetLibraryItemsMediaContainer) GetLibrarySectionTitle() *string {
if o == nil {
return nil
}
return o.LibrarySectionTitle
}
func (o *GetLibraryItemsMediaContainer) GetLibrarySectionUUID() *string {
if o == nil {
return nil
}
return o.LibrarySectionUUID
}
func (o *GetLibraryItemsMediaContainer) GetMediaTagPrefix() *string {
if o == nil {
return nil
}
return o.MediaTagPrefix
}
func (o *GetLibraryItemsMediaContainer) GetMediaTagVersion() *int {
if o == nil {
return nil
}
return o.MediaTagVersion
}
func (o *GetLibraryItemsMediaContainer) GetThumb() *string {
if o == nil {
return nil
}
return o.Thumb
}
func (o *GetLibraryItemsMediaContainer) GetTitle1() *string {
if o == nil {
return nil
}
return o.Title1
}
func (o *GetLibraryItemsMediaContainer) GetTitle2() *string {
if o == nil {
return nil
}
return o.Title2
}
func (o *GetLibraryItemsMediaContainer) GetViewGroup() *string {
if o == nil {
return nil
}
return o.ViewGroup
}
func (o *GetLibraryItemsMediaContainer) GetViewMode() *int {
if o == nil {
return nil
}
return o.ViewMode
}
func (o *GetLibraryItemsMediaContainer) GetMixedParents() *bool {
if o == nil {
return nil
}
return o.MixedParents
}
func (o *GetLibraryItemsMediaContainer) GetMetadata() []GetLibraryItemsMetadata {
if o == nil {
return nil
}
return o.Metadata
}
// GetLibraryItemsResponseBody - The contents of the library by section and tag
type GetLibraryItemsResponseBody struct {
MediaContainer *GetLibraryItemsMediaContainer `json:"MediaContainer,omitempty"`
}
func (o *GetLibraryItemsResponseBody) GetMediaContainer() *GetLibraryItemsMediaContainer {
if o == nil {
return nil
}
return o.MediaContainer
}
type GetLibraryItemsResponse struct {
// HTTP response content type for this operation
ContentType string
// HTTP response status code for this operation
StatusCode int
// Raw HTTP response; suitable for custom response parsing
RawResponse *http.Response
// The contents of the library by section and tag
Object *GetLibraryItemsResponseBody
}
func (o *GetLibraryItemsResponse) GetContentType() string {
if o == nil {
return ""
}
return o.ContentType
}
func (o *GetLibraryItemsResponse) GetStatusCode() int {
if o == nil {
return 0
}
return o.StatusCode
}
func (o *GetLibraryItemsResponse) GetRawResponse() *http.Response {
if o == nil {
return nil
}
return o.RawResponse
}
func (o *GetLibraryItemsResponse) GetObject() *GetLibraryItemsResponseBody {
if o == nil {
return nil
}
return o.Object
}

View File

@@ -12,17 +12,32 @@ var GetPinServerList = []string{
"https://plex.tv/api/v2",
}
type GetPinRequest struct {
type GetPinGlobals struct {
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetPinGlobals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
type GetPinRequest struct {
// Determines the kind of code returned by the API call
// Strong codes are used for Pin authentication flows
// Non-Strong codes are used for `Plex.tv/link`
//
Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"`
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (g GetPinRequest) MarshalJSON() ([]byte, error) {
@@ -36,13 +51,6 @@ func (g *GetPinRequest) UnmarshalJSON(data []byte) error {
return nil
}
func (o *GetPinRequest) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
func (o *GetPinRequest) GetStrong() *bool {
if o == nil {
return nil
@@ -50,6 +58,13 @@ func (o *GetPinRequest) GetStrong() *bool {
return o.Strong
}
func (o *GetPinRequest) GetXPlexClientIdentifier() *string {
if o == nil {
return nil
}
return o.XPlexClientIdentifier
}
type Location struct {
Code *string `json:"code,omitempty"`
EuropeanUnionMember *bool `json:"european_union_member,omitempty"`

View File

@@ -10,6 +10,21 @@ var GetTokenServerList = []string{
"https://plex.tv/api/v2",
}
type GetTokenGlobals struct {
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetTokenGlobals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
type GetTokenRequest struct {
// The PinID to retrieve an access token for
PinID string `pathParam:"style=simple,explode=false,name=pinID"`
@@ -17,7 +32,7 @@ type GetTokenRequest struct {
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetTokenRequest) GetPinID() string {
@@ -27,9 +42,9 @@ func (o *GetTokenRequest) GetPinID() string {
return o.PinID
}
func (o *GetTokenRequest) GetXPlexClientIdentifier() string {
func (o *GetTokenRequest) GetXPlexClientIdentifier() *string {
if o == nil {
return ""
return nil
}
return o.XPlexClientIdentifier
}

View File

@@ -37,6 +37,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "createPlaylist",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -57,14 +58,16 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -75,9 +78,11 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -85,11 +90,10 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.CreatePlaylistResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -103,7 +107,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.CreatePlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -111,7 +115,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -121,17 +125,19 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.CreatePlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -143,6 +149,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getPlaylists",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -168,14 +175,16 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -186,9 +195,11 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -196,11 +207,10 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetPlaylistsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -214,7 +224,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetPlaylistsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -222,7 +232,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -232,17 +242,19 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetPlaylistsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -255,6 +267,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getPlaylist",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -275,14 +288,16 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -293,9 +308,11 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -303,11 +320,10 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetPlaylistResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -321,7 +337,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetPlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -329,7 +345,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -339,17 +355,19 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetPlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -361,6 +379,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "deletePlaylist",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -381,14 +400,16 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -399,9 +420,11 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -409,11 +432,10 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.DeletePlaylistResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -434,17 +456,19 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.DeletePlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -456,6 +480,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "updatePlaylist",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -482,14 +507,16 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -500,9 +527,11 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -510,11 +539,10 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.UpdatePlaylistResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -535,17 +563,19 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.UpdatePlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -560,6 +590,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getPlaylistContents",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -585,14 +616,16 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -603,9 +636,11 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -613,11 +648,10 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetPlaylistContentsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -631,7 +665,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetPlaylistContentsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -639,7 +673,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -649,17 +683,19 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetPlaylistContentsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -671,6 +707,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "clearPlaylistContents",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -691,14 +728,16 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -709,9 +748,11 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -719,11 +760,10 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.ClearPlaylistContentsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -744,17 +784,19 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.ClearPlaylistContentsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -767,6 +809,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "addPlaylistContents",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -793,14 +836,16 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -811,9 +856,11 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -821,11 +868,10 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.AddPlaylistContentsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -839,7 +885,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.AddPlaylistContentsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -847,7 +893,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -857,17 +903,19 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.AddPlaylistContentsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -879,6 +927,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "uploadPlaylist",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -904,14 +953,16 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -922,9 +973,11 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -932,11 +985,10 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.UploadPlaylistResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -957,17 +1009,19 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.UploadPlaylistResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

71
plex.go
View File

@@ -12,7 +12,6 @@ import (
"github.com/LukeHagar/plexgo/models/sdkerrors"
"io"
"net/http"
"net/url"
)
// Plex - API Calls that perform operations directly against https://Plex.tv
@@ -28,16 +27,21 @@ func newPlex(sdkConfig sdkConfiguration) *Plex {
// GetPin - Get a Pin
// Retrieve a Pin from Plex.tv for authentication flows
func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong *bool, opts ...operations.Option) (*operations.GetPinResponse, error) {
func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetPinResponse, error) {
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getPin",
OAuth2Scopes: []string{},
SecuritySource: nil,
}
request := operations.GetPinRequest{
XPlexClientIdentifier: xPlexClientIdentifier,
Strong: strong,
XPlexClientIdentifier: xPlexClientIdentifier,
}
globals := operations.GetPinGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
}
o := operations.Options{}
@@ -55,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
baseURL = *o.ServerURL
}
opURL, err := url.JoinPath(baseURL, "/pins")
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals)
if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err)
}
@@ -67,20 +71,18 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request)
utils.PopulateHeaders(ctx, req, request, globals)
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.DefaultClient
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -91,9 +93,11 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -101,11 +105,10 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetPinResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -119,7 +122,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetPinResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -127,25 +130,27 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetPinResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -153,10 +158,11 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
// GetToken - Get Access Token
// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getToken",
OAuth2Scopes: []string{},
SecuritySource: nil,
}
@@ -165,6 +171,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
XPlexClientIdentifier: xPlexClientIdentifier,
}
globals := operations.GetTokenGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
}
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionServerURL,
@@ -180,7 +190,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
baseURL = *o.ServerURL
}
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil)
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals)
if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err)
}
@@ -192,16 +202,18 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request)
utils.PopulateHeaders(ctx, req, request, globals)
client := s.sdkConfiguration.DefaultClient
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err)
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -212,9 +224,11 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -222,11 +236,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetTokenResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -241,21 +254,23 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
case httpRes.StatusCode == 200:
case httpRes.StatusCode == 400:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetTokenResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/LukeHagar/plexgo/internal/globals"
"github.com/LukeHagar/plexgo/internal/hooks"
"github.com/LukeHagar/plexgo/internal/utils"
"github.com/LukeHagar/plexgo/models/components"
@@ -43,8 +44,7 @@ func Float32(f float32) *float32 { return &f }
func Float64(f float64) *float64 { return &f }
type sdkConfiguration struct {
DefaultClient HTTPClient
SecurityClient HTTPClient
Client HTTPClient
Security func(context.Context) (interface{}, error)
ServerURL string
ServerIndex int
@@ -54,6 +54,7 @@ type sdkConfiguration struct {
SDKVersion string
GenVersion string
UserAgent string
Globals globals.Globals
RetryConfig *utils.RetryConfig
Hooks *hooks.Hooks
}
@@ -229,7 +230,7 @@ func WithPort(port string) SDKOption {
// WithClient allows the overriding of the default HTTP client used by the SDK
func WithClient(client HTTPClient) SDKOption {
return func(sdk *PlexAPI) {
sdk.sdkConfiguration.DefaultClient = client
sdk.sdkConfiguration.Client = client
}
}
@@ -256,6 +257,13 @@ func WithSecuritySource(security func(context.Context) (components.Security, err
}
}
// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations
func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption {
return func(sdk *PlexAPI) {
sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier
}
}
func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption {
return func(sdk *PlexAPI) {
sdk.sdkConfiguration.RetryConfig = &retryConfig
@@ -268,9 +276,10 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{
Language: "go",
OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.4.1",
GenVersion: "2.272.4",
UserAgent: "speakeasy-sdk/go 0.4.1 2.272.4 0.0.3 github.com/LukeHagar/plexgo",
SDKVersion: "0.7.0",
GenVersion: "2.326.3",
UserAgent: "speakeasy-sdk/go 0.7.0 2.326.3 0.0.3 github.com/LukeHagar/plexgo",
Globals: globals.Globals{},
ServerDefaults: []map[string]string{
{
"protocol": "http",
@@ -286,25 +295,17 @@ func New(opts ...SDKOption) *PlexAPI {
}
// Use WithClient to override the default client if you would like to customize the timeout
if sdk.sdkConfiguration.DefaultClient == nil {
sdk.sdkConfiguration.DefaultClient = &http.Client{Timeout: 60 * time.Second}
if sdk.sdkConfiguration.Client == nil {
sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second}
}
currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails()
serverURL := currentServerURL
serverURL, sdk.sdkConfiguration.DefaultClient = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.DefaultClient)
serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client)
if serverURL != currentServerURL {
sdk.sdkConfiguration.ServerURL = serverURL
}
if sdk.sdkConfiguration.SecurityClient == nil {
if sdk.sdkConfiguration.Security != nil {
sdk.sdkConfiguration.SecurityClient = utils.ConfigureSecurityClient(sdk.sdkConfiguration.DefaultClient, sdk.sdkConfiguration.Security)
} else {
sdk.sdkConfiguration.SecurityClient = sdk.sdkConfiguration.DefaultClient
}
}
sdk.Server = newServer(sdk.sdkConfiguration)
sdk.Media = newMedia(sdk.sdkConfiguration)

View File

@@ -44,6 +44,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "performSearch",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -70,14 +71,16 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -88,9 +91,11 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -98,11 +103,10 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.PerformSearchResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -123,17 +127,19 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.PerformSearchResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -148,6 +154,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "performVoiceSearch",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -174,14 +181,16 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -192,9 +201,11 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -202,11 +213,10 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.PerformVoiceSearchResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -227,17 +237,19 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.PerformVoiceSearchResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -249,6 +261,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getSearchResults",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -273,14 +286,16 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -291,9 +306,11 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -301,11 +318,10 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetSearchResultsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -319,7 +335,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetSearchResultsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -327,7 +343,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -337,17 +353,19 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetSearchResultsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

204
server.go
View File

@@ -32,6 +32,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getServerCapabilities",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -48,14 +49,16 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -66,9 +69,11 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -76,11 +81,10 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetServerCapabilitiesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -94,7 +98,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetServerCapabilitiesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -102,7 +106,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -112,17 +116,19 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetServerCapabilitiesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -134,6 +140,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getServerPreferences",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -150,14 +157,16 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -168,9 +177,11 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -178,11 +189,10 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetServerPreferencesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -196,7 +206,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetServerPreferencesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -204,7 +214,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -214,17 +224,19 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetServerPreferencesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -236,6 +248,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getAvailableClients",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -252,14 +265,16 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -270,9 +285,11 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -280,11 +297,10 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetAvailableClientsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -298,7 +314,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetAvailableClientsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -306,7 +322,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -316,17 +332,19 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetAvailableClientsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -338,6 +356,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getDevices",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -354,14 +373,16 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -372,9 +393,11 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -382,11 +405,10 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetDevicesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -400,7 +422,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetDevicesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -408,7 +430,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -418,17 +440,19 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetDevicesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -440,6 +464,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getServerIdentity",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -456,14 +481,16 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -474,9 +501,11 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -484,11 +513,10 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetServerIdentityResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -502,7 +530,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetServerIdentityResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -510,7 +538,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -520,17 +548,19 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetServerIdentityResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -542,6 +572,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getMyPlexAccount",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -558,14 +589,16 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -576,9 +609,11 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -586,11 +621,10 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetMyPlexAccountResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -604,7 +638,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetMyPlexAccountResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -612,7 +646,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -622,17 +656,19 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetMyPlexAccountResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -644,6 +680,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getResizedPhoto",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -664,14 +701,16 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -682,9 +721,11 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -692,11 +733,10 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetResizedPhotoResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -717,17 +757,19 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetResizedPhotoResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -739,6 +781,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getServerList",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -755,14 +798,16 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -773,9 +818,11 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -783,11 +830,10 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetServerListResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -801,7 +847,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetServerListResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -809,7 +855,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -819,17 +865,19 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetServerListResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -32,6 +32,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getSessions",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -48,14 +49,16 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -66,9 +69,11 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -76,11 +81,10 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetSessionsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -94,7 +98,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetSessionsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -102,7 +106,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -112,17 +116,19 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetSessionsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -134,6 +140,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getSessionHistory",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -150,14 +157,16 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -168,9 +177,11 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -178,11 +189,10 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetSessionHistoryResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -196,7 +206,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetSessionHistoryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -204,7 +214,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -214,17 +224,19 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetSessionHistoryResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -236,6 +248,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getTranscodeSessions",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -252,14 +265,16 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -270,9 +285,11 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -280,11 +297,10 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetTranscodeSessionsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -298,7 +314,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetTranscodeSessionsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -306,7 +322,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -316,17 +332,19 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetTranscodeSessionsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -338,6 +356,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "stopTranscodeSession",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -358,14 +377,16 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -376,9 +397,11 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -386,11 +409,10 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StopTranscodeSessionResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -411,17 +433,19 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StopTranscodeSessionResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -32,6 +32,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getStatistics",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -56,14 +57,16 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -74,9 +77,11 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -84,11 +89,10 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetStatisticsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -102,7 +106,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetStatisticsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -110,7 +114,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -120,17 +124,19 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetStatisticsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -33,6 +33,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getUpdateStatus",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -49,14 +50,16 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -67,9 +70,11 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -77,11 +82,10 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetUpdateStatusResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -95,7 +99,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out operations.GetUpdateStatusResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
@@ -103,7 +107,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
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:
fallthrough
@@ -113,17 +117,19 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetUpdateStatusResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -135,6 +141,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "checkForUpdates",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -159,14 +166,16 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -177,9 +186,11 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -187,11 +198,10 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.CheckForUpdatesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -212,17 +222,19 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.CheckForUpdatesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -234,6 +246,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "applyUpdates",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -259,14 +272,16 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -277,9 +292,11 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "500", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -287,11 +304,10 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.ApplyUpdatesResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -314,17 +330,19 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.ApplyUpdatesResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil

View File

@@ -32,6 +32,7 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "getTimeline",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -52,14 +53,16 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -70,9 +73,11 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -80,11 +85,10 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetTimelineResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -105,17 +109,19 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.GetTimelineResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
@@ -127,6 +133,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
hookCtx := hooks.HookContext{
Context: ctx,
OperationID: "startUniversalTranscode",
OAuth2Scopes: []string{},
SecuritySource: s.sdkConfiguration.Security,
}
@@ -147,14 +154,16 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
return nil, err
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil {
return nil, err
}
httpRes, err := client.Do(req)
httpRes, err := s.sdkConfiguration.Client.Do(req)
if err != nil || httpRes == nil {
if err != nil {
err = fmt.Errorf("error sending request: %w", err)
@@ -165,9 +174,11 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) {
httpRes, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil)
_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)
@@ -175,11 +186,10 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
return nil, err
}
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StartUniversalTranscodeResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
ContentType: httpRes.Header.Get("Content-Type"),
RawResponse: httpRes,
}
@@ -200,17 +210,19 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
var out sdkerrors.StartUniversalTranscodeResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
}
default:
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil