mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 20:47:48 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eb6f2c692 | ||
|
|
0adacc0e13 | ||
|
|
ec6ef7db64 | ||
|
|
32a5beaae6 | ||
|
|
ea30334a95 | ||
|
|
f3eb760757 | ||
|
|
683823eab9 | ||
|
|
6942d6b905 | ||
|
|
1a7051235f | ||
|
|
68fedfa8fc | ||
|
|
5916d2ace5 | ||
|
|
417454ebb2 | ||
|
|
992291fe20 |
@@ -1,12 +1,12 @@
|
|||||||
lockVersion: 2.0.0
|
lockVersion: 2.0.0
|
||||||
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
|
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
|
||||||
management:
|
management:
|
||||||
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
|
||||||
docVersion: 0.0.3
|
docVersion: 0.0.3
|
||||||
speakeasyVersion: internal
|
speakeasyVersion: 1.235.0
|
||||||
generationVersion: 2.277.0
|
generationVersion: 2.298.0
|
||||||
releaseVersion: 0.4.3
|
releaseVersion: 0.6.1
|
||||||
configChecksum: 674d3a2999f009a34f988214b4866715
|
configChecksum: d8f185571a23470089a80d835fcabcbb
|
||||||
repoURL: https://github.com/LukeHagar/plexgo.git
|
repoURL: https://github.com/LukeHagar/plexgo.git
|
||||||
repoSubDirectory: .
|
repoSubDirectory: .
|
||||||
installationURL: https://github.com/LukeHagar/plexgo
|
installationURL: https://github.com/LukeHagar/plexgo
|
||||||
@@ -14,12 +14,14 @@ management:
|
|||||||
features:
|
features:
|
||||||
go:
|
go:
|
||||||
constsAndDefaults: 0.1.4
|
constsAndDefaults: 0.1.4
|
||||||
core: 3.4.3
|
core: 3.4.5
|
||||||
flattening: 2.81.1
|
flattening: 2.81.1
|
||||||
globalSecurity: 2.82.8
|
globalSecurity: 2.82.9
|
||||||
globalServerURLs: 2.82.1
|
globalServerURLs: 2.82.2
|
||||||
|
globals: 2.82.1
|
||||||
methodServerURLs: 2.82.1
|
methodServerURLs: 2.82.1
|
||||||
nameOverrides: 2.81.1
|
nameOverrides: 2.81.2
|
||||||
|
responseFormat: 0.1.0
|
||||||
generatedFiles:
|
generatedFiles:
|
||||||
- server.go
|
- server.go
|
||||||
- media.go
|
- media.go
|
||||||
|
|||||||
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
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
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
|
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.
|
||||||
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.
|
|
||||||
|
|||||||
73
README.md
73
README.md
@@ -33,6 +33,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -40,7 +41,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -235,6 +236,7 @@ func main() {
|
|||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithServerIndex(0),
|
plexgo.WithServerIndex(0),
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -242,7 +244,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -274,6 +275,7 @@ func main() {
|
|||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithServerURL("{protocol}://{ip}:{port}"),
|
plexgo.WithServerURL("{protocol}://{ip}:{port}"),
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -281,7 +283,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -302,18 +303,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New()
|
s := plexgo.New(
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
var xPlexClientIdentifier string = "<value>"
|
)
|
||||||
|
|
||||||
var strong *bool = plexgo.Bool(false)
|
var strong *bool = plexgo.Bool(false)
|
||||||
|
|
||||||
|
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||||
|
|
||||||
ctx := context.Background()
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -375,6 +377,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -382,7 +385,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -417,6 +419,59 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on
|
|||||||
```
|
```
|
||||||
<!-- End Special Types [types] -->
|
<!-- 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 -->
|
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
|
|||||||
60
RELEASES.md
60
RELEASES.md
@@ -159,3 +159,63 @@ Based on:
|
|||||||
- [go v0.4.3] .
|
- [go v0.4.3] .
|
||||||
### Releases
|
### Releases
|
||||||
- [Go v0.4.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.3 - .
|
- [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 - .
|
||||||
2
USAGE.md
2
USAGE.md
@@ -12,6 +12,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -19,7 +20,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getServerActivities",
|
OperationID: "getServerActivities",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -82,11 +85,10 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetServerActivitiesResponse{
|
res := &operations.GetServerActivitiesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +102,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetServerActivitiesResponseBody
|
var out operations.GetServerActivitiesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -108,7 +110,7 @@ func (s *Activities) GetServerActivities(ctx context.Context) (*operations.GetSe
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetServerActivitiesResponseBody
|
var out sdkerrors.GetServerActivitiesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -140,6 +144,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "cancelServerActivities",
|
OperationID: "cancelServerActivities",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +153,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -160,14 +165,16 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -188,11 +195,10 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.CancelServerActivitiesResponse{
|
res := &operations.CancelServerActivitiesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.CancelServerActivitiesResponseBody
|
var out sdkerrors.CancelServerActivitiesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getTransientToken",
|
OperationID: "getTransientToken",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,18 +54,20 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -85,11 +88,10 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetTransientTokenResponse{
|
res := &operations.GetTransientTokenResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetTransientTokenResponseBody
|
var out sdkerrors.GetTransientTokenResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -133,6 +137,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getSourceConnectionInformation",
|
OperationID: "getSourceConnectionInformation",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,18 +158,20 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -185,11 +192,10 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetSourceConnectionInformationResponse{
|
res := &operations.GetSourceConnectionInformationResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetSourceConnectionInformationResponseBody
|
var out sdkerrors.GetSourceConnectionInformationResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
98
butler.go
98
butler.go
@@ -32,6 +32,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getButlerTasks",
|
OperationID: "getButlerTasks",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -76,11 +79,10 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetButlerTasksResponse{
|
res := &operations.GetButlerTasksResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetButlerTasksResponseBody
|
var out operations.GetButlerTasksResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -102,7 +104,7 @@ func (s *Butler) GetButlerTasks(ctx context.Context) (*operations.GetButlerTasks
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetButlerTasksResponseBody
|
var out sdkerrors.GetButlerTasksResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -138,6 +142,7 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "startAllTasks",
|
OperationID: "startAllTasks",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -182,11 +189,10 @@ func (s *Butler) StartAllTasks(ctx context.Context) (*operations.StartAllTasksRe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StartAllTasksResponse{
|
res := &operations.StartAllTasksResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StartAllTasksResponseBody
|
var out sdkerrors.StartAllTasksResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -229,6 +237,7 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "stopAllTasks",
|
OperationID: "stopAllTasks",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -273,11 +284,10 @@ func (s *Butler) StopAllTasks(ctx context.Context) (*operations.StopAllTasksResp
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StopAllTasksResponse{
|
res := &operations.StopAllTasksResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StopAllTasksResponseBody
|
var out sdkerrors.StopAllTasksResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -324,6 +336,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "startTask",
|
OperationID: "startTask",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +345,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -344,14 +357,16 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StartTaskResponse{
|
res := &operations.StartTaskResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StartTaskResponseBody
|
var out sdkerrors.StartTaskResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -421,6 +437,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "stopTask",
|
OperationID: "stopTask",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +446,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -441,14 +458,16 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StopTaskResponse{
|
res := &operations.StopTaskResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StopTaskResponseBody
|
var out sdkerrors.StopTaskResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
| Field | Type | Required | Description |
|
| 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/> |
|
| `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/> |
|
||||||
@@ -6,4 +6,4 @@
|
|||||||
| Field | Type | Required | Description |
|
| Field | Type | Required | Description |
|
||||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
||||||
| `XPlexClientIdentifier` | *string* | :heavy_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() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -43,7 +44,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -79,12 +79,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -95,8 +95,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -45,8 +45,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,12 +84,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -101,8 +100,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -40,7 +41,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -81,12 +81,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -94,8 +94,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,12 +130,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -144,8 +143,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,12 +184,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -202,8 +200,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,12 +238,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -257,8 +254,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +44,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +103,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,8 +52,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,6 +95,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -103,7 +103,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -150,6 +149,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -157,7 +157,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -238,6 +237,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -250,7 +250,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -288,12 +287,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -304,8 +303,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,6 +365,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -379,7 +378,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -417,12 +415,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -433,8 +431,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,6 +491,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -506,7 +504,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -549,6 +546,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -559,7 +557,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -602,6 +599,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -612,7 +610,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -655,6 +652,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -662,7 +660,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -48,8 +48,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,12 +107,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -123,8 +122,7 @@ level=1&message=Test%20message%203&source=postman")
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,12 +159,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -174,8 +172,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -42,8 +42,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,12 +78,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -95,8 +94,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,12 +131,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -153,8 +151,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -56,7 +57,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +112,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -156,6 +156,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -166,7 +167,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -204,12 +204,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -220,8 +220,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,12 +257,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -278,8 +277,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,6 +324,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -338,7 +337,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -377,12 +375,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -393,8 +391,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,6 +434,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -451,7 +449,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -492,12 +489,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -510,8 +507,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,19 +27,20 @@ import(
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New()
|
s := plexgo.New(
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
var xPlexClientIdentifier string = "<value>"
|
|
||||||
|
|
||||||
var strong *bool = plexgo.Bool(false)
|
var strong *bool = plexgo.Bool(false)
|
||||||
|
|
||||||
|
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
res, err := s.Plex.GetPin(ctx, xPlexClientIdentifier, strong)
|
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -51,8 +52,8 @@ func main() {
|
|||||||
| Parameter | Type | Required | Description |
|
| Parameter | Type | Required | Description |
|
||||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
|
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
|
||||||
| `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/> |
|
| `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. |
|
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
|
||||||
|
|
||||||
|
|
||||||
@@ -77,24 +78,24 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New()
|
s := plexgo.New(
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
var pinID string = "<value>"
|
var pinID string = "<value>"
|
||||||
|
|
||||||
var xPlexClientIdentifier string = "<value>"
|
var xPlexClientIdentifier *string = plexgo.String("<value>")
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
|
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// 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. |
|
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
|
||||||
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
|
||||||
| `xPlexClientIdentifier` | *string* | :heavy_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. |
|
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -58,8 +58,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,12 +100,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -121,8 +120,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,6 +163,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +174,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -43,7 +44,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -84,6 +84,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -91,7 +92,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -132,6 +132,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -139,7 +140,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -180,6 +180,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -187,7 +188,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -228,6 +228,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -235,7 +236,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -276,6 +276,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -283,7 +284,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -321,12 +321,12 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -342,8 +342,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,6 +383,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -391,7 +391,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -39,7 +40,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -80,6 +80,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -87,7 +88,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -128,6 +128,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -135,7 +136,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -171,12 +171,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -187,8 +187,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +40,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import(
|
|||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -39,7 +40,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Object != nil {
|
if res.Object != nil {
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
@@ -76,12 +76,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -92,8 +92,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,12 +130,12 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -149,8 +148,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -50,8 +50,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,12 +87,12 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := plexgo.New(
|
s := plexgo.New(
|
||||||
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
||||||
|
plexgo.WithXPlexClientIdentifier("<value>"),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -107,8 +106,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
gen.yaml
3
gen.yaml
@@ -12,7 +12,7 @@ generation:
|
|||||||
auth:
|
auth:
|
||||||
oAuth2ClientCredentialsEnabled: false
|
oAuth2ClientCredentialsEnabled: false
|
||||||
go:
|
go:
|
||||||
version: 0.4.3
|
version: 0.6.1
|
||||||
additionalDependencies: {}
|
additionalDependencies: {}
|
||||||
clientServerStatusCodesAsErrors: true
|
clientServerStatusCodesAsErrors: true
|
||||||
flattenGlobalSecurity: true
|
flattenGlobalSecurity: true
|
||||||
@@ -28,3 +28,4 @@ go:
|
|||||||
maxMethodParams: 4
|
maxMethodParams: 4
|
||||||
outputModelSuffix: output
|
outputModelSuffix: output
|
||||||
packageName: github.com/LukeHagar/plexgo
|
packageName: github.com/LukeHagar/plexgo
|
||||||
|
responseFormat: envelope
|
||||||
|
|||||||
50
hubs.go
50
hubs.go
@@ -32,6 +32,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getGlobalHubs",
|
OperationID: "getGlobalHubs",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,18 +54,20 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetGlobalHubsResponse{
|
res := &operations.GetGlobalHubsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetGlobalHubsResponseBody
|
var out operations.GetGlobalHubsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -111,7 +113,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetGlobalHubsResponseBody
|
var out sdkerrors.GetGlobalHubsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -143,6 +147,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getLibraryHubs",
|
OperationID: "getLibraryHubs",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +158,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -165,18 +170,20 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetLibraryHubsResponse{
|
res := &operations.GetLibraryHubsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +221,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetLibraryHubsResponseBody
|
var out operations.GetLibraryHubsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -223,7 +229,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetLibraryHubsResponseBody
|
var out sdkerrors.GetLibraryHubsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ func New() *Hooks {
|
|||||||
afterErrorHook: []afterErrorHook{},
|
afterErrorHook: []afterErrorHook{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initHooks(h)
|
||||||
|
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}) {
|
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}, globals map[string]map[string]map[string]interface{}) {
|
||||||
headerParamsStructType := reflect.TypeOf(headers)
|
headerParamsStructType := reflect.TypeOf(headers)
|
||||||
headerParamsValType := reflect.ValueOf(headers)
|
headerParamsValType := reflect.ValueOf(headers)
|
||||||
|
|
||||||
@@ -18,6 +18,8 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
|
|||||||
fieldType := headerParamsStructType.Field(i)
|
fieldType := headerParamsStructType.Field(i)
|
||||||
valType := headerParamsValType.Field(i)
|
valType := headerParamsValType.Field(i)
|
||||||
|
|
||||||
|
valType = populateFromGlobals(fieldType, valType, "header", globals)
|
||||||
|
|
||||||
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
|
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
|
||||||
if tag == nil {
|
if tag == nil {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPClient interface {
|
|
||||||
Do(req *http.Request) (*http.Response, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
securityTagKey = "security"
|
securityTagKey = "security"
|
||||||
)
|
)
|
||||||
@@ -27,73 +23,24 @@ type securityTag struct {
|
|||||||
SubType string
|
SubType string
|
||||||
}
|
}
|
||||||
|
|
||||||
type securityConfig struct {
|
func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error {
|
||||||
headers map[string]string
|
if securitySource == nil {
|
||||||
queryParams map[string]string
|
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) {
|
security, err := securitySource(ctx)
|
||||||
securityCtx, err := c.security(req.Context())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := securityConfig{
|
headers := make(map[string]string)
|
||||||
headers: make(map[string]string),
|
queryParams := make(map[string]string)
|
||||||
queryParams: make(map[string]string),
|
|
||||||
}
|
|
||||||
parseSecurityStruct(&ctx, securityCtx)
|
|
||||||
|
|
||||||
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))
|
securityValType := trueReflectValue(reflect.ValueOf(security))
|
||||||
securityStructType := securityValType.Type()
|
securityStructType := securityValType.Type()
|
||||||
|
|
||||||
if isNil(securityStructType, securityValType) {
|
if isNil(securityStructType, securityValType) {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if securityStructType.Kind() == reflect.Ptr {
|
if securityStructType.Kind() == reflect.Ptr {
|
||||||
@@ -118,20 +65,32 @@ func parseSecurityStruct(c *securityConfig, security interface{}) {
|
|||||||
secTag := parseSecurityTag(fieldType)
|
secTag := parseSecurityTag(fieldType)
|
||||||
if secTag != nil {
|
if secTag != nil {
|
||||||
if secTag.Option {
|
if secTag.Option {
|
||||||
handleSecurityOption(c, valType.Interface())
|
handleSecurityOption(headers, queryParams, valType.Interface())
|
||||||
} else if secTag.Scheme {
|
} else if secTag.Scheme {
|
||||||
// Special case for basic auth which could be a flattened struct
|
// Special case for basic auth which could be a flattened struct
|
||||||
if secTag.SubType == "basic" && kind != reflect.Struct {
|
if secTag.SubType == "basic" && kind != reflect.Struct {
|
||||||
parseSecurityScheme(c, secTag, security)
|
parseSecurityScheme(headers, queryParams, secTag, security)
|
||||||
} else {
|
} else {
|
||||||
parseSecurityScheme(c, secTag, valType.Interface())
|
parseSecurityScheme(headers, queryParams, secTag, valType.Interface())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key, value := range headers {
|
||||||
|
req.Header.Add(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
query := req.URL.Query()
|
||||||
|
for key, value := range queryParams {
|
||||||
|
query.Add(key, value)
|
||||||
|
}
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSecurityOption(c *securityConfig, option interface{}) {
|
func handleSecurityOption(headers, queryParams map[string]string, option interface{}) {
|
||||||
optionValType := trueReflectValue(reflect.ValueOf(option))
|
optionValType := trueReflectValue(reflect.ValueOf(option))
|
||||||
optionStructType := optionValType.Type()
|
optionStructType := optionValType.Type()
|
||||||
|
|
||||||
@@ -145,12 +104,12 @@ func handleSecurityOption(c *securityConfig, option interface{}) {
|
|||||||
|
|
||||||
secTag := parseSecurityTag(fieldType)
|
secTag := parseSecurityTag(fieldType)
|
||||||
if secTag != nil && secTag.Scheme {
|
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))
|
schemeVal := trueReflectValue(reflect.ValueOf(scheme))
|
||||||
schemeType := schemeVal.Type()
|
schemeType := schemeVal.Type()
|
||||||
|
|
||||||
@@ -160,7 +119,7 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
|
|||||||
|
|
||||||
if schemeType.Kind() == reflect.Struct {
|
if schemeType.Kind() == reflect.Struct {
|
||||||
if schemeTag.Type == "http" && schemeTag.SubType == "basic" {
|
if schemeTag.Type == "http" && schemeTag.SubType == "basic" {
|
||||||
handleBasicAuthScheme(client, schemeVal.Interface())
|
handleBasicAuthScheme(headers, schemeVal.Interface())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,36 +140,36 @@ func parseSecurityScheme(client *securityConfig, schemeTag *securityTag, scheme
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
parseSecuritySchemeValue(client, schemeTag, secTag, valType.Interface())
|
parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface())
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
switch schemeTag.Type {
|
||||||
case "apiKey":
|
case "apiKey":
|
||||||
switch schemeTag.SubType {
|
switch schemeTag.SubType {
|
||||||
case "header":
|
case "header":
|
||||||
client.headers[secTag.Name] = valToString(val)
|
headers[secTag.Name] = valToString(val)
|
||||||
case "query":
|
case "query":
|
||||||
client.queryParams[secTag.Name] = valToString(val)
|
queryParams[secTag.Name] = valToString(val)
|
||||||
case "cookie":
|
case "cookie":
|
||||||
client.headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
|
headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val))
|
||||||
default:
|
default:
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
case "openIdConnect":
|
case "openIdConnect":
|
||||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||||
case "oauth2":
|
case "oauth2":
|
||||||
if schemeTag.SubType != "client_credentials" {
|
if schemeTag.SubType != "client_credentials" {
|
||||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||||
}
|
}
|
||||||
case "http":
|
case "http":
|
||||||
switch schemeTag.SubType {
|
switch schemeTag.SubType {
|
||||||
case "bearer":
|
case "bearer":
|
||||||
client.headers[secTag.Name] = prefixBearer(valToString(val))
|
headers[secTag.Name] = prefixBearer(valToString(val))
|
||||||
default:
|
default:
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
@@ -227,7 +186,7 @@ func prefixBearer(authHeaderValue string) string {
|
|||||||
return fmt.Sprintf("Bearer %s", authHeaderValue)
|
return fmt.Sprintf("Bearer %s", authHeaderValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleBasicAuthScheme(client *securityConfig, scheme interface{}) {
|
func handleBasicAuthScheme(headers map[string]string, scheme interface{}) {
|
||||||
schemeStructType := reflect.TypeOf(scheme)
|
schemeStructType := reflect.TypeOf(scheme)
|
||||||
schemeValType := reflect.ValueOf(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 {
|
func parseSecurityTag(field reflect.StructField) *securityTag {
|
||||||
@@ -296,3 +255,16 @@ func parseSecurityTag(field reflect.StructField) *securityTag {
|
|||||||
SubType: securitySubType,
|
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
|
||||||
|
}
|
||||||
|
|||||||
238
library.go
238
library.go
@@ -32,6 +32,7 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getFileHash",
|
OperationID: "getFileHash",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,18 +54,20 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetFileHashResponse{
|
res := &operations.GetFileHashResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetFileHashResponseBody
|
var out sdkerrors.GetFileHashResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -132,6 +136,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getRecentlyAdded",
|
OperationID: "getRecentlyAdded",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -176,11 +183,10 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetRecentlyAddedResponse{
|
res := &operations.GetRecentlyAddedResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +200,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetRecentlyAddedResponseBody
|
var out operations.GetRecentlyAddedResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -202,7 +208,7 @@ func (s *Library) GetRecentlyAdded(ctx context.Context) (*operations.GetRecently
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetRecentlyAddedResponseBody
|
var out sdkerrors.GetRecentlyAddedResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -239,6 +247,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getLibraries",
|
OperationID: "getLibraries",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -283,11 +294,10 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetLibrariesResponse{
|
res := &operations.GetLibrariesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +311,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetLibrariesResponseBody
|
var out operations.GetLibrariesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -309,7 +319,7 @@ func (s *Library) GetLibraries(ctx context.Context) (*operations.GetLibrariesRes
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetLibrariesResponseBody
|
var out sdkerrors.GetLibrariesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -379,6 +391,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getLibrary",
|
OperationID: "getLibrary",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +401,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -400,18 +413,20 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetLibraryResponse{
|
res := &operations.GetLibraryResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,7 +464,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetLibraryResponseBody
|
var out operations.GetLibraryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -458,7 +472,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetLibraryResponseBody
|
var out sdkerrors.GetLibraryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -490,6 +506,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "deleteLibrary",
|
OperationID: "deleteLibrary",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +515,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -510,14 +527,16 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.DeleteLibraryResponse{
|
res := &operations.DeleteLibraryResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.DeleteLibraryResponseBody
|
var out sdkerrors.DeleteLibraryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -604,6 +624,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getLibraryItems",
|
OperationID: "getLibraryItems",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,7 +634,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -625,14 +646,16 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetLibraryItemsResponse{
|
res := &operations.GetLibraryItemsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,7 +693,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetLibraryItemsResponseBody
|
var out operations.GetLibraryItemsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -679,12 +701,14 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||||
fallthrough
|
fallthrough
|
||||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
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
|
return res, nil
|
||||||
@@ -696,6 +720,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "refreshLibrary",
|
OperationID: "refreshLibrary",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,7 +729,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -716,14 +741,16 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.RefreshLibraryResponse{
|
res := &operations.RefreshLibraryResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.RefreshLibraryResponseBody
|
var out sdkerrors.RefreshLibraryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -808,6 +836,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "searchLibrary",
|
OperationID: "searchLibrary",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,7 +846,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -829,18 +858,20 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.SearchLibraryResponse{
|
res := &operations.SearchLibraryResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +909,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.SearchLibraryResponseBody
|
var out operations.SearchLibraryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -887,12 +917,14 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||||
fallthrough
|
fallthrough
|
||||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
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
|
return res, nil
|
||||||
@@ -904,6 +936,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getMetadata",
|
OperationID: "getMetadata",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,7 +945,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -924,14 +957,16 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetMetadataResponse{
|
res := &operations.GetMetadataResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -970,7 +1004,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetMetadataResponseBody
|
var out operations.GetMetadataResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -978,7 +1012,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetMetadataResponseBody
|
var out sdkerrors.GetMetadataResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -1010,6 +1046,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getMetadataChildren",
|
OperationID: "getMetadataChildren",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,7 +1055,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1030,14 +1067,16 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -1058,11 +1097,10 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetMetadataChildrenResponse{
|
res := &operations.GetMetadataChildrenResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1076,7 +1114,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetMetadataChildrenResponseBody
|
var out operations.GetMetadataChildrenResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1084,7 +1122,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetMetadataChildrenResponseBody
|
var out sdkerrors.GetMetadataChildrenResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -1116,6 +1156,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getOnDeck",
|
OperationID: "getOnDeck",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -1160,11 +1203,10 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetOnDeckResponse{
|
res := &operations.GetOnDeckResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1178,7 +1220,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetOnDeckResponseBody
|
var out operations.GetOnDeckResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1186,7 +1228,7 @@ func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse,
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetOnDeckResponseBody
|
var out sdkerrors.GetOnDeckResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
56
log.go
56
log.go
@@ -32,6 +32,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "logLine",
|
OperationID: "logLine",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,18 +55,20 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.LogLineResponse{
|
res := &operations.LogLineResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.LogLineResponseBody
|
var out sdkerrors.LogLineResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -153,6 +157,7 @@ func (s *Log) LogMultiLine(ctx context.Context, request string) (*operations.Log
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "logMultiLine",
|
OperationID: "logMultiLine",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
req.Header.Set("Content-Type", reqContentType)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.LogMultiLineResponse{
|
res := &operations.LogMultiLineResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.LogMultiLineResponseBody
|
var out sdkerrors.LogMultiLineResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -250,6 +258,7 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "enablePaperTrail",
|
OperationID: "enablePaperTrail",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -294,11 +305,10 @@ func (s *Log) EnablePaperTrail(ctx context.Context) (*operations.EnablePaperTrai
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.EnablePaperTrailResponse{
|
res := &operations.EnablePaperTrailResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.EnablePaperTrailResponseBody
|
var out sdkerrors.EnablePaperTrailResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
60
media.go
60
media.go
@@ -32,6 +32,7 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "markPlayed",
|
OperationID: "markPlayed",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +53,20 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.MarkPlayedResponse{
|
res := &operations.MarkPlayedResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.MarkPlayedResponseBody
|
var out sdkerrors.MarkPlayedResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -131,6 +135,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "markUnplayed",
|
OperationID: "markUnplayed",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,18 +156,20 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.MarkUnplayedResponse{
|
res := &operations.MarkUnplayedResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.MarkUnplayedResponseBody
|
var out sdkerrors.MarkUnplayedResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -230,6 +238,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "updatePlayProgress",
|
OperationID: "updatePlayProgress",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,18 +261,20 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.UpdatePlayProgressResponse{
|
res := &operations.UpdatePlayProgressResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.UpdatePlayProgressResponseBody
|
var out sdkerrors.UpdatePlayProgressResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ var GetPinServerList = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetPinRequest struct {
|
type GetPinRequest 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"`
|
|
||||||
// Determines the kind of code returned by the API call
|
// Determines the kind of code returned by the API call
|
||||||
// Strong codes are used for Pin authentication flows
|
// Strong codes are used for Pin authentication flows
|
||||||
// Non-Strong codes are used for `Plex.tv/link`
|
// Non-Strong codes are used for `Plex.tv/link`
|
||||||
//
|
//
|
||||||
Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"`
|
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) {
|
func (g GetPinRequest) MarshalJSON() ([]byte, error) {
|
||||||
@@ -36,13 +36,6 @@ func (g *GetPinRequest) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GetPinRequest) GetXPlexClientIdentifier() string {
|
|
||||||
if o == nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return o.XPlexClientIdentifier
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *GetPinRequest) GetStrong() *bool {
|
func (o *GetPinRequest) GetStrong() *bool {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -50,6 +43,13 @@ func (o *GetPinRequest) GetStrong() *bool {
|
|||||||
return o.Strong
|
return o.Strong
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *GetPinRequest) GetXPlexClientIdentifier() *string {
|
||||||
|
if o == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return o.XPlexClientIdentifier
|
||||||
|
}
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
Code *string `json:"code,omitempty"`
|
Code *string `json:"code,omitempty"`
|
||||||
EuropeanUnionMember *bool `json:"european_union_member,omitempty"`
|
EuropeanUnionMember *bool `json:"european_union_member,omitempty"`
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type GetTokenRequest struct {
|
|||||||
// This is used to track the client application and its usage
|
// This is used to track the client application and its usage
|
||||||
// (UUID, serial number, or other number unique per device)
|
// (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 {
|
func (o *GetTokenRequest) GetPinID() string {
|
||||||
@@ -27,9 +27,9 @@ func (o *GetTokenRequest) GetPinID() string {
|
|||||||
return o.PinID
|
return o.PinID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GetTokenRequest) GetXPlexClientIdentifier() string {
|
func (o *GetTokenRequest) GetXPlexClientIdentifier() *string {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
return o.XPlexClientIdentifier
|
return o.XPlexClientIdentifier
|
||||||
}
|
}
|
||||||
|
|||||||
206
playlists.go
206
playlists.go
@@ -37,6 +37,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "createPlaylist",
|
OperationID: "createPlaylist",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,18 +54,20 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.CreatePlaylistResponse{
|
res := &operations.CreatePlaylistResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.CreatePlaylistResponseBody
|
var out operations.CreatePlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -111,7 +113,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.CreatePlaylistResponseBody
|
var out sdkerrors.CreatePlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -143,6 +147,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getPlaylists",
|
OperationID: "getPlaylists",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,18 +169,20 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetPlaylistsResponse{
|
res := &operations.GetPlaylistsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +220,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetPlaylistsResponseBody
|
var out operations.GetPlaylistsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -222,7 +228,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetPlaylistsResponseBody
|
var out sdkerrors.GetPlaylistsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -255,6 +263,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getPlaylist",
|
OperationID: "getPlaylist",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +272,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -275,14 +284,16 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetPlaylistResponse{
|
res := &operations.GetPlaylistResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +331,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetPlaylistResponseBody
|
var out operations.GetPlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -329,7 +339,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetPlaylistResponseBody
|
var out sdkerrors.GetPlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -361,6 +373,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "deletePlaylist",
|
OperationID: "deletePlaylist",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +382,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -381,14 +394,16 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.DeletePlaylistResponse{
|
res := &operations.DeletePlaylistResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.DeletePlaylistResponseBody
|
var out sdkerrors.DeletePlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -456,6 +472,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "updatePlaylist",
|
OperationID: "updatePlaylist",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,7 +483,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -478,18 +495,20 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.UpdatePlaylistResponse{
|
res := &operations.UpdatePlaylistResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.UpdatePlaylistResponseBody
|
var out sdkerrors.UpdatePlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -560,6 +580,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getPlaylistContents",
|
OperationID: "getPlaylistContents",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +590,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -581,18 +602,20 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -613,11 +636,10 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetPlaylistContentsResponse{
|
res := &operations.GetPlaylistContentsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,7 +653,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetPlaylistContentsResponseBody
|
var out operations.GetPlaylistContentsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -639,7 +661,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetPlaylistContentsResponseBody
|
var out sdkerrors.GetPlaylistContentsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -671,6 +695,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "clearPlaylistContents",
|
OperationID: "clearPlaylistContents",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,7 +704,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -691,14 +716,16 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -719,11 +746,10 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.ClearPlaylistContentsResponse{
|
res := &operations.ClearPlaylistContentsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.ClearPlaylistContentsResponseBody
|
var out sdkerrors.ClearPlaylistContentsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -767,6 +795,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "addPlaylistContents",
|
OperationID: "addPlaylistContents",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +806,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -789,18 +818,20 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -821,11 +852,10 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.AddPlaylistContentsResponse{
|
res := &operations.AddPlaylistContentsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,7 +869,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.AddPlaylistContentsResponseBody
|
var out operations.AddPlaylistContentsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -847,7 +877,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.AddPlaylistContentsResponseBody
|
var out sdkerrors.AddPlaylistContentsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -879,6 +911,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "uploadPlaylist",
|
OperationID: "uploadPlaylist",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,18 +933,20 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.UploadPlaylistResponse{
|
res := &operations.UploadPlaylistResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.UploadPlaylistResponseBody
|
var out sdkerrors.UploadPlaylistResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
50
plex.go
50
plex.go
@@ -28,16 +28,17 @@ func newPlex(sdkConfig sdkConfiguration) *Plex {
|
|||||||
|
|
||||||
// GetPin - Get a Pin
|
// GetPin - Get a Pin
|
||||||
// Retrieve a Pin from Plex.tv for authentication flows
|
// 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{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getPin",
|
OperationID: "getPin",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: nil,
|
SecuritySource: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
request := operations.GetPinRequest{
|
request := operations.GetPinRequest{
|
||||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
|
||||||
Strong: strong,
|
Strong: strong,
|
||||||
|
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
o := operations.Options{}
|
o := operations.Options{}
|
||||||
@@ -67,20 +68,18 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
utils.PopulateHeaders(ctx, req, request)
|
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -101,11 +100,10 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetPinResponse{
|
res := &operations.GetPinResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetPinResponseBody
|
var out operations.GetPinResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -127,25 +125,27 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetPinResponseBody
|
var out sdkerrors.GetPinResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||||
fallthrough
|
fallthrough
|
||||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
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
|
return res, nil
|
||||||
@@ -153,10 +153,11 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
|
|
||||||
// GetToken - Get Access Token
|
// GetToken - Get Access Token
|
||||||
// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
// 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{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getToken",
|
OperationID: "getToken",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: nil,
|
SecuritySource: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
baseURL = *o.ServerURL
|
baseURL = *o.ServerURL
|
||||||
}
|
}
|
||||||
|
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -192,16 +193,14 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
utils.PopulateHeaders(ctx, req, request)
|
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals)
|
||||||
|
|
||||||
client := s.sdkConfiguration.DefaultClient
|
|
||||||
|
|
||||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -222,11 +221,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetTokenResponse{
|
res := &operations.GetTokenResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,21 +239,23 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
case httpRes.StatusCode == 400:
|
case httpRes.StatusCode == 400:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetTokenResponseBody
|
var out sdkerrors.GetTokenResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
|
||||||
fallthrough
|
fallthrough
|
||||||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
|
||||||
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
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
|
return res, nil
|
||||||
|
|||||||
40
plexapi.go
40
plexapi.go
@@ -43,8 +43,7 @@ func Float32(f float32) *float32 { return &f }
|
|||||||
func Float64(f float64) *float64 { return &f }
|
func Float64(f float64) *float64 { return &f }
|
||||||
|
|
||||||
type sdkConfiguration struct {
|
type sdkConfiguration struct {
|
||||||
DefaultClient HTTPClient
|
Client HTTPClient
|
||||||
SecurityClient HTTPClient
|
|
||||||
Security func(context.Context) (interface{}, error)
|
Security func(context.Context) (interface{}, error)
|
||||||
ServerURL string
|
ServerURL string
|
||||||
ServerIndex int
|
ServerIndex int
|
||||||
@@ -54,6 +53,7 @@ type sdkConfiguration struct {
|
|||||||
SDKVersion string
|
SDKVersion string
|
||||||
GenVersion string
|
GenVersion string
|
||||||
UserAgent string
|
UserAgent string
|
||||||
|
Globals map[string]map[string]map[string]interface{}
|
||||||
RetryConfig *utils.RetryConfig
|
RetryConfig *utils.RetryConfig
|
||||||
Hooks *hooks.Hooks
|
Hooks *hooks.Hooks
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ func WithPort(port string) SDKOption {
|
|||||||
// WithClient allows the overriding of the default HTTP client used by the SDK
|
// WithClient allows the overriding of the default HTTP client used by the SDK
|
||||||
func WithClient(client HTTPClient) SDKOption {
|
func WithClient(client HTTPClient) SDKOption {
|
||||||
return func(sdk *PlexAPI) {
|
return func(sdk *PlexAPI) {
|
||||||
sdk.sdkConfiguration.DefaultClient = client
|
sdk.sdkConfiguration.Client = client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +256,17 @@ 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) {
|
||||||
|
if _, ok := sdk.sdkConfiguration.Globals["parameters"]["header"]; !ok {
|
||||||
|
sdk.sdkConfiguration.Globals["parameters"]["header"] = map[string]interface{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
sdk.sdkConfiguration.Globals["parameters"]["header"]["XPlexClientIdentifier"] = xPlexClientIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption {
|
func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption {
|
||||||
return func(sdk *PlexAPI) {
|
return func(sdk *PlexAPI) {
|
||||||
sdk.sdkConfiguration.RetryConfig = &retryConfig
|
sdk.sdkConfiguration.RetryConfig = &retryConfig
|
||||||
@@ -268,9 +279,12 @@ func New(opts ...SDKOption) *PlexAPI {
|
|||||||
sdkConfiguration: sdkConfiguration{
|
sdkConfiguration: sdkConfiguration{
|
||||||
Language: "go",
|
Language: "go",
|
||||||
OpenAPIDocVersion: "0.0.3",
|
OpenAPIDocVersion: "0.0.3",
|
||||||
SDKVersion: "0.4.3",
|
SDKVersion: "0.6.1",
|
||||||
GenVersion: "2.277.0",
|
GenVersion: "2.298.0",
|
||||||
UserAgent: "speakeasy-sdk/go 0.4.3 2.277.0 0.0.3 github.com/LukeHagar/plexgo",
|
UserAgent: "speakeasy-sdk/go 0.6.1 2.298.0 0.0.3 github.com/LukeHagar/plexgo",
|
||||||
|
Globals: map[string]map[string]map[string]interface{}{
|
||||||
|
"parameters": {},
|
||||||
|
},
|
||||||
ServerDefaults: []map[string]string{
|
ServerDefaults: []map[string]string{
|
||||||
{
|
{
|
||||||
"protocol": "http",
|
"protocol": "http",
|
||||||
@@ -286,25 +300,17 @@ func New(opts ...SDKOption) *PlexAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use WithClient to override the default client if you would like to customize the timeout
|
// Use WithClient to override the default client if you would like to customize the timeout
|
||||||
if sdk.sdkConfiguration.DefaultClient == nil {
|
if sdk.sdkConfiguration.Client == nil {
|
||||||
sdk.sdkConfiguration.DefaultClient = &http.Client{Timeout: 60 * time.Second}
|
sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails()
|
currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails()
|
||||||
serverURL := currentServerURL
|
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 {
|
if serverURL != currentServerURL {
|
||||||
sdk.sdkConfiguration.ServerURL = serverURL
|
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.Server = newServer(sdk.sdkConfiguration)
|
||||||
|
|
||||||
sdk.Media = newMedia(sdk.sdkConfiguration)
|
sdk.Media = newMedia(sdk.sdkConfiguration)
|
||||||
|
|||||||
64
search.go
64
search.go
@@ -44,6 +44,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "performSearch",
|
OperationID: "performSearch",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +67,20 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.PerformSearchResponse{
|
res := &operations.PerformSearchResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.PerformSearchResponseBody
|
var out sdkerrors.PerformSearchResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -148,6 +152,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "performVoiceSearch",
|
OperationID: "performVoiceSearch",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,18 +175,20 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.PerformVoiceSearchResponse{
|
res := &operations.PerformVoiceSearchResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.PerformVoiceSearchResponseBody
|
var out sdkerrors.PerformVoiceSearchResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -249,6 +257,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getSearchResults",
|
OperationID: "getSearchResults",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,18 +278,20 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetSearchResultsResponse{
|
res := &operations.GetSearchResultsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +329,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetSearchResultsResponseBody
|
var out operations.GetSearchResultsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -327,7 +337,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetSearchResultsResponseBody
|
var out sdkerrors.GetSearchResultsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
174
server.go
174
server.go
@@ -32,6 +32,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getServerCapabilities",
|
OperationID: "getServerCapabilities",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -76,11 +79,10 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetServerCapabilitiesResponse{
|
res := &operations.GetServerCapabilitiesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetServerCapabilitiesResponseBody
|
var out operations.GetServerCapabilitiesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -102,7 +104,7 @@ func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServ
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetServerCapabilitiesResponseBody
|
var out sdkerrors.GetServerCapabilitiesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -134,6 +138,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getServerPreferences",
|
OperationID: "getServerPreferences",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -178,11 +185,10 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetServerPreferencesResponse{
|
res := &operations.GetServerPreferencesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +202,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetServerPreferencesResponseBody
|
var out operations.GetServerPreferencesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -204,7 +210,7 @@ func (s *Server) GetServerPreferences(ctx context.Context) (*operations.GetServe
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetServerPreferencesResponseBody
|
var out sdkerrors.GetServerPreferencesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -236,6 +244,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getAvailableClients",
|
OperationID: "getAvailableClients",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -280,11 +291,10 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetAvailableClientsResponse{
|
res := &operations.GetAvailableClientsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +308,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetAvailableClientsResponseBody
|
var out operations.GetAvailableClientsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -306,7 +316,7 @@ func (s *Server) GetAvailableClients(ctx context.Context) (*operations.GetAvaila
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetAvailableClientsResponseBody
|
var out sdkerrors.GetAvailableClientsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -338,6 +350,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getDevices",
|
OperationID: "getDevices",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -382,11 +397,10 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetDevicesResponse{
|
res := &operations.GetDevicesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +414,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetDevicesResponseBody
|
var out operations.GetDevicesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -408,7 +422,7 @@ func (s *Server) GetDevices(ctx context.Context) (*operations.GetDevicesResponse
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetDevicesResponseBody
|
var out sdkerrors.GetDevicesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -440,6 +456,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getServerIdentity",
|
OperationID: "getServerIdentity",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -484,11 +503,10 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetServerIdentityResponse{
|
res := &operations.GetServerIdentityResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +520,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetServerIdentityResponseBody
|
var out operations.GetServerIdentityResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -510,7 +528,7 @@ func (s *Server) GetServerIdentity(ctx context.Context) (*operations.GetServerId
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetServerIdentityResponseBody
|
var out sdkerrors.GetServerIdentityResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -542,6 +562,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getMyPlexAccount",
|
OperationID: "getMyPlexAccount",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -586,11 +609,10 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetMyPlexAccountResponse{
|
res := &operations.GetMyPlexAccountResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +626,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetMyPlexAccountResponseBody
|
var out operations.GetMyPlexAccountResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -612,7 +634,7 @@ func (s *Server) GetMyPlexAccount(ctx context.Context) (*operations.GetMyPlexAcc
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetMyPlexAccountResponseBody
|
var out sdkerrors.GetMyPlexAccountResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -644,6 +668,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getResizedPhoto",
|
OperationID: "getResizedPhoto",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,18 +685,20 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetResizedPhotoResponse{
|
res := &operations.GetResizedPhotoResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetResizedPhotoResponseBody
|
var out sdkerrors.GetResizedPhotoResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -739,6 +767,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getServerList",
|
OperationID: "getServerList",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -783,11 +814,10 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetServerListResponse{
|
res := &operations.GetServerListResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,7 +831,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetServerListResponseBody
|
var out operations.GetServerListResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -809,7 +839,7 @@ func (s *Server) GetServerList(ctx context.Context) (*operations.GetServerListRe
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetServerListResponseBody
|
var out sdkerrors.GetServerListResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
86
sessions.go
86
sessions.go
@@ -32,6 +32,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getSessions",
|
OperationID: "getSessions",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -76,11 +79,10 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetSessionsResponse{
|
res := &operations.GetSessionsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +96,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetSessionsResponseBody
|
var out operations.GetSessionsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -102,7 +104,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetSessionsResponseBody
|
var out sdkerrors.GetSessionsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -134,6 +138,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getSessionHistory",
|
OperationID: "getSessionHistory",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -178,11 +185,10 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetSessionHistoryResponse{
|
res := &operations.GetSessionHistoryResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +202,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetSessionHistoryResponseBody
|
var out operations.GetSessionHistoryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -204,7 +210,7 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetSessionHistoryResponseBody
|
var out sdkerrors.GetSessionHistoryResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -236,6 +244,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getTranscodeSessions",
|
OperationID: "getTranscodeSessions",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -280,11 +291,10 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetTranscodeSessionsResponse{
|
res := &operations.GetTranscodeSessionsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +308,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetTranscodeSessionsResponseBody
|
var out operations.GetTranscodeSessionsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -306,7 +316,7 @@ func (s *Sessions) GetTranscodeSessions(ctx context.Context) (*operations.GetTra
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetTranscodeSessionsResponseBody
|
var out sdkerrors.GetTranscodeSessionsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -338,6 +350,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "stopTranscodeSession",
|
OperationID: "stopTranscodeSession",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +359,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, nil)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, s.sdkConfiguration.Globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -358,14 +371,16 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -386,11 +401,10 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StopTranscodeSessionResponse{
|
res := &operations.StopTranscodeSessionResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StopTranscodeSessionResponseBody
|
var out sdkerrors.StopTranscodeSessionResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getStatistics",
|
OperationID: "getStatistics",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +53,20 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetStatisticsResponse{
|
res := &operations.GetStatisticsResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetStatisticsResponseBody
|
var out operations.GetStatisticsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -110,7 +112,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetStatisticsResponseBody
|
var out sdkerrors.GetStatisticsResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
62
updater.go
62
updater.go
@@ -33,6 +33,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getUpdateStatus",
|
OperationID: "getUpdateStatus",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
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("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -77,11 +80,10 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetUpdateStatusResponse{
|
res := &operations.GetUpdateStatusResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
RawResponse: httpRes,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
|||||||
switch {
|
switch {
|
||||||
case httpRes.StatusCode == 200:
|
case httpRes.StatusCode == 200:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out operations.GetUpdateStatusResponseBody
|
var out operations.GetUpdateStatusResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -103,7 +105,7 @@ func (s *Updater) GetUpdateStatus(ctx context.Context) (*operations.GetUpdateSta
|
|||||||
|
|
||||||
res.Object = &out
|
res.Object = &out
|
||||||
default:
|
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:
|
case httpRes.StatusCode == 400:
|
||||||
fallthrough
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetUpdateStatusResponseBody
|
var out sdkerrors.GetUpdateStatusResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -135,6 +139,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "checkForUpdates",
|
OperationID: "checkForUpdates",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,18 +160,20 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.CheckForUpdatesResponse{
|
res := &operations.CheckForUpdatesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.CheckForUpdatesResponseBody
|
var out sdkerrors.CheckForUpdatesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -234,6 +242,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "applyUpdates",
|
OperationID: "applyUpdates",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,18 +264,20 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.ApplyUpdatesResponse{
|
res := &operations.ApplyUpdatesResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.ApplyUpdatesResponseBody
|
var out sdkerrors.ApplyUpdatesResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
40
video.go
40
video.go
@@ -32,6 +32,7 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getTimeline",
|
OperationID: "getTimeline",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,18 +49,20 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.GetTimelineResponse{
|
res := &operations.GetTimelineResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.GetTimelineResponseBody
|
var out sdkerrors.GetTimelineResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
@@ -127,6 +131,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "startUniversalTranscode",
|
OperationID: "startUniversalTranscode",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,18 +148,20 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRes, err := client.Do(req)
|
httpRes, err := s.sdkConfiguration.Client.Do(req)
|
||||||
if err != nil || httpRes == nil {
|
if err != nil || httpRes == nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error sending request: %w", err)
|
err = fmt.Errorf("error sending request: %w", err)
|
||||||
@@ -175,11 +182,10 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentType := httpRes.Header.Get("Content-Type")
|
|
||||||
|
|
||||||
res := &operations.StartUniversalTranscodeResponse{
|
res := &operations.StartUniversalTranscodeResponse{
|
||||||
StatusCode: httpRes.StatusCode,
|
StatusCode: httpRes.StatusCode,
|
||||||
ContentType: contentType,
|
ContentType: httpRes.Header.Get("Content-Type"),
|
||||||
RawResponse: httpRes,
|
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)
|
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
|
||||||
case httpRes.StatusCode == 401:
|
case httpRes.StatusCode == 401:
|
||||||
switch {
|
switch {
|
||||||
case utils.MatchContentType(contentType, `application/json`):
|
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`):
|
||||||
var out sdkerrors.StartUniversalTranscodeResponseBody
|
var out sdkerrors.StartUniversalTranscodeResponseBody
|
||||||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.RawResponse = httpRes
|
|
||||||
|
|
||||||
|
out.RawResponse = httpRes
|
||||||
return nil, &out
|
return nil, &out
|
||||||
default:
|
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
|
return res, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user