mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a7051235f | ||
|
|
68fedfa8fc | ||
|
|
5916d2ace5 | ||
|
|
417454ebb2 | ||
|
|
992291fe20 | ||
|
|
515f318f05 | ||
|
|
8b81bc5692 |
@@ -3,23 +3,24 @@ id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
|
|||||||
management:
|
management:
|
||||||
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
||||||
docVersion: 0.0.3
|
docVersion: 0.0.3
|
||||||
speakeasyVersion: internal
|
speakeasyVersion: 1.207.1
|
||||||
generationVersion: 2.272.7
|
generationVersion: 2.280.6
|
||||||
releaseVersion: 0.4.2
|
releaseVersion: 0.5.1
|
||||||
configChecksum: e5a25a1a8f81b1393579b0112a09b581
|
configChecksum: 8df2468b7d6f03eb2598948a4b3dac5b
|
||||||
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
|
||||||
published: true
|
published: true
|
||||||
features:
|
features:
|
||||||
go:
|
go:
|
||||||
constsAndDefaults: 0.1.3
|
constsAndDefaults: 0.1.4
|
||||||
core: 3.4.3
|
core: 3.4.4
|
||||||
flattening: 2.81.1
|
flattening: 2.81.1
|
||||||
globalSecurity: 2.82.8
|
globalSecurity: 2.82.8
|
||||||
globalServerURLs: 2.82.1
|
globalServerURLs: 2.82.2
|
||||||
methodServerURLs: 2.82.1
|
methodServerURLs: 2.82.1
|
||||||
nameOverrides: 2.81.1
|
nameOverrides: 2.81.1
|
||||||
|
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.
|
|
||||||
|
|||||||
@@ -40,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
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,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
|
||||||
}
|
}
|
||||||
@@ -281,7 +279,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
|
||||||
}
|
}
|
||||||
@@ -313,7 +310,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
|
||||||
}
|
}
|
||||||
@@ -382,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
|
||||||
}
|
}
|
||||||
|
|||||||
32
RELEASES.md
32
RELEASES.md
@@ -148,4 +148,34 @@ Based on:
|
|||||||
### Generated
|
### Generated
|
||||||
- [go v0.4.2] .
|
- [go v0.4.2] .
|
||||||
### Releases
|
### Releases
|
||||||
- [Go v0.4.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.2 - .
|
- [Go v0.4.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.2 - .
|
||||||
|
|
||||||
|
## 2024-03-02 00:42:48
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.200.0 (2.277.0) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.4.3] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.4.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.4.3 - .
|
||||||
|
|
||||||
|
## 2024-03-08 00:43:49
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.204.1 (2.279.1) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.5.0] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.5.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.0 - .
|
||||||
|
|
||||||
|
## 2024-03-13 00:44:38
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.207.1 (2.280.6) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.5.1] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.5.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.1 - .
|
||||||
1
USAGE.md
1
USAGE.md
@@ -19,7 +19,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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,14 +58,16 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,14 +162,16 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
|||||||
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
|
||||||
|
|||||||
94
butler.go
94
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -43,7 +43,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,7 +78,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -95,8 +93,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,7 +27,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -45,8 +44,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,7 +83,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -101,8 +98,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,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
|
||||||
}
|
}
|
||||||
@@ -81,7 +80,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -94,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,7 +128,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -144,8 +140,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,7 +181,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -202,8 +196,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,7 +234,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -257,8 +249,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,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
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,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,7 +34,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -52,8 +51,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +101,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
|
||||||
}
|
}
|
||||||
@@ -157,7 +154,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
|
||||||
}
|
}
|
||||||
@@ -250,7 +246,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,7 +283,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -304,8 +298,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,7 +372,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,7 +409,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -433,8 +424,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -506,7 +496,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
|
||||||
}
|
}
|
||||||
@@ -559,7 +548,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
|
||||||
}
|
}
|
||||||
@@ -612,7 +600,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
|
||||||
}
|
}
|
||||||
@@ -662,7 +649,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,7 +28,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -48,8 +47,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,7 +106,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -123,8 +120,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,7 +157,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -174,8 +169,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,7 +26,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -42,8 +41,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,7 +77,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -95,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +129,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -153,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,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
|
||||||
}
|
}
|
||||||
@@ -111,7 +110,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
|
||||||
}
|
}
|
||||||
@@ -166,7 +164,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,7 +201,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -220,8 +216,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,7 +253,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -278,8 +272,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +331,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,7 +369,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -393,8 +384,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +441,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,7 +481,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -510,8 +498,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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
|
||||||
}
|
}
|
||||||
@@ -77,7 +76,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -93,8 +91,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -58,8 +57,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,7 +99,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -121,8 +118,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +171,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,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
|
||||||
}
|
}
|
||||||
@@ -91,7 +90,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
|
||||||
}
|
}
|
||||||
@@ -139,7 +137,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
|
||||||
}
|
}
|
||||||
@@ -187,7 +184,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
|
||||||
}
|
}
|
||||||
@@ -235,7 +231,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
|
||||||
}
|
}
|
||||||
@@ -283,7 +278,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,7 +315,6 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -333,17 +326,16 @@ func main() {
|
|||||||
res, err := s.Server.GetResizedPhoto(ctx, operations.GetResizedPhotoRequest{
|
res, err := s.Server.GetResizedPhoto(ctx, operations.GetResizedPhotoRequest{
|
||||||
Width: 110,
|
Width: 110,
|
||||||
Height: 165,
|
Height: 165,
|
||||||
Opacity: 643869,
|
Opacity: 100,
|
||||||
Blur: 4000,
|
Blur: 20,
|
||||||
MinSize: operations.MinSizeZero,
|
MinSize: operations.MinSizeOne,
|
||||||
Upscale: operations.UpscaleZero,
|
Upscale: operations.UpscaleZero,
|
||||||
URL: "/library/metadata/49564/thumb/1654258204",
|
URL: "/library/metadata/49564/thumb/1654258204",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if res != nil {
|
||||||
if res.StatusCode == http.StatusOK {
|
|
||||||
// handle response
|
// handle response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -391,7 +383,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,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
|
||||||
}
|
}
|
||||||
@@ -135,7 +133,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,7 +168,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo"
|
"github.com/LukeHagar/plexgo"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -187,8 +183,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,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,7 +75,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -92,8 +90,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,7 +128,6 @@ import(
|
|||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -149,8 +145,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,7 +26,6 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -50,8 +49,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,7 +86,6 @@ import(
|
|||||||
"context"
|
"context"
|
||||||
"github.com/LukeHagar/plexgo/models/operations"
|
"github.com/LukeHagar/plexgo/models/operations"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -107,8 +104,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.2
|
version: 0.5.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
|
||||||
|
|||||||
44
hubs.go
44
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,14 +58,16 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,14 +174,16 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|||||||
218
library.go
218
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,14 +58,16 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,14 +417,16 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,14 +862,16 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
54
log.go
54
log.go
@@ -32,6 +32,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "logLine",
|
OperationID: "logLine",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: s.sdkConfiguration.Security,
|
SecuritySource: s.sdkConfiguration.Security,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,14 +59,16 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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
|
||||||
|
|||||||
54
media.go
54
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +57,16 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,14 +160,16 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,14 +265,16 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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
|
||||||
|
|||||||
182
playlists.go
182
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,14 +58,16 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,14 +173,16 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,14 +499,16 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,14 +606,16 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,14 +822,16 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -904,14 +937,16 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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
|
||||||
|
|||||||
36
plex.go
36
plex.go
@@ -32,6 +32,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getPin",
|
OperationID: "getPin",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: nil,
|
SecuritySource: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,14 +74,12 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
|
|||||||
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
|
||||||
@@ -157,6 +157,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
hookCtx := hooks.HookContext{
|
hookCtx := hooks.HookContext{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
OperationID: "getToken",
|
OperationID: "getToken",
|
||||||
|
OAuth2Scopes: []string{},
|
||||||
SecuritySource: nil,
|
SecuritySource: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,14 +195,12 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
|
|
||||||
utils.PopulateHeaders(ctx, req, request)
|
utils.PopulateHeaders(ctx, req, request)
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
25
plexapi.go
25
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
|
||||||
@@ -229,7 +228,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,9 +267,9 @@ func New(opts ...SDKOption) *PlexAPI {
|
|||||||
sdkConfiguration: sdkConfiguration{
|
sdkConfiguration: sdkConfiguration{
|
||||||
Language: "go",
|
Language: "go",
|
||||||
OpenAPIDocVersion: "0.0.3",
|
OpenAPIDocVersion: "0.0.3",
|
||||||
SDKVersion: "0.4.2",
|
SDKVersion: "0.5.1",
|
||||||
GenVersion: "2.272.7",
|
GenVersion: "2.280.6",
|
||||||
UserAgent: "speakeasy-sdk/go 0.4.2 2.272.7 0.0.3 github.com/LukeHagar/plexgo",
|
UserAgent: "speakeasy-sdk/go 0.5.1 2.280.6 0.0.3 github.com/LukeHagar/plexgo",
|
||||||
ServerDefaults: []map[string]string{
|
ServerDefaults: []map[string]string{
|
||||||
{
|
{
|
||||||
"protocol": "http",
|
"protocol": "http",
|
||||||
@@ -286,25 +285,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)
|
||||||
|
|||||||
58
search.go
58
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,14 +71,16 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
|||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,14 +179,16 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,14 +282,16 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
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
|
||||||
|
|||||||
172
server.go
172
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,14 +689,16 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
|||||||
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
|
||||||
|
|||||||
84
sessions.go
84
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +57,16 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
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
|
||||||
|
|||||||
58
updater.go
58
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,14 +164,16 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +268,16 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
|||||||
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
|
||||||
|
|||||||
36
video.go
36
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,14 +53,16 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
|||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,14 +152,16 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
|||||||
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