mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a382342e4 | ||
|
|
b8b984dc14 | ||
|
|
0de5991239 | ||
|
|
0ff88615e0 | ||
|
|
0eb6f2c692 | ||
|
|
0adacc0e13 | ||
|
|
ec6ef7db64 | ||
|
|
32a5beaae6 | ||
|
|
ea30334a95 | ||
|
|
f3eb760757 | ||
|
|
683823eab9 | ||
|
|
6942d6b905 | ||
|
|
1a7051235f | ||
|
|
68fedfa8fc | ||
|
|
5916d2ace5 | ||
|
|
417454ebb2 | ||
|
|
992291fe20 | ||
|
|
515f318f05 | ||
|
|
8b81bc5692 |
@@ -1,25 +1,27 @@
|
||||
lockVersion: 2.0.0
|
||||
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
|
||||
management:
|
||||
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
||||
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
|
||||
docVersion: 0.0.3
|
||||
speakeasyVersion: internal
|
||||
generationVersion: 2.272.7
|
||||
releaseVersion: 0.4.2
|
||||
configChecksum: e5a25a1a8f81b1393579b0112a09b581
|
||||
speakeasyVersion: 1.245.0
|
||||
generationVersion: 2.301.3
|
||||
releaseVersion: 0.6.3
|
||||
configChecksum: 305403acfb42fec7c8e5f2903b30cf41
|
||||
repoURL: https://github.com/LukeHagar/plexgo.git
|
||||
repoSubDirectory: .
|
||||
installationURL: https://github.com/LukeHagar/plexgo
|
||||
published: true
|
||||
features:
|
||||
go:
|
||||
constsAndDefaults: 0.1.3
|
||||
core: 3.4.3
|
||||
constsAndDefaults: 0.1.4
|
||||
core: 3.4.6
|
||||
flattening: 2.81.1
|
||||
globalSecurity: 2.82.8
|
||||
globalServerURLs: 2.82.1
|
||||
globalSecurity: 2.82.9
|
||||
globalServerURLs: 2.82.2
|
||||
globals: 2.82.2
|
||||
methodServerURLs: 2.82.1
|
||||
nameOverrides: 2.81.1
|
||||
nameOverrides: 2.81.2
|
||||
responseFormat: 0.1.0
|
||||
generatedFiles:
|
||||
- server.go
|
||||
- media.go
|
||||
@@ -54,6 +56,7 @@ generatedFiles:
|
||||
- internal/utils/retries.go
|
||||
- internal/utils/security.go
|
||||
- internal/utils/utils.go
|
||||
- internal/globals/globals.go
|
||||
- /models/operations/getservercapabilities.go
|
||||
- /models/operations/getserverpreferences.go
|
||||
- /models/operations/getavailableclients.go
|
||||
@@ -360,10 +363,12 @@ generatedFiles:
|
||||
- docs/models/operations/loglineresponse.md
|
||||
- docs/models/operations/logmultilineresponse.md
|
||||
- docs/models/operations/enablepapertrailresponse.md
|
||||
- docs/models/operations/getpinglobals.md
|
||||
- docs/models/operations/getpinrequest.md
|
||||
- docs/models/operations/location.md
|
||||
- docs/models/operations/getpinresponsebody.md
|
||||
- docs/models/operations/getpinresponse.md
|
||||
- docs/models/operations/gettokenglobals.md
|
||||
- docs/models/operations/gettokenrequest.md
|
||||
- docs/models/operations/gettokenresponse.md
|
||||
- docs/models/operations/queryparamtype.md
|
||||
|
||||
22
LICENSE.md
22
LICENSE.md
@@ -1,21 +1,7 @@
|
||||
MIT License
|
||||
Copyright 2024 Luke Hagar
|
||||
|
||||
Copyright (c) 2023 LukeHagar
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
73
README.md
73
README.md
@@ -33,6 +33,7 @@ import (
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -40,7 +41,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -185,6 +185,7 @@ import (
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -235,6 +236,7 @@ func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithServerIndex(0),
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -242,7 +244,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -274,6 +275,7 @@ func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithServerURL("{protocol}://{ip}:{port}"),
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -281,7 +283,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -302,18 +303,19 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New()
|
||||
|
||||
var xPlexClientIdentifier string = "<value>"
|
||||
s := plexgo.New(
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
var strong *bool = plexgo.Bool(false)
|
||||
|
||||
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||
|
||||
ctx := context.Background()
|
||||
res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), xPlexClientIdentifier, strong)
|
||||
res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), strong, xPlexClientIdentifier)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -375,6 +377,7 @@ import (
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -382,7 +385,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -417,6 +419,59 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on
|
||||
```
|
||||
<!-- End Special Types [types] -->
|
||||
|
||||
<!-- Start Global Parameters [global-parameters] -->
|
||||
## Global Parameters
|
||||
|
||||
A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
|
||||
|
||||
For example, you can set `X-Plex-Client-Identifier` to `"<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.
|
||||
|
||||
|
||||
### Available Globals
|
||||
|
||||
The following global parameter is available. The required parameter must be set when you initialize the SDK client.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
| ---- | ---- |:--------:| ----------- |
|
||||
| XPlexClientIdentifier | string | ✔️ | The unique identifier for the client application
|
||||
This is used to track the client application and its usage
|
||||
(UUID, serial number, or other number unique per device)
|
||||
|
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
var strong *bool = plexgo.Bool(false)
|
||||
|
||||
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||
|
||||
ctx := context.Background()
|
||||
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
<!-- End Global Parameters [global-parameters] -->
|
||||
|
||||
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
||||
|
||||
# Development
|
||||
|
||||
90
RELEASES.md
90
RELEASES.md
@@ -149,3 +149,93 @@ Based on:
|
||||
- [go v0.4.2] .
|
||||
### Releases
|
||||
- [Go v0.4.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.2 - .
|
||||
|
||||
## 2024-03-02 00:42:48
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.200.0 (2.277.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.4.3] .
|
||||
### Releases
|
||||
- [Go v0.4.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.3 - .
|
||||
|
||||
## 2024-03-08 00:43:49
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.204.1 (2.279.1) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.5.0] .
|
||||
### Releases
|
||||
- [Go v0.5.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.0 - .
|
||||
|
||||
## 2024-03-13 00:44:38
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.207.1 (2.280.6) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.5.1] .
|
||||
### Releases
|
||||
- [Go v0.5.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.1 - .
|
||||
|
||||
## 2024-03-20 00:43:42
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.213.0 (2.283.1) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.5.2] .
|
||||
### Releases
|
||||
- [Go v0.5.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.2 - .
|
||||
|
||||
## 2024-03-27 00:44:06
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.227.0 (2.291.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.5.3] .
|
||||
### Releases
|
||||
- [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - .
|
||||
|
||||
## 2024-03-29 16:37:06
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.228.1 (2.292.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.6.0] .
|
||||
### Releases
|
||||
- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - .
|
||||
|
||||
## 2024-04-03 00:44:02
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.235.0 (2.298.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.6.1] .
|
||||
### Releases
|
||||
- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - .
|
||||
|
||||
## 2024-04-09 00:44:53
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.244.0 (2.301.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.6.2] .
|
||||
### Releases
|
||||
- [Go v0.6.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.2 - .
|
||||
|
||||
## 2024-04-10 00:44:38
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.245.0 (2.301.3) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [go v0.6.3] .
|
||||
### Releases
|
||||
- [Go v0.6.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.3 - .
|
||||
2
USAGE.md
2
USAGE.md
@@ -12,6 +12,7 @@ import (
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -19,7 +20,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getServerActivities",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -54,14 +55,16 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -82,11 +85,10 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetServerActivitiesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetServerActivitiesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -108,7 +110,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -118,17 +120,19 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetServerActivitiesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -140,6 +144,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "cancelServerActivities",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -160,14 +165,16 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -188,11 +195,10 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.CancelServerActivitiesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -213,17 +219,19 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.CancelServerActivitiesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
@@ -32,6 +32,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getTransientToken",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -57,14 +58,16 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -85,11 +88,10 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetTransientTokenResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -110,17 +112,19 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetTransientTokenResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -133,6 +137,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getSourceConnectionInformation",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -157,14 +162,16 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -185,11 +192,10 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetSourceConnectionInformationResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -210,17 +216,19 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetSourceConnectionInformationResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
94
butler.go
94
butler.go
@@ -32,6 +32,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getButlerTasks",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -48,14 +49,16 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -76,11 +79,10 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetButlerTasksResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetButlerTasksResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -102,7 +104,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -112,17 +114,19 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetButlerTasksResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -138,6 +142,7 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "startAllTasks",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -154,14 +159,16 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -182,11 +189,10 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StartAllTasksResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -207,17 +213,19 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StartAllTasksResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -229,6 +237,7 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "stopAllTasks",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -245,14 +254,16 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -273,11 +284,10 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StopAllTasksResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -298,17 +308,19 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StopAllTasksResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -324,6 +336,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "startTask",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -344,14 +357,16 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -372,11 +387,10 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StartTaskResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -399,17 +413,19 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StartTaskResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -421,6 +437,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "stopTask",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -441,14 +458,16 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -469,11 +488,10 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StopTaskResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -496,17 +514,19 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StopTaskResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
8
docs/models/operations/getpinglobals.md
Normal file
8
docs/models/operations/getpinglobals.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# GetPinGlobals
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
|
||||
| `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/> |
|
||||
8
docs/models/operations/gettokenglobals.md
Normal file
8
docs/models/operations/gettokenglobals.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# GetTokenGlobals
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
@@ -6,4 +6,4 @@
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
||||
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
| `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/> |
|
||||
@@ -36,6 +36,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -43,7 +44,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -79,12 +79,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -85,12 +84,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -101,8 +100,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -40,7 +41,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -81,12 +81,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -94,8 +94,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -131,12 +130,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -144,8 +143,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -186,12 +184,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -202,8 +200,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -241,12 +238,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -257,8 +254,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -43,7 +44,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -88,6 +88,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -102,7 +103,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -96,6 +95,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -103,7 +103,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -150,6 +149,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -157,7 +157,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -238,6 +237,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -250,7 +250,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -288,12 +287,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -304,8 +303,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -367,6 +365,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -379,7 +378,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -417,12 +415,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -433,8 +431,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -494,6 +491,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -506,7 +504,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -549,6 +546,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -559,7 +557,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -602,6 +599,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -612,7 +610,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -655,6 +652,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -662,7 +660,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -108,12 +107,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -123,8 +122,7 @@ level=1&message=Test%20message%203&source=postman")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -161,12 +159,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -174,8 +172,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -79,12 +78,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -95,8 +94,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -133,12 +131,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -153,8 +151,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -56,7 +57,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -99,6 +99,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -111,7 +112,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -156,6 +156,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -166,7 +167,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -204,12 +204,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -220,8 +220,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -258,12 +257,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -278,8 +277,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -326,6 +324,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -338,7 +337,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -377,12 +375,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -393,8 +391,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -437,6 +434,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -451,7 +449,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -492,12 +489,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -510,8 +507,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,19 +27,20 @@ import(
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New()
|
||||
s := plexgo.New(
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
var xPlexClientIdentifier string = "<value>"
|
||||
|
||||
var strong *bool = plexgo.Bool(false)
|
||||
|
||||
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||
|
||||
ctx := context.Background()
|
||||
res, err := s.Plex.GetPin(ctx, xPlexClientIdentifier, strong)
|
||||
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -51,8 +52,8 @@ func main() {
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
|
||||
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
| `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
|
||||
| `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/> |
|
||||
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
|
||||
|
||||
|
||||
@@ -77,24 +78,24 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New()
|
||||
s := plexgo.New(
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
var pinID string = "<value>"
|
||||
|
||||
var xPlexClientIdentifier string = "<value>"
|
||||
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||
|
||||
ctx := context.Background()
|
||||
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ func main() {
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
|
||||
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
||||
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||
| `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/> |
|
||||
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
|
||||
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -58,8 +58,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -101,12 +100,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -121,8 +120,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -165,6 +163,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -175,7 +174,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -43,7 +44,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -84,6 +84,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -91,7 +92,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -132,6 +132,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -139,7 +140,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -180,6 +180,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -187,7 +188,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -228,6 +228,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -235,7 +236,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -276,6 +276,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -283,7 +284,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -321,29 +321,28 @@ import(
|
||||
"context"
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
res, err := s.Server.GetResizedPhoto(ctx, operations.GetResizedPhotoRequest{
|
||||
Width: 110,
|
||||
Height: 165,
|
||||
Opacity: 643869,
|
||||
Blur: 4000,
|
||||
MinSize: operations.MinSizeZero,
|
||||
Opacity: 100,
|
||||
Blur: 20,
|
||||
MinSize: operations.MinSizeOne,
|
||||
Upscale: operations.UpscaleZero,
|
||||
URL: "/library/metadata/49564/thumb/1654258204",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -384,6 +383,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -391,7 +391,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -39,7 +40,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -80,6 +80,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -87,7 +88,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -128,6 +128,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -135,7 +136,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -171,12 +171,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -187,8 +187,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -39,7 +40,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import(
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -39,7 +40,6 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.Object != nil {
|
||||
// handle response
|
||||
}
|
||||
@@ -76,12 +76,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -92,8 +92,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -131,12 +130,12 @@ import(
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
|
||||
@@ -149,8 +148,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import(
|
||||
"context"
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -50,8 +50,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
@@ -88,12 +87,12 @@ import(
|
||||
"context"
|
||||
"github.com/LukeHagar/plexgo/models/operations"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := plexgo.New(
|
||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -107,8 +106,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusOK {
|
||||
if res != nil {
|
||||
// handle response
|
||||
}
|
||||
}
|
||||
|
||||
3
gen.yaml
3
gen.yaml
@@ -12,7 +12,7 @@ generation:
|
||||
auth:
|
||||
oAuth2ClientCredentialsEnabled: false
|
||||
go:
|
||||
version: 0.4.2
|
||||
version: 0.6.3
|
||||
additionalDependencies: {}
|
||||
clientServerStatusCodesAsErrors: true
|
||||
flattenGlobalSecurity: true
|
||||
@@ -28,3 +28,4 @@ go:
|
||||
maxMethodParams: 4
|
||||
outputModelSuffix: output
|
||||
packageName: github.com/LukeHagar/plexgo
|
||||
responseFormat: envelope
|
||||
|
||||
44
hubs.go
44
hubs.go
@@ -32,6 +32,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getGlobalHubs",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -57,14 +58,16 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -85,11 +88,10 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetGlobalHubsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetGlobalHubsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -111,7 +113,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -121,17 +123,19 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetGlobalHubsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -143,6 +147,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getLibraryHubs",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -169,14 +174,16 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -197,11 +204,10 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetLibraryHubsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -215,7 +221,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetLibraryHubsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -223,7 +229,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -233,17 +239,19 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetLibraryHubsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
18
internal/globals/globals.go
Normal file
18
internal/globals/globals.go
Normal 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
|
||||
}
|
||||
@@ -78,6 +78,8 @@ func New() *Hooks {
|
||||
afterErrorHook: []afterErrorHook{},
|
||||
}
|
||||
|
||||
initHooks(h)
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,35 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}) {
|
||||
func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) {
|
||||
globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{})
|
||||
if globals != nil {
|
||||
_ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated)
|
||||
}
|
||||
}
|
||||
|
||||
func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string {
|
||||
headerParamsStructType := reflect.TypeOf(headers)
|
||||
headerParamsValType := reflect.ValueOf(headers)
|
||||
|
||||
globalsAlreadyPopulated := []string{}
|
||||
|
||||
for i := 0; i < headerParamsStructType.NumField(); i++ {
|
||||
fieldType := headerParamsStructType.Field(i)
|
||||
valType := headerParamsValType.Field(i)
|
||||
|
||||
if contains(skipFields, fieldType.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
if globals != nil {
|
||||
var globalFound bool
|
||||
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals)
|
||||
if globalFound {
|
||||
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||
}
|
||||
}
|
||||
|
||||
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
|
||||
if tag == nil {
|
||||
continue
|
||||
@@ -25,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
|
||||
|
||||
value := serializeHeader(fieldType.Type, valType, tag.Explode)
|
||||
if value != "" {
|
||||
req.Header.Add(tag.ParamName, value)
|
||||
reqHeaders.Add(tag.ParamName, value)
|
||||
}
|
||||
}
|
||||
|
||||
return globalsAlreadyPopulated
|
||||
}
|
||||
|
||||
func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {
|
||||
|
||||
@@ -16,18 +16,41 @@ import (
|
||||
"github.com/LukeHagar/plexgo/types"
|
||||
)
|
||||
|
||||
func GenerateURL(ctx context.Context, serverURL, path string, pathParams interface{}, globals map[string]map[string]map[string]interface{}) (string, error) {
|
||||
func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) {
|
||||
uri := strings.TrimSuffix(serverURL, "/") + path
|
||||
|
||||
parsedParameters := map[string]string{}
|
||||
|
||||
globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if globals != nil {
|
||||
_, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO should we handle the case where there are no matching path params?
|
||||
return ReplaceParameters(uri, parsedParameters), nil
|
||||
}
|
||||
|
||||
func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) {
|
||||
pathParamsStructType := reflect.TypeOf(pathParams)
|
||||
pathParamsValType := reflect.ValueOf(pathParams)
|
||||
|
||||
parsedParameters := map[string]string{}
|
||||
globalsAlreadyPopulated := []string{}
|
||||
|
||||
for i := 0; i < pathParamsStructType.NumField(); i++ {
|
||||
fieldType := pathParamsStructType.Field(i)
|
||||
valType := pathParamsValType.Field(i)
|
||||
|
||||
if contains(skipFields, fieldType.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
requestTag := getRequestTag(fieldType)
|
||||
if requestTag != nil {
|
||||
continue
|
||||
@@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
||||
continue
|
||||
}
|
||||
|
||||
valType = populateFromGlobals(fieldType, valType, "pathParam", globals)
|
||||
if globals != nil {
|
||||
var globalFound bool
|
||||
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals)
|
||||
if globalFound {
|
||||
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if ppTag.Serialization != "" {
|
||||
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range vals {
|
||||
parsedParameters[k] = url.PathEscape(v)
|
||||
@@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
||||
// TODO: support other styles
|
||||
switch ppTag.Style {
|
||||
case "simple":
|
||||
simpleParams := getSimplePathParams(ctx, ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
|
||||
simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
|
||||
for k, v := range simpleParams {
|
||||
parsedParameters[k] = v
|
||||
}
|
||||
@@ -60,11 +89,10 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
||||
}
|
||||
}
|
||||
|
||||
// TODO should we handle the case where there are no matching path params?
|
||||
return ReplaceParameters(uri, parsedParameters), nil
|
||||
return globalsAlreadyPopulated, nil
|
||||
}
|
||||
|
||||
func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
|
||||
func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
|
||||
pathParams := make(map[string]string)
|
||||
|
||||
if isNil(objType, objValue) {
|
||||
|
||||
@@ -11,16 +11,40 @@ import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams interface{}, globals map[string]map[string]map[string]interface{}) error {
|
||||
func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error {
|
||||
values := url.Values{}
|
||||
|
||||
globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if globals != nil {
|
||||
_, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
req.URL.RawQuery = values.Encode()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) {
|
||||
queryParamsStructType := reflect.TypeOf(queryParams)
|
||||
queryParamsValType := reflect.ValueOf(queryParams)
|
||||
|
||||
values := url.Values{}
|
||||
globalsAlreadyPopulated := []string{}
|
||||
|
||||
for i := 0; i < queryParamsStructType.NumField(); i++ {
|
||||
fieldType := queryParamsStructType.Field(i)
|
||||
valType := queryParamsValType.Field(i)
|
||||
|
||||
if contains(skipFields, fieldType.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
requestTag := getRequestTag(fieldType)
|
||||
if requestTag != nil {
|
||||
continue
|
||||
@@ -31,12 +55,18 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
|
||||
continue
|
||||
}
|
||||
|
||||
valType = populateFromGlobals(fieldType, valType, "queryParam", globals)
|
||||
if globals != nil {
|
||||
var globalFound bool
|
||||
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals)
|
||||
if globalFound {
|
||||
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if qpTag.Serialization != "" {
|
||||
vals, err := populateSerializedParams(qpTag, fieldType.Type, valType)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range vals {
|
||||
values.Add(k, v)
|
||||
@@ -44,35 +74,33 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
|
||||
} else {
|
||||
switch qpTag.Style {
|
||||
case "deepObject":
|
||||
vals := populateDeepObjectParams(req, qpTag, fieldType.Type, valType)
|
||||
vals := populateDeepObjectParams(qpTag, fieldType.Type, valType)
|
||||
for k, v := range vals {
|
||||
for _, vv := range v {
|
||||
values.Add(k, vv)
|
||||
}
|
||||
}
|
||||
case "form":
|
||||
vals := populateFormParams(req, qpTag, fieldType.Type, valType, ",")
|
||||
vals := populateFormParams(qpTag, fieldType.Type, valType, ",")
|
||||
for k, v := range vals {
|
||||
for _, vv := range v {
|
||||
values.Add(k, vv)
|
||||
}
|
||||
}
|
||||
case "pipeDelimited":
|
||||
vals := populateFormParams(req, qpTag, fieldType.Type, valType, "|")
|
||||
vals := populateFormParams(qpTag, fieldType.Type, valType, "|")
|
||||
for k, v := range vals {
|
||||
for _, vv := range v {
|
||||
values.Add(k, vv)
|
||||
}
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported style: %s", qpTag.Style)
|
||||
return nil, fmt.Errorf("unsupported style: %s", qpTag.Style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req.URL.RawQuery = values.Encode()
|
||||
|
||||
return nil
|
||||
return globalsAlreadyPopulated, nil
|
||||
}
|
||||
|
||||
func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) {
|
||||
@@ -98,7 +126,7 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
|
||||
func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
|
||||
values := url.Values{}
|
||||
|
||||
if isNil(objType, objValue) {
|
||||
@@ -155,7 +183,7 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.
|
||||
return values
|
||||
}
|
||||
|
||||
func populateFormParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
|
||||
func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
|
||||
return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string {
|
||||
qpTag := parseQueryParamTag(fieldType)
|
||||
if qpTag == nil {
|
||||
|
||||
@@ -25,8 +25,8 @@ var (
|
||||
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`)
|
||||
)
|
||||
|
||||
func SerializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||
bodyReader, contentType, err := serializeRequestBody(ctx, request, nullable, optional, requestFieldName, serializationMethod, tag)
|
||||
func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||
bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("error serializing request body: %w", err)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, nullable, op
|
||||
return bodyReader, contentType, nil
|
||||
}
|
||||
|
||||
func serializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||
func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||
requestStructType := reflect.TypeOf(request)
|
||||
requestValType := reflect.ValueOf(request)
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HTTPClient interface {
|
||||
Do(req *http.Request) (*http.Response, error)
|
||||
}
|
||||
|
||||
const (
|
||||
securityTagKey = "security"
|
||||
)
|
||||
@@ -27,73 +23,24 @@ type securityTag struct {
|
||||
SubType string
|
||||
}
|
||||
|
||||
type securityConfig struct {
|
||||
headers map[string]string
|
||||
queryParams map[string]string
|
||||
func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error {
|
||||
if securitySource == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
type SecurityClient struct {
|
||||
HTTPClient
|
||||
security func(ctx context.Context) (interface{}, error)
|
||||
}
|
||||
|
||||
func newSecurityClient(client HTTPClient, security func(ctx context.Context) (interface{}, error)) *SecurityClient {
|
||||
return &SecurityClient{
|
||||
HTTPClient: client,
|
||||
security: security,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SecurityClient) Do(req *http.Request) (*http.Response, error) {
|
||||
securityCtx, err := c.security(req.Context())
|
||||
security, err := securitySource(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
ctx := securityConfig{
|
||||
headers: make(map[string]string),
|
||||
queryParams: make(map[string]string),
|
||||
}
|
||||
parseSecurityStruct(&ctx, securityCtx)
|
||||
headers := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
|
||||
for k, v := range ctx.headers {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
|
||||
queryParams := req.URL.Query()
|
||||
|
||||
for k, v := range ctx.queryParams {
|
||||
queryParams.Add(k, v)
|
||||
}
|
||||
|
||||
req.URL.RawQuery = queryParams.Encode()
|
||||
|
||||
return c.HTTPClient.Do(req)
|
||||
}
|
||||
|
||||
func ConfigureSecurityClient(c HTTPClient, security func(ctx context.Context) (interface{}, error)) *SecurityClient {
|
||||
return newSecurityClient(c, security)
|
||||
}
|
||||
|
||||
func trueReflectValue(val reflect.Value) reflect.Value {
|
||||
kind := val.Type().Kind()
|
||||
for kind == reflect.Interface || kind == reflect.Ptr {
|
||||
innerVal := val.Elem()
|
||||
if !innerVal.IsValid() {
|
||||
break
|
||||
}
|
||||
val = innerVal
|
||||
kind = val.Type().Kind()
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func parseSecurityStruct(c *securityConfig, security interface{}) {
|
||||
securityValType := trueReflectValue(reflect.ValueOf(security))
|
||||
securityStructType := securityValType.Type()
|
||||
|
||||
if isNil(securityStructType, securityValType) {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
if securityStructType.Kind() == reflect.Ptr {
|
||||
@@ -118,20 +65,32 @@ func parseSecurityStruct(c *securityConfig, security interface{}) {
|
||||
secTag := parseSecurityTag(fieldType)
|
||||
if secTag != nil {
|
||||
if secTag.Option {
|
||||
handleSecurityOption(c, valType.Interface())
|
||||
handleSecurityOption(headers, queryParams, valType.Interface())
|
||||
} else if secTag.Scheme {
|
||||
// Special case for basic auth which could be a flattened struct
|
||||
if secTag.SubType == "basic" && kind != reflect.Struct {
|
||||
parseSecurityScheme(c, secTag, security)
|
||||
parseSecurityScheme(headers, queryParams, secTag, security)
|
||||
} else {
|
||||
parseSecurityScheme(c, secTag, valType.Interface())
|
||||
}
|
||||
parseSecurityScheme(headers, queryParams, secTag, valType.Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleSecurityOption(c *securityConfig, option interface{}) {
|
||||
for key, value := range headers {
|
||||
req.Header.Add(key, value)
|
||||
}
|
||||
|
||||
query := req.URL.Query()
|
||||
for key, value := range queryParams {
|
||||
query.Add(key, value)
|
||||
}
|
||||
req.URL.RawQuery = query.Encode()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleSecurityOption(headers, queryParams map[string]string, option interface{}) {
|
||||
optionValType := trueReflectValue(reflect.ValueOf(option))
|
||||
optionStructType := optionValType.Type()
|
||||
|
||||
@@ -145,12 +104,12 @@ func handleSecurityOption(c *securityConfig, option interface{}) {
|
||||
|
||||
secTag := parseSecurityTag(fieldType)
|
||||
if secTag != nil && secTag.Scheme {
|
||||
parseSecurityScheme(c, secTag, valType.Interface())
|
||||
parseSecurityScheme(headers, queryParams, secTag, valType.Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme interface{}) {
|
||||
func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *securityTag, scheme interface{}) {
|
||||
schemeVal := trueReflectValue(reflect.ValueOf(scheme))
|
||||
schemeType := schemeVal.Type()
|
||||
|
||||
@@ -160,7 +119,7 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
|
||||
|
||||
if schemeType.Kind() == reflect.Struct {
|
||||
if schemeTag.Type == "http" && schemeTag.SubType == "basic" {
|
||||
handleBasicAuthScheme(client, schemeVal.Interface())
|
||||
handleBasicAuthScheme(headers, schemeVal.Interface())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -181,36 +140,36 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
|
||||
return
|
||||
}
|
||||
|
||||
parseSecuritySchemeValue(client, schemeTag, secTag, valType.Interface())
|
||||
parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface())
|
||||
}
|
||||
} else {
|
||||
parseSecuritySchemeValue(client, schemeTag, schemeTag, schemeVal.Interface())
|
||||
parseSecuritySchemeValue(headers, queryParams, schemeTag, schemeTag, schemeVal.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
func parseSecuritySchemeValue(client *securityConfig, schemeTag *securityTag, secTag *securityTag, val interface{}) {
|
||||
func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag *securityTag, secTag *securityTag, val interface{}) {
|
||||
switch schemeTag.Type {
|
||||
case "apiKey":
|
||||
switch schemeTag.SubType {
|
||||
case "header":
|
||||
client.headers[secTag.Name] = valToString(val)
|
||||
headers[secTag.Name] = valToString(val)
|
||||
case "query":
|
||||
client.queryParams[secTag.Name] = valToString(val)
|
||||
queryParams[secTag.Name] = valToString(val)
|
||||
case "cookie":
|
||||
client.headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
|
||||
headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
|
||||
default:
|
||||
panic("not supported")
|
||||
}
|
||||
case "openIdConnect":
|
||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
case "oauth2":
|
||||
if schemeTag.SubType != "client_credentials" {
|
||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
}
|
||||
case "http":
|
||||
switch schemeTag.SubType {
|
||||
case "bearer":
|
||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||
default:
|
||||
panic("not supported")
|
||||
}
|
||||
@@ -227,7 +186,7 @@ func prefixBearer(authHeaderValue string) string {
|
||||
return fmt.Sprintf("Bearer %s", authHeaderValue)
|
||||
}
|
||||
|
||||
func handleBasicAuthScheme(client *securityConfig, scheme interface{}) {
|
||||
func handleBasicAuthScheme(headers map[string]string, scheme interface{}) {
|
||||
schemeStructType := reflect.TypeOf(scheme)
|
||||
schemeValType := reflect.ValueOf(scheme)
|
||||
|
||||
@@ -250,7 +209,7 @@ func handleBasicAuthScheme(client *securityConfig, scheme interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
client.headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password))))
|
||||
headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password))))
|
||||
}
|
||||
|
||||
func parseSecurityTag(field reflect.StructField) *securityTag {
|
||||
@@ -296,3 +255,16 @@ func parseSecurityTag(field reflect.StructField) *securityTag {
|
||||
SubType: securitySubType,
|
||||
}
|
||||
}
|
||||
|
||||
func trueReflectValue(val reflect.Value) reflect.Value {
|
||||
kind := val.Type().Kind()
|
||||
for kind == reflect.Interface || kind == reflect.Ptr {
|
||||
innerVal := val.Elem()
|
||||
if !innerVal.IsValid() {
|
||||
break
|
||||
}
|
||||
val = innerVal
|
||||
kind = val.Type().Kind()
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
@@ -158,23 +158,43 @@ func valToString(val interface{}) string {
|
||||
}
|
||||
}
|
||||
|
||||
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals map[string]map[string]map[string]interface{}) reflect.Value {
|
||||
if globals != nil && fieldType.Type.Kind() == reflect.Ptr {
|
||||
parameters, ok := globals["parameters"]
|
||||
if ok {
|
||||
paramsOfType, ok := parameters[paramType]
|
||||
if ok {
|
||||
globalVal, ok := paramsOfType[fieldType.Name]
|
||||
if ok {
|
||||
if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() {
|
||||
valType = reflect.ValueOf(&globalVal)
|
||||
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) {
|
||||
if globals == nil {
|
||||
return fieldType, valType, false
|
||||
}
|
||||
|
||||
globalsStruct := reflect.TypeOf(globals)
|
||||
globalsStructVal := reflect.ValueOf(globals)
|
||||
|
||||
globalsField, found := globalsStruct.FieldByName(fieldType.Name)
|
||||
if !found {
|
||||
return fieldType, valType, false
|
||||
}
|
||||
|
||||
if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() {
|
||||
return fieldType, valType, true
|
||||
}
|
||||
|
||||
globalsVal := globalsStructVal.FieldByName(fieldType.Name)
|
||||
|
||||
if !globalsVal.IsValid() {
|
||||
return fieldType, valType, false
|
||||
}
|
||||
|
||||
switch paramType {
|
||||
case queryParamTagKey:
|
||||
qpTag := parseQueryParamTag(globalsField)
|
||||
if qpTag == nil {
|
||||
return fieldType, valType, false
|
||||
}
|
||||
default:
|
||||
tag := parseParamTag(paramType, fieldType, "simple", false)
|
||||
if tag == nil {
|
||||
return fieldType, valType, false
|
||||
}
|
||||
}
|
||||
|
||||
return valType
|
||||
return globalsField, globalsVal, true
|
||||
}
|
||||
|
||||
func isNil(typ reflect.Type, val reflect.Value) bool {
|
||||
@@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func contains(arr []string, str string) bool {
|
||||
for _, a := range arr {
|
||||
if a == str {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
218
library.go
218
library.go
@@ -32,6 +32,7 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getFileHash",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -57,14 +58,16 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -85,11 +88,10 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetFileHashResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -110,17 +112,19 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetFileHashResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -132,6 +136,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getRecentlyAdded",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -148,14 +153,16 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -176,11 +183,10 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetRecentlyAddedResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -194,7 +200,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetRecentlyAddedResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -202,7 +208,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -212,17 +218,19 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetRecentlyAddedResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -239,6 +247,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getLibraries",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -255,14 +264,16 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -283,11 +294,10 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetLibrariesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -301,7 +311,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetLibrariesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -309,7 +319,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -319,17 +329,19 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetLibrariesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -379,6 +391,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getLibrary",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -404,14 +417,16 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -432,11 +447,10 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetLibraryResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -450,7 +464,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetLibraryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -458,7 +472,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -468,17 +482,19 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetLibraryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -490,6 +506,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "deleteLibrary",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -510,14 +527,16 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -538,11 +557,10 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.DeleteLibraryResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -563,17 +581,19 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.DeleteLibraryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -604,6 +624,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getLibraryItems",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -625,14 +646,16 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -653,11 +676,10 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetLibraryItemsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -671,7 +693,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetLibraryItemsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -679,12 +701,14 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||
fallthrough
|
||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -696,6 +720,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "refreshLibrary",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -716,14 +741,16 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -744,11 +771,10 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.RefreshLibraryResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -769,17 +795,19 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.RefreshLibraryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -808,6 +836,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "searchLibrary",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -833,14 +862,16 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -861,11 +892,10 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.SearchLibraryResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -879,7 +909,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.SearchLibraryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -887,12 +917,14 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||
fallthrough
|
||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -904,6 +936,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getMetadata",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -924,14 +957,16 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -952,11 +987,10 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetMetadataResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -970,7 +1004,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetMetadataResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -978,7 +1012,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -988,17 +1022,19 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetMetadataResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -1010,6 +1046,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getMetadataChildren",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -1030,14 +1067,16 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -1058,11 +1097,10 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetMetadataChildrenResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -1076,7 +1114,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetMetadataChildrenResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -1084,7 +1122,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -1094,17 +1132,19 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetMetadataChildrenResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -1116,6 +1156,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getOnDeck",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -1132,14 +1173,16 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -1160,11 +1203,10 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetOnDeckResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -1178,7 +1220,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetOnDeckResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -1186,7 +1228,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -1196,17 +1238,19 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetOnDeckResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
54
log.go
54
log.go
@@ -32,6 +32,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "logLine",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -58,14 +59,16 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -86,11 +89,10 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.LogLineResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -111,17 +113,19 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.LogLineResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -153,6 +157,7 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "logMultiLine",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -175,14 +180,16 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
req.Header.Set("Content-Type", reqContentType)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -203,11 +210,10 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.LogMultiLineResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -228,17 +234,19 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.LogMultiLineResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -250,6 +258,7 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "enablePaperTrail",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -266,14 +275,16 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -294,11 +305,10 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.EnablePaperTrailResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -321,17 +331,19 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.EnablePaperTrailResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
54
media.go
54
media.go
@@ -32,6 +32,7 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "markPlayed",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -56,14 +57,16 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -84,11 +87,10 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.MarkPlayedResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -109,17 +111,19 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.MarkPlayedResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -131,6 +135,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "markUnplayed",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -155,14 +160,16 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -183,11 +190,10 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.MarkUnplayedResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -208,17 +214,19 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.MarkUnplayedResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -230,6 +238,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "updatePlayProgress",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -256,14 +265,16 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -284,11 +295,10 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.UpdatePlayProgressResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -309,17 +319,19 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.UpdatePlayProgressResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
@@ -12,17 +12,32 @@ var GetPinServerList = []string{
|
||||
"https://plex.tv/api/v2",
|
||||
}
|
||||
|
||||
type GetPinRequest struct {
|
||||
type GetPinGlobals struct {
|
||||
// The unique identifier for the client application
|
||||
// This is used to track the client application and its usage
|
||||
// (UUID, serial number, or other number unique per device)
|
||||
//
|
||||
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||
}
|
||||
|
||||
func (o *GetPinGlobals) GetXPlexClientIdentifier() string {
|
||||
if o == nil {
|
||||
return ""
|
||||
}
|
||||
return o.XPlexClientIdentifier
|
||||
}
|
||||
|
||||
type GetPinRequest struct {
|
||||
// Determines the kind of code returned by the API call
|
||||
// Strong codes are used for Pin authentication flows
|
||||
// Non-Strong codes are used for `Plex.tv/link`
|
||||
//
|
||||
Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"`
|
||||
// The unique identifier for the client application
|
||||
// This is used to track the client application and its usage
|
||||
// (UUID, serial number, or other number unique per device)
|
||||
//
|
||||
XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||
}
|
||||
|
||||
func (g GetPinRequest) MarshalJSON() ([]byte, error) {
|
||||
@@ -36,13 +51,6 @@ func (g *GetPinRequest) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetPinRequest) GetXPlexClientIdentifier() string {
|
||||
if o == nil {
|
||||
return ""
|
||||
}
|
||||
return o.XPlexClientIdentifier
|
||||
}
|
||||
|
||||
func (o *GetPinRequest) GetStrong() *bool {
|
||||
if o == nil {
|
||||
return nil
|
||||
@@ -50,6 +58,13 @@ func (o *GetPinRequest) GetStrong() *bool {
|
||||
return o.Strong
|
||||
}
|
||||
|
||||
func (o *GetPinRequest) GetXPlexClientIdentifier() *string {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
return o.XPlexClientIdentifier
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
Code *string `json:"code,omitempty"`
|
||||
EuropeanUnionMember *bool `json:"european_union_member,omitempty"`
|
||||
|
||||
@@ -10,6 +10,21 @@ var GetTokenServerList = []string{
|
||||
"https://plex.tv/api/v2",
|
||||
}
|
||||
|
||||
type GetTokenGlobals struct {
|
||||
// The unique identifier for the client application
|
||||
// This is used to track the client application and its usage
|
||||
// (UUID, serial number, or other number unique per device)
|
||||
//
|
||||
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||
}
|
||||
|
||||
func (o *GetTokenGlobals) GetXPlexClientIdentifier() string {
|
||||
if o == nil {
|
||||
return ""
|
||||
}
|
||||
return o.XPlexClientIdentifier
|
||||
}
|
||||
|
||||
type GetTokenRequest struct {
|
||||
// The PinID to retrieve an access token for
|
||||
PinID string `pathParam:"style=simple,explode=false,name=pinID"`
|
||||
@@ -17,7 +32,7 @@ type GetTokenRequest struct {
|
||||
// This is used to track the client application and its usage
|
||||
// (UUID, serial number, or other number unique per device)
|
||||
//
|
||||
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||
XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||
}
|
||||
|
||||
func (o *GetTokenRequest) GetPinID() string {
|
||||
@@ -27,9 +42,9 @@ func (o *GetTokenRequest) GetPinID() string {
|
||||
return o.PinID
|
||||
}
|
||||
|
||||
func (o *GetTokenRequest) GetXPlexClientIdentifier() string {
|
||||
func (o *GetTokenRequest) GetXPlexClientIdentifier() *string {
|
||||
if o == nil {
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
return o.XPlexClientIdentifier
|
||||
}
|
||||
|
||||
182
playlists.go
182
playlists.go
@@ -37,6 +37,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "createPlaylist",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -57,14 +58,16 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -85,11 +88,10 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.CreatePlaylistResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.CreatePlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -111,7 +113,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -121,17 +123,19 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.CreatePlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -143,6 +147,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getPlaylists",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -168,14 +173,16 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -196,11 +203,10 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetPlaylistsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -214,7 +220,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetPlaylistsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -222,7 +228,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -232,17 +238,19 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetPlaylistsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -255,6 +263,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getPlaylist",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -275,14 +284,16 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -303,11 +314,10 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetPlaylistResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -321,7 +331,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetPlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -329,7 +339,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -339,17 +349,19 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetPlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -361,6 +373,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "deletePlaylist",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -381,14 +394,16 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -409,11 +424,10 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.DeletePlaylistResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -434,17 +448,19 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.DeletePlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -456,6 +472,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "updatePlaylist",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -482,14 +499,16 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -510,11 +529,10 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.UpdatePlaylistResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -535,17 +553,19 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.UpdatePlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -560,6 +580,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getPlaylistContents",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -585,14 +606,16 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -613,11 +636,10 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetPlaylistContentsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -631,7 +653,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetPlaylistContentsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -639,7 +661,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -649,17 +671,19 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetPlaylistContentsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -671,6 +695,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "clearPlaylistContents",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -691,14 +716,16 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -719,11 +746,10 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.ClearPlaylistContentsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -744,17 +770,19 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.ClearPlaylistContentsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -767,6 +795,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "addPlaylistContents",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -793,14 +822,16 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -821,11 +852,10 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.AddPlaylistContentsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -839,7 +869,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.AddPlaylistContentsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -847,7 +877,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -857,17 +887,19 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.AddPlaylistContentsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -879,6 +911,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "uploadPlaylist",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -904,14 +937,16 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -932,11 +967,10 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.UploadPlaylistResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -957,17 +991,19 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.UploadPlaylistResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
63
plex.go
63
plex.go
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/LukeHagar/plexgo/models/sdkerrors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// Plex - API Calls that perform operations directly against https://Plex.tv
|
||||
@@ -28,16 +27,21 @@ func newPlex(sdkConfig sdkConfiguration) *Plex {
|
||||
|
||||
// GetPin - Get a Pin
|
||||
// Retrieve a Pin from Plex.tv for authentication flows
|
||||
func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong *bool, opts ...operations.Option) (*operations.GetPinResponse, error) {
|
||||
func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetPinResponse, error) {
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getPin",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: nil,
|
||||
}
|
||||
|
||||
request := operations.GetPinRequest{
|
||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||
Strong: strong,
|
||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||
}
|
||||
|
||||
globals := operations.GetPinGlobals{
|
||||
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
|
||||
}
|
||||
|
||||
o := operations.Options{}
|
||||
@@ -55,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
baseURL = *o.ServerURL
|
||||
}
|
||||
|
||||
opURL, err := url.JoinPath(baseURL, "/pins")
|
||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||
}
|
||||
@@ -67,20 +71,18 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
utils.PopulateHeaders(ctx, req, request)
|
||||
utils.PopulateHeaders(ctx, req, request, globals)
|
||||
|
||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.DefaultClient
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -101,11 +103,10 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetPinResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetPinResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -127,25 +128,27 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetPinResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||
fallthrough
|
||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -153,10 +156,11 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
||||
|
||||
// GetToken - Get Access Token
|
||||
// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
||||
func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
|
||||
func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getToken",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: nil,
|
||||
}
|
||||
|
||||
@@ -165,6 +169,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||
}
|
||||
|
||||
globals := operations.GetTokenGlobals{
|
||||
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
|
||||
}
|
||||
|
||||
o := operations.Options{}
|
||||
supportedOptions := []string{
|
||||
operations.SupportedOptionServerURL,
|
||||
@@ -180,7 +188,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
||||
baseURL = *o.ServerURL
|
||||
}
|
||||
|
||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil)
|
||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||
}
|
||||
@@ -192,16 +200,18 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
utils.PopulateHeaders(ctx, req, request)
|
||||
utils.PopulateHeaders(ctx, req, request, globals)
|
||||
|
||||
client := s.sdkConfiguration.DefaultClient
|
||||
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -222,11 +232,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetTokenResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -241,21 +250,23 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
||||
case httpRes.StatusCode == 200:
|
||||
case httpRes.StatusCode == 400:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetTokenResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||
fallthrough
|
||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
35
plexapi.go
35
plexapi.go
@@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/LukeHagar/plexgo/internal/globals"
|
||||
"github.com/LukeHagar/plexgo/internal/hooks"
|
||||
"github.com/LukeHagar/plexgo/internal/utils"
|
||||
"github.com/LukeHagar/plexgo/models/components"
|
||||
@@ -43,8 +44,7 @@ func Float32(f float32) *float32 { return &f }
|
||||
func Float64(f float64) *float64 { return &f }
|
||||
|
||||
type sdkConfiguration struct {
|
||||
DefaultClient HTTPClient
|
||||
SecurityClient HTTPClient
|
||||
Client HTTPClient
|
||||
Security func(context.Context) (interface{}, error)
|
||||
ServerURL string
|
||||
ServerIndex int
|
||||
@@ -54,6 +54,7 @@ type sdkConfiguration struct {
|
||||
SDKVersion string
|
||||
GenVersion string
|
||||
UserAgent string
|
||||
Globals globals.Globals
|
||||
RetryConfig *utils.RetryConfig
|
||||
Hooks *hooks.Hooks
|
||||
}
|
||||
@@ -229,7 +230,7 @@ func WithPort(port string) SDKOption {
|
||||
// WithClient allows the overriding of the default HTTP client used by the SDK
|
||||
func WithClient(client HTTPClient) SDKOption {
|
||||
return func(sdk *PlexAPI) {
|
||||
sdk.sdkConfiguration.DefaultClient = client
|
||||
sdk.sdkConfiguration.Client = client
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +257,13 @@ func WithSecuritySource(security func(context.Context) (components.Security, err
|
||||
}
|
||||
}
|
||||
|
||||
// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations
|
||||
func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption {
|
||||
return func(sdk *PlexAPI) {
|
||||
sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier
|
||||
}
|
||||
}
|
||||
|
||||
func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption {
|
||||
return func(sdk *PlexAPI) {
|
||||
sdk.sdkConfiguration.RetryConfig = &retryConfig
|
||||
@@ -268,9 +276,10 @@ func New(opts ...SDKOption) *PlexAPI {
|
||||
sdkConfiguration: sdkConfiguration{
|
||||
Language: "go",
|
||||
OpenAPIDocVersion: "0.0.3",
|
||||
SDKVersion: "0.4.2",
|
||||
GenVersion: "2.272.7",
|
||||
UserAgent: "speakeasy-sdk/go 0.4.2 2.272.7 0.0.3 github.com/LukeHagar/plexgo",
|
||||
SDKVersion: "0.6.3",
|
||||
GenVersion: "2.301.3",
|
||||
UserAgent: "speakeasy-sdk/go 0.6.3 2.301.3 0.0.3 github.com/LukeHagar/plexgo",
|
||||
Globals: globals.Globals{},
|
||||
ServerDefaults: []map[string]string{
|
||||
{
|
||||
"protocol": "http",
|
||||
@@ -286,25 +295,17 @@ func New(opts ...SDKOption) *PlexAPI {
|
||||
}
|
||||
|
||||
// Use WithClient to override the default client if you would like to customize the timeout
|
||||
if sdk.sdkConfiguration.DefaultClient == nil {
|
||||
sdk.sdkConfiguration.DefaultClient = &http.Client{Timeout: 60 * time.Second}
|
||||
if sdk.sdkConfiguration.Client == nil {
|
||||
sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second}
|
||||
}
|
||||
|
||||
currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails()
|
||||
serverURL := currentServerURL
|
||||
serverURL, sdk.sdkConfiguration.DefaultClient = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.DefaultClient)
|
||||
serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client)
|
||||
if serverURL != currentServerURL {
|
||||
sdk.sdkConfiguration.ServerURL = serverURL
|
||||
}
|
||||
|
||||
if sdk.sdkConfiguration.SecurityClient == nil {
|
||||
if sdk.sdkConfiguration.Security != nil {
|
||||
sdk.sdkConfiguration.SecurityClient = utils.ConfigureSecurityClient(sdk.sdkConfiguration.DefaultClient, sdk.sdkConfiguration.Security)
|
||||
} else {
|
||||
sdk.sdkConfiguration.SecurityClient = sdk.sdkConfiguration.DefaultClient
|
||||
}
|
||||
}
|
||||
|
||||
sdk.Server = newServer(sdk.sdkConfiguration)
|
||||
|
||||
sdk.Media = newMedia(sdk.sdkConfiguration)
|
||||
|
||||
58
search.go
58
search.go
@@ -44,6 +44,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "performSearch",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -70,14 +71,16 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -98,11 +101,10 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.PerformSearchResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -123,17 +125,19 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.PerformSearchResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -148,6 +152,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "performVoiceSearch",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -174,14 +179,16 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -202,11 +209,10 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.PerformVoiceSearchResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -227,17 +233,19 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.PerformVoiceSearchResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -249,6 +257,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getSearchResults",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -273,14 +282,16 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -301,11 +312,10 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetSearchResultsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -319,7 +329,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetSearchResultsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -327,7 +337,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -337,17 +347,19 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetSearchResultsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
172
server.go
172
server.go
@@ -32,6 +32,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getServerCapabilities",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -48,14 +49,16 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -76,11 +79,10 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetServerCapabilitiesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetServerCapabilitiesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -102,7 +104,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -112,17 +114,19 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetServerCapabilitiesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -134,6 +138,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getServerPreferences",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -150,14 +155,16 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -178,11 +185,10 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetServerPreferencesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -196,7 +202,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetServerPreferencesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -204,7 +210,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -214,17 +220,19 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetServerPreferencesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -236,6 +244,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getAvailableClients",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -252,14 +261,16 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -280,11 +291,10 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetAvailableClientsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -298,7 +308,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetAvailableClientsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -306,7 +316,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -316,17 +326,19 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetAvailableClientsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -338,6 +350,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getDevices",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -354,14 +367,16 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -382,11 +397,10 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetDevicesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -400,7 +414,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetDevicesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -408,7 +422,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -418,17 +432,19 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetDevicesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -440,6 +456,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getServerIdentity",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -456,14 +473,16 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -484,11 +503,10 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetServerIdentityResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -502,7 +520,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetServerIdentityResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -510,7 +528,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -520,17 +538,19 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetServerIdentityResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -542,6 +562,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getMyPlexAccount",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -558,14 +579,16 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -586,11 +609,10 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetMyPlexAccountResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -604,7 +626,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetMyPlexAccountResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -612,7 +634,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -622,17 +644,19 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetMyPlexAccountResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -644,6 +668,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getResizedPhoto",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -664,14 +689,16 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -692,11 +719,10 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetResizedPhotoResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -717,17 +743,19 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetResizedPhotoResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -739,6 +767,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getServerList",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -755,14 +784,16 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -783,11 +814,10 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetServerListResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -801,7 +831,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetServerListResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -809,7 +839,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -819,17 +849,19 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetServerListResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
84
sessions.go
84
sessions.go
@@ -32,6 +32,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getSessions",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -48,14 +49,16 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -76,11 +79,10 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetSessionsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetSessionsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -102,7 +104,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -112,17 +114,19 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetSessionsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -134,6 +138,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getSessionHistory",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -150,14 +155,16 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -178,11 +185,10 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetSessionHistoryResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -196,7 +202,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetSessionHistoryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -204,7 +210,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -214,17 +220,19 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetSessionHistoryResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -236,6 +244,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getTranscodeSessions",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -252,14 +261,16 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -280,11 +291,10 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetTranscodeSessionsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -298,7 +308,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetTranscodeSessionsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -306,7 +316,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -316,17 +326,19 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetTranscodeSessionsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -338,6 +350,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "stopTranscodeSession",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -358,14 +371,16 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -386,11 +401,10 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StopTranscodeSessionResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -411,17 +425,19 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StopTranscodeSessionResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
@@ -32,6 +32,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getStatistics",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -56,14 +57,16 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -84,11 +87,10 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetStatisticsResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetStatisticsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -110,7 +112,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -120,17 +122,19 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetStatisticsResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
58
updater.go
58
updater.go
@@ -33,6 +33,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getUpdateStatus",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -49,14 +50,16 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -77,11 +80,10 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetUpdateStatusResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -95,7 +97,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
switch {
|
||||
case httpRes.StatusCode == 200:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out operations.GetUpdateStatusResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
@@ -103,7 +105,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
|
||||
res.Object = &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
case httpRes.StatusCode == 400:
|
||||
fallthrough
|
||||
@@ -113,17 +115,19 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetUpdateStatusResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -135,6 +139,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "checkForUpdates",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -159,14 +164,16 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -187,11 +194,10 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.CheckForUpdatesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -212,17 +218,19 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.CheckForUpdatesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -234,6 +242,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "applyUpdates",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -259,14 +268,16 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -287,11 +298,10 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.ApplyUpdatesResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -314,17 +324,19 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.ApplyUpdatesResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
36
video.go
36
video.go
@@ -32,6 +32,7 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "getTimeline",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -52,14 +53,16 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -80,11 +83,10 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.GetTimelineResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -105,17 +107,19 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.GetTimelineResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@@ -127,6 +131,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
||||
hookCtx := hooks.HookContext{
|
||||
Context: ctx,
|
||||
OperationID: "startUniversalTranscode",
|
||||
OAuth2Scopes: []string{},
|
||||
SecuritySource: s.sdkConfiguration.Security,
|
||||
}
|
||||
|
||||
@@ -147,14 +152,16 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||
}
|
||||
|
||||
client := s.sdkConfiguration.SecurityClient
|
||||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpRes, err := client.Do(req)
|
||||
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||
if err != nil || httpRes == nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending request: %w", err)
|
||||
@@ -175,11 +182,10 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
contentType := httpRes.Header.Get("Content-Type")
|
||||
|
||||
res := &operations.StartUniversalTranscodeResponse{
|
||||
StatusCode: httpRes.StatusCode,
|
||||
ContentType: contentType,
|
||||
ContentType: httpRes.Header.Get("Content-Type"),
|
||||
RawResponse: httpRes,
|
||||
}
|
||||
|
||||
@@ -200,17 +206,19 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
case httpRes.StatusCode == 401:
|
||||
switch {
|
||||
case utils.MatchContentType(contentType, `application/json`):
|
||||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||
var out sdkerrors.StartUniversalTranscodeResponseBody
|
||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.RawResponse = httpRes
|
||||
|
||||
out.RawResponse = httpRes
|
||||
return nil, &out
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
default:
|
||||
return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
Reference in New Issue
Block a user