Compare commits

..

21 Commits

Author SHA1 Message Date
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
52 changed files with 2751 additions and 294 deletions

View File

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

View File

@@ -1,12 +1,12 @@
lockVersion: 2.0.0 lockVersion: 2.0.0
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3 id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
management: management:
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae docChecksum: 7a43cd3413d535205cfaee20a4b6a250
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: 1.235.0 speakeasyVersion: 1.277.8
generationVersion: 2.298.0 generationVersion: 2.319.10
releaseVersion: 0.6.1 releaseVersion: 0.6.6
configChecksum: d8f185571a23470089a80d835fcabcbb configChecksum: f8398b860184344aa6c067b6ffd710a4
repoURL: https://github.com/LukeHagar/plexgo.git repoURL: https://github.com/LukeHagar/plexgo.git
repoSubDirectory: . repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexgo installationURL: https://github.com/LukeHagar/plexgo
@@ -14,11 +14,11 @@ management:
features: features:
go: go:
constsAndDefaults: 0.1.4 constsAndDefaults: 0.1.4
core: 3.4.5 core: 3.4.7
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.82.9 globalSecurity: 2.82.9
globalServerURLs: 2.82.2 globalServerURLs: 2.82.2
globals: 2.82.1 globals: 2.82.2
methodServerURLs: 2.82.1 methodServerURLs: 2.82.1
nameOverrides: 2.81.2 nameOverrides: 2.81.2
responseFormat: 0.1.0 responseFormat: 0.1.0
@@ -56,6 +56,7 @@ generatedFiles:
- internal/utils/retries.go - internal/utils/retries.go
- internal/utils/security.go - internal/utils/security.go
- internal/utils/utils.go - internal/utils/utils.go
- internal/globals/globals.go
- /models/operations/getservercapabilities.go - /models/operations/getservercapabilities.go
- /models/operations/getserverpreferences.go - /models/operations/getserverpreferences.go
- /models/operations/getavailableclients.go - /models/operations/getavailableclients.go
@@ -362,10 +363,12 @@ generatedFiles:
- docs/models/operations/loglineresponse.md - docs/models/operations/loglineresponse.md
- docs/models/operations/logmultilineresponse.md - docs/models/operations/logmultilineresponse.md
- docs/models/operations/enablepapertrailresponse.md - docs/models/operations/enablepapertrailresponse.md
- docs/models/operations/getpinglobals.md
- docs/models/operations/getpinrequest.md - docs/models/operations/getpinrequest.md
- docs/models/operations/location.md - docs/models/operations/location.md
- docs/models/operations/getpinresponsebody.md - docs/models/operations/getpinresponsebody.md
- docs/models/operations/getpinresponse.md - docs/models/operations/getpinresponse.md
- docs/models/operations/gettokenglobals.md
- docs/models/operations/gettokenrequest.md - docs/models/operations/gettokenrequest.md
- docs/models/operations/gettokenresponse.md - docs/models/operations/gettokenresponse.md
- docs/models/operations/queryparamtype.md - docs/models/operations/queryparamtype.md

View File

@@ -6,13 +6,13 @@ generation:
optionalPropertyRendering: withExample optionalPropertyRendering: withExample
useClassNamesForArrayFields: true useClassNamesForArrayFields: true
fixes: fixes:
nameResolutionDec2023: false nameResolutionDec2023: true
parameterOrderingFeb2024: false parameterOrderingFeb2024: true
requestResponseComponentNamesFeb2024: false requestResponseComponentNamesFeb2024: true
auth: auth:
oAuth2ClientCredentialsEnabled: false oAuth2ClientCredentialsEnabled: true
go: go:
version: 0.6.1 version: 0.6.6
additionalDependencies: {} additionalDependencies: {}
clientServerStatusCodesAsErrors: true clientServerStatusCodesAsErrors: true
flattenGlobalSecurity: true flattenGlobalSecurity: true

16
.speakeasy/workflow.lock Normal file
View File

@@ -0,0 +1,16 @@
speakeasyVersion: 1.277.8
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

@@ -33,7 +33,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -185,7 +185,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -236,7 +236,7 @@ func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithServerIndex(0), plexgo.WithServerIndex(0),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -275,7 +275,7 @@ func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithServerURL("{protocol}://{ip}:{port}"), plexgo.WithServerURL("{protocol}://{ip}:{port}"),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -304,12 +304,12 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
var strong *bool = plexgo.Bool(false) var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>") var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), strong, xPlexClientIdentifier) res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), strong, xPlexClientIdentifier)
@@ -377,7 +377,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -424,7 +424,7 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on
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. 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 `"<value>"` 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. 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 ### Available Globals
@@ -452,12 +452,12 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
var strong *bool = plexgo.Bool(false) var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>") var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier) res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)

View File

@@ -219,3 +219,127 @@ Based on:
- [go v0.6.1] . - [go v0.6.1] .
### Releases ### Releases
- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - . - [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 - .

View File

@@ -12,7 +12,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -75,9 +75,11 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -153,7 +155,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -185,9 +187,11 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -54,7 +54,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -78,9 +78,11 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -158,7 +160,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -182,9 +184,11 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -69,9 +69,11 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -179,9 +181,11 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -274,9 +278,11 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -345,7 +351,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -377,9 +383,11 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -446,7 +454,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -478,9 +486,11 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "404", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

2010
codeSamples.yaml Normal file

File diff suppressed because it is too large Load Diff

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 ## Fields
| Field | Type | Required | Description | | 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/> | | `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/> | | `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

@@ -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 ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `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/> | | `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

@@ -36,7 +36,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -84,7 +84,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -32,7 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -89,7 +89,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -33,7 +33,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -86,7 +86,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -135,7 +135,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -189,7 +189,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -243,7 +243,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -31,7 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -88,7 +88,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -39,7 +39,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -95,7 +95,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -149,7 +149,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -237,7 +237,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -292,7 +292,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -365,7 +365,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -420,7 +420,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -491,7 +491,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -546,7 +546,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -599,7 +599,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -652,7 +652,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -33,7 +33,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -112,7 +112,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -164,7 +164,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -31,7 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -83,7 +83,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -136,7 +136,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -44,7 +44,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -99,7 +99,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -156,7 +156,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -209,7 +209,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -262,7 +262,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -324,7 +324,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -380,7 +380,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -434,7 +434,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -494,7 +494,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -28,13 +28,13 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
var strong *bool = plexgo.Bool(false) var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>") var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier) res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
@@ -49,12 +49,12 @@ func main() {
### Parameters ### Parameters
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `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/> | | `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/> | | `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. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response ### Response
@@ -82,13 +82,13 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
var pinID string = "<value>" var pinID string = "<value>"
var xPlexClientIdentifier *string = plexgo.String("<value>") var xPlexClientIdentifier *string = plexgo.String("Postman")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier) res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
@@ -103,12 +103,12 @@ func main() {
### Parameters ### Parameters
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `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 | | `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/> | | `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. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response ### Response

View File

@@ -43,7 +43,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -105,7 +105,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -163,7 +163,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -36,7 +36,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -84,7 +84,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -132,7 +132,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -180,7 +180,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -228,7 +228,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -276,7 +276,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -326,7 +326,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -383,7 +383,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -32,7 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -80,7 +80,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -128,7 +128,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -176,7 +176,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -29,7 +29,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -32,7 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -81,7 +81,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
@@ -135,7 +135,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )

View File

@@ -31,7 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()
@@ -92,7 +92,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"), plexgo.WithXPlexClientIdentifier("Postman"),
) )
ctx := context.Background() ctx := context.Background()

14
hubs.go
View File

@@ -54,7 +54,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -78,9 +78,11 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -158,7 +160,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -170,7 +172,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -194,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

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

@@ -10,15 +10,34 @@ import (
"strings" "strings"
) )
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}, globals map[string]map[string]map[string]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) headerParamsStructType := reflect.TypeOf(headers)
headerParamsValType := reflect.ValueOf(headers) headerParamsValType := reflect.ValueOf(headers)
globalsAlreadyPopulated := []string{}
for i := 0; i < headerParamsStructType.NumField(); i++ { for i := 0; i < headerParamsStructType.NumField(); i++ {
fieldType := headerParamsStructType.Field(i) fieldType := headerParamsStructType.Field(i)
valType := headerParamsValType.Field(i) valType := headerParamsValType.Field(i)
valType = populateFromGlobals(fieldType, valType, "header", globals) 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) tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
if tag == nil { if tag == nil {
@@ -27,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
value := serializeHeader(fieldType.Type, valType, tag.Explode) value := serializeHeader(fieldType.Type, valType, tag.Explode)
if value != "" { 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 { func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {

View File

@@ -16,18 +16,41 @@ import (
"github.com/LukeHagar/plexgo/types" "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 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) pathParamsStructType := reflect.TypeOf(pathParams)
pathParamsValType := reflect.ValueOf(pathParams) pathParamsValType := reflect.ValueOf(pathParams)
parsedParameters := map[string]string{} globalsAlreadyPopulated := []string{}
for i := 0; i < pathParamsStructType.NumField(); i++ { for i := 0; i < pathParamsStructType.NumField(); i++ {
fieldType := pathParamsStructType.Field(i) fieldType := pathParamsStructType.Field(i)
valType := pathParamsValType.Field(i) valType := pathParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
requestTag := getRequestTag(fieldType) requestTag := getRequestTag(fieldType)
if requestTag != nil { if requestTag != nil {
continue continue
@@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
continue 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 != "" { if ppTag.Serialization != "" {
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
if err != nil { if err != nil {
return "", err return nil, err
} }
for k, v := range vals { for k, v := range vals {
parsedParameters[k] = url.PathEscape(v) parsedParameters[k] = url.PathEscape(v)
@@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
// TODO: support other styles // TODO: support other styles
switch ppTag.Style { switch ppTag.Style {
case "simple": 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 { for k, v := range simpleParams {
parsedParameters[k] = v 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 globalsAlreadyPopulated, nil
return ReplaceParameters(uri, parsedParameters), 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) pathParams := make(map[string]string)
if isNil(objType, objValue) { if isNil(objType, objValue) {

View File

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

View File

@@ -25,8 +25,8 @@ var (
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) 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) { func SerializeRequestBody(_ 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) bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag)
if err != nil { if err != nil {
return nil, "", fmt.Errorf("error serializing request body: %w", err) 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 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) requestStructType := reflect.TypeOf(request)
requestValType := reflect.ValueOf(request) requestValType := reflect.ValueOf(request)

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 { func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) {
if globals != nil && fieldType.Type.Kind() == reflect.Ptr { if globals == nil {
parameters, ok := globals["parameters"] return fieldType, valType, false
if ok { }
paramsOfType, ok := parameters[paramType]
if ok { globalsStruct := reflect.TypeOf(globals)
globalVal, ok := paramsOfType[fieldType.Name] globalsStructVal := reflect.ValueOf(globals)
if ok {
if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() { globalsField, found := globalsStruct.FieldByName(fieldType.Name)
valType = reflect.ValueOf(&globalVal) 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 { func isNil(typ reflect.Type, val reflect.Value) bool {
@@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool {
return false return false
} }
func contains(arr []string, str string) bool {
for _, a := range arr {
if a == str {
return true
}
}
return false
}

View File

@@ -54,7 +54,7 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -78,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -173,9 +175,11 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -284,9 +288,11 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -401,7 +407,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -413,7 +419,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -437,9 +443,11 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -515,7 +523,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -547,9 +555,11 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -634,7 +644,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -666,9 +676,11 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -729,7 +741,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -761,9 +773,11 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -846,7 +860,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -858,7 +872,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -882,9 +896,11 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -945,7 +961,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -977,9 +993,11 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -1055,7 +1073,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -1087,9 +1105,11 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -1193,9 +1213,11 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

14
log.go
View File

@@ -55,7 +55,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -79,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -200,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -295,9 +299,11 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "403", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -53,7 +53,7 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -77,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -156,7 +158,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -180,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -261,7 +265,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -285,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -12,6 +12,21 @@ var GetPinServerList = []string{
"https://plex.tv/api/v2", "https://plex.tv/api/v2",
} }
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 { type GetPinRequest struct {
// Determines the kind of code returned by the API call // Determines the kind of code returned by the API call
// Strong codes are used for Pin authentication flows // Strong codes are used for Pin authentication flows

View File

@@ -10,6 +10,21 @@ var GetTokenServerList = []string{
"https://plex.tv/api/v2", "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 { type GetTokenRequest struct {
// The PinID to retrieve an access token for // The PinID to retrieve an access token for
PinID string `pathParam:"style=simple,explode=false,name=pinID"` PinID string `pathParam:"style=simple,explode=false,name=pinID"`

View File

@@ -54,7 +54,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -78,9 +78,11 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -169,7 +171,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -193,9 +195,11 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -272,7 +276,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -304,9 +308,11 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -382,7 +388,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -414,9 +420,11 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -483,7 +491,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -495,7 +503,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -519,9 +527,11 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -590,7 +600,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -602,7 +612,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -626,9 +636,11 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -704,7 +716,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -736,9 +748,11 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -806,7 +820,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -818,7 +832,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -842,9 +856,11 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -933,7 +949,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -957,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

31
plex.go
View File

@@ -12,7 +12,6 @@ import (
"github.com/LukeHagar/plexgo/models/sdkerrors" "github.com/LukeHagar/plexgo/models/sdkerrors"
"io" "io"
"net/http" "net/http"
"net/url"
) )
// Plex - API Calls that perform operations directly against https://Plex.tv // Plex - API Calls that perform operations directly against https://Plex.tv
@@ -41,6 +40,10 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
XPlexClientIdentifier: xPlexClientIdentifier, XPlexClientIdentifier: xPlexClientIdentifier,
} }
globals := operations.GetPinGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
}
o := operations.Options{} o := operations.Options{}
supportedOptions := []string{ supportedOptions := []string{
operations.SupportedOptionServerURL, operations.SupportedOptionServerURL,
@@ -56,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
baseURL = *o.ServerURL baseURL = *o.ServerURL
} }
opURL, err := url.JoinPath(baseURL, "/pins") opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -68,9 +71,9 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals) utils.PopulateHeaders(ctx, req, request, globals)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -90,9 +93,11 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -166,6 +171,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
XPlexClientIdentifier: xPlexClientIdentifier, XPlexClientIdentifier: xPlexClientIdentifier,
} }
globals := operations.GetTokenGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
}
o := operations.Options{} o := operations.Options{}
supportedOptions := []string{ supportedOptions := []string{
operations.SupportedOptionServerURL, operations.SupportedOptionServerURL,
@@ -181,7 +190,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
baseURL = *o.ServerURL baseURL = *o.ServerURL
} }
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -193,7 +202,11 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals) utils.PopulateHeaders(ctx, req, request, globals)
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) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil { if err != nil {
@@ -211,9 +224,11 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -6,6 +6,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/LukeHagar/plexgo/internal/globals"
"github.com/LukeHagar/plexgo/internal/hooks" "github.com/LukeHagar/plexgo/internal/hooks"
"github.com/LukeHagar/plexgo/internal/utils" "github.com/LukeHagar/plexgo/internal/utils"
"github.com/LukeHagar/plexgo/models/components" "github.com/LukeHagar/plexgo/models/components"
@@ -53,7 +54,7 @@ type sdkConfiguration struct {
SDKVersion string SDKVersion string
GenVersion string GenVersion string
UserAgent string UserAgent string
Globals map[string]map[string]map[string]interface{} Globals globals.Globals
RetryConfig *utils.RetryConfig RetryConfig *utils.RetryConfig
Hooks *hooks.Hooks Hooks *hooks.Hooks
} }
@@ -259,11 +260,7 @@ func WithSecuritySource(security func(context.Context) (components.Security, err
// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations // WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations
func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption { func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption {
return func(sdk *PlexAPI) { return func(sdk *PlexAPI) {
if _, ok := sdk.sdkConfiguration.Globals["parameters"]["header"]; !ok { sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier
sdk.sdkConfiguration.Globals["parameters"]["header"] = map[string]interface{}{}
}
sdk.sdkConfiguration.Globals["parameters"]["header"]["XPlexClientIdentifier"] = xPlexClientIdentifier
} }
} }
@@ -279,12 +276,10 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{ sdkConfiguration: sdkConfiguration{
Language: "go", Language: "go",
OpenAPIDocVersion: "0.0.3", OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.6.1", SDKVersion: "0.6.6",
GenVersion: "2.298.0", GenVersion: "2.319.10",
UserAgent: "speakeasy-sdk/go 0.6.1 2.298.0 0.0.3 github.com/LukeHagar/plexgo", UserAgent: "speakeasy-sdk/go 0.6.6 2.319.10 0.0.3 github.com/LukeHagar/plexgo",
Globals: map[string]map[string]map[string]interface{}{ Globals: globals.Globals{},
"parameters": {},
},
ServerDefaults: []map[string]string{ ServerDefaults: []map[string]string{
{ {
"protocol": "http", "protocol": "http",

View File

@@ -67,7 +67,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -91,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) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -175,7 +177,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -199,9 +201,11 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -278,7 +282,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -302,9 +306,11 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -69,9 +69,11 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -175,9 +177,11 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -281,9 +285,11 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -387,9 +393,11 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -493,9 +501,11 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -599,9 +609,11 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -685,7 +697,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -709,9 +721,11 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -804,9 +818,11 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -69,9 +69,11 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -175,9 +177,11 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -281,9 +285,11 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -359,7 +365,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
} }
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, s.sdkConfiguration.Globals) opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -391,9 +397,11 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -53,7 +53,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -77,9 +77,11 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -70,9 +70,11 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -160,7 +162,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -184,9 +186,11 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -264,7 +268,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -288,9 +292,11 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "500", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)

View File

@@ -49,7 +49,7 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -73,9 +73,11 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)
@@ -148,7 +150,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -172,9 +174,11 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err)
return nil, err return nil, err
} else if utils.MatchStatusCodes([]string{"400", "401", "4XX", "5XX"}, httpRes.StatusCode) { } 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 { if err != nil {
return nil, err return nil, err
} else if _httpRes != nil {
httpRes = _httpRes
} }
} else { } else {
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes)