mirror of
https://github.com/LukeHagar/plexgo.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a382342e4 | ||
|
|
b8b984dc14 | ||
|
|
0de5991239 | ||
|
|
0ff88615e0 | ||
|
|
0eb6f2c692 | ||
|
|
0adacc0e13 |
@@ -3,10 +3,10 @@ id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
|
|||||||
management:
|
management:
|
||||||
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
|
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
|
||||||
docVersion: 0.0.3
|
docVersion: 0.0.3
|
||||||
speakeasyVersion: 1.228.1
|
speakeasyVersion: 1.245.0
|
||||||
generationVersion: 2.292.0
|
generationVersion: 2.301.3
|
||||||
releaseVersion: 0.6.0
|
releaseVersion: 0.6.3
|
||||||
configChecksum: 0a5d37a613eb2b27e32428c43ed96f05
|
configChecksum: 305403acfb42fec7c8e5f2903b30cf41
|
||||||
repoURL: https://github.com/LukeHagar/plexgo.git
|
repoURL: https://github.com/LukeHagar/plexgo.git
|
||||||
repoSubDirectory: .
|
repoSubDirectory: .
|
||||||
installationURL: https://github.com/LukeHagar/plexgo
|
installationURL: https://github.com/LukeHagar/plexgo
|
||||||
@@ -14,13 +14,13 @@ management:
|
|||||||
features:
|
features:
|
||||||
go:
|
go:
|
||||||
constsAndDefaults: 0.1.4
|
constsAndDefaults: 0.1.4
|
||||||
core: 3.4.5
|
core: 3.4.6
|
||||||
flattening: 2.81.1
|
flattening: 2.81.1
|
||||||
globalSecurity: 2.82.9
|
globalSecurity: 2.82.9
|
||||||
globalServerURLs: 2.82.2
|
globalServerURLs: 2.82.2
|
||||||
globals: 2.82.1
|
globals: 2.82.2
|
||||||
methodServerURLs: 2.82.1
|
methodServerURLs: 2.82.1
|
||||||
nameOverrides: 2.81.1
|
nameOverrides: 2.81.2
|
||||||
responseFormat: 0.1.0
|
responseFormat: 0.1.0
|
||||||
generatedFiles:
|
generatedFiles:
|
||||||
- server.go
|
- server.go
|
||||||
@@ -56,6 +56,7 @@ generatedFiles:
|
|||||||
- internal/utils/retries.go
|
- internal/utils/retries.go
|
||||||
- internal/utils/security.go
|
- internal/utils/security.go
|
||||||
- internal/utils/utils.go
|
- internal/utils/utils.go
|
||||||
|
- internal/globals/globals.go
|
||||||
- /models/operations/getservercapabilities.go
|
- /models/operations/getservercapabilities.go
|
||||||
- /models/operations/getserverpreferences.go
|
- /models/operations/getserverpreferences.go
|
||||||
- /models/operations/getavailableclients.go
|
- /models/operations/getavailableclients.go
|
||||||
@@ -362,10 +363,12 @@ generatedFiles:
|
|||||||
- docs/models/operations/loglineresponse.md
|
- docs/models/operations/loglineresponse.md
|
||||||
- docs/models/operations/logmultilineresponse.md
|
- docs/models/operations/logmultilineresponse.md
|
||||||
- docs/models/operations/enablepapertrailresponse.md
|
- docs/models/operations/enablepapertrailresponse.md
|
||||||
|
- docs/models/operations/getpinglobals.md
|
||||||
- docs/models/operations/getpinrequest.md
|
- docs/models/operations/getpinrequest.md
|
||||||
- docs/models/operations/location.md
|
- docs/models/operations/location.md
|
||||||
- docs/models/operations/getpinresponsebody.md
|
- docs/models/operations/getpinresponsebody.md
|
||||||
- docs/models/operations/getpinresponse.md
|
- docs/models/operations/getpinresponse.md
|
||||||
|
- docs/models/operations/gettokenglobals.md
|
||||||
- docs/models/operations/gettokenrequest.md
|
- docs/models/operations/gettokenrequest.md
|
||||||
- docs/models/operations/gettokenresponse.md
|
- docs/models/operations/gettokenresponse.md
|
||||||
- docs/models/operations/queryparamtype.md
|
- docs/models/operations/queryparamtype.md
|
||||||
|
|||||||
30
RELEASES.md
30
RELEASES.md
@@ -209,3 +209,33 @@ Based on:
|
|||||||
- [go v0.6.0] .
|
- [go v0.6.0] .
|
||||||
### Releases
|
### Releases
|
||||||
- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - .
|
- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - .
|
||||||
|
|
||||||
|
## 2024-04-03 00:44:02
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.235.0 (2.298.0) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.6.1] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - .
|
||||||
|
|
||||||
|
## 2024-04-09 00:44:53
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.244.0 (2.301.0) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.6.2] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.6.2] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.2 - .
|
||||||
|
|
||||||
|
## 2024-04-10 00:44:38
|
||||||
|
### Changes
|
||||||
|
Based on:
|
||||||
|
- OpenAPI Doc 0.0.3
|
||||||
|
- Speakeasy CLI 1.245.0 (2.301.3) https://github.com/speakeasy-api/speakeasy
|
||||||
|
### Generated
|
||||||
|
- [go v0.6.3] .
|
||||||
|
### Releases
|
||||||
|
- [Go v0.6.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.3 - .
|
||||||
@@ -153,7 +153,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -446,7 +446,7 @@ func (s *Butler) StopTask(ctx context.Context, taskName operations.PathParamTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
8
docs/models/operations/getpinglobals.md
Normal file
8
docs/models/operations/getpinglobals.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# GetPinGlobals
|
||||||
|
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||||
8
docs/models/operations/gettokenglobals.md
Normal file
8
docs/models/operations/gettokenglobals.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# GetTokenGlobals
|
||||||
|
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
|
||||||
2
gen.yaml
2
gen.yaml
@@ -12,7 +12,7 @@ generation:
|
|||||||
auth:
|
auth:
|
||||||
oAuth2ClientCredentialsEnabled: false
|
oAuth2ClientCredentialsEnabled: false
|
||||||
go:
|
go:
|
||||||
version: 0.6.0
|
version: 0.6.3
|
||||||
additionalDependencies: {}
|
additionalDependencies: {}
|
||||||
clientServerStatusCodesAsErrors: true
|
clientServerStatusCodesAsErrors: true
|
||||||
flattenGlobalSecurity: true
|
flattenGlobalSecurity: true
|
||||||
|
|||||||
6
hubs.go
6
hubs.go
@@ -54,7 +54,7 @@ func (s *Hubs) GetGlobalHubs(ctx context.Context, count *float64, onlyTransient
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
internal/globals/globals.go
Normal file
18
internal/globals/globals.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
||||||
|
|
||||||
|
package globals
|
||||||
|
|
||||||
|
type Globals struct {
|
||||||
|
// The unique identifier for the client application
|
||||||
|
// This is used to track the client application and its usage
|
||||||
|
// (UUID, serial number, or other number unique per device)
|
||||||
|
//
|
||||||
|
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Globals) GetXPlexClientIdentifier() string {
|
||||||
|
if o == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return o.XPlexClientIdentifier
|
||||||
|
}
|
||||||
@@ -10,15 +10,34 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}, globals map[string]map[string]map[string]interface{}) {
|
func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) {
|
||||||
|
globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{})
|
||||||
|
if globals != nil {
|
||||||
|
_ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string {
|
||||||
headerParamsStructType := reflect.TypeOf(headers)
|
headerParamsStructType := reflect.TypeOf(headers)
|
||||||
headerParamsValType := reflect.ValueOf(headers)
|
headerParamsValType := reflect.ValueOf(headers)
|
||||||
|
|
||||||
|
globalsAlreadyPopulated := []string{}
|
||||||
|
|
||||||
for i := 0; i < headerParamsStructType.NumField(); i++ {
|
for i := 0; i < headerParamsStructType.NumField(); i++ {
|
||||||
fieldType := headerParamsStructType.Field(i)
|
fieldType := headerParamsStructType.Field(i)
|
||||||
valType := headerParamsValType.Field(i)
|
valType := headerParamsValType.Field(i)
|
||||||
|
|
||||||
valType = populateFromGlobals(fieldType, valType, "header", globals)
|
if contains(skipFields, fieldType.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if globals != nil {
|
||||||
|
var globalFound bool
|
||||||
|
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals)
|
||||||
|
if globalFound {
|
||||||
|
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
|
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
|
||||||
if tag == nil {
|
if tag == nil {
|
||||||
@@ -27,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
|
|||||||
|
|
||||||
value := serializeHeader(fieldType.Type, valType, tag.Explode)
|
value := serializeHeader(fieldType.Type, valType, tag.Explode)
|
||||||
if value != "" {
|
if value != "" {
|
||||||
req.Header.Add(tag.ParamName, value)
|
reqHeaders.Add(tag.ParamName, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return globalsAlreadyPopulated
|
||||||
}
|
}
|
||||||
|
|
||||||
func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {
|
func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {
|
||||||
|
|||||||
@@ -16,18 +16,41 @@ import (
|
|||||||
"github.com/LukeHagar/plexgo/types"
|
"github.com/LukeHagar/plexgo/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GenerateURL(ctx context.Context, serverURL, path string, pathParams interface{}, globals map[string]map[string]map[string]interface{}) (string, error) {
|
func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) {
|
||||||
uri := strings.TrimSuffix(serverURL, "/") + path
|
uri := strings.TrimSuffix(serverURL, "/") + path
|
||||||
|
|
||||||
|
parsedParameters := map[string]string{}
|
||||||
|
|
||||||
|
globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if globals != nil {
|
||||||
|
_, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO should we handle the case where there are no matching path params?
|
||||||
|
return ReplaceParameters(uri, parsedParameters), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) {
|
||||||
pathParamsStructType := reflect.TypeOf(pathParams)
|
pathParamsStructType := reflect.TypeOf(pathParams)
|
||||||
pathParamsValType := reflect.ValueOf(pathParams)
|
pathParamsValType := reflect.ValueOf(pathParams)
|
||||||
|
|
||||||
parsedParameters := map[string]string{}
|
globalsAlreadyPopulated := []string{}
|
||||||
|
|
||||||
for i := 0; i < pathParamsStructType.NumField(); i++ {
|
for i := 0; i < pathParamsStructType.NumField(); i++ {
|
||||||
fieldType := pathParamsStructType.Field(i)
|
fieldType := pathParamsStructType.Field(i)
|
||||||
valType := pathParamsValType.Field(i)
|
valType := pathParamsValType.Field(i)
|
||||||
|
|
||||||
|
if contains(skipFields, fieldType.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
requestTag := getRequestTag(fieldType)
|
requestTag := getRequestTag(fieldType)
|
||||||
if requestTag != nil {
|
if requestTag != nil {
|
||||||
continue
|
continue
|
||||||
@@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
valType = populateFromGlobals(fieldType, valType, "pathParam", globals)
|
if globals != nil {
|
||||||
|
var globalFound bool
|
||||||
|
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals)
|
||||||
|
if globalFound {
|
||||||
|
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ppTag.Serialization != "" {
|
if ppTag.Serialization != "" {
|
||||||
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
|
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
for k, v := range vals {
|
for k, v := range vals {
|
||||||
parsedParameters[k] = url.PathEscape(v)
|
parsedParameters[k] = url.PathEscape(v)
|
||||||
@@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
|||||||
// TODO: support other styles
|
// TODO: support other styles
|
||||||
switch ppTag.Style {
|
switch ppTag.Style {
|
||||||
case "simple":
|
case "simple":
|
||||||
simpleParams := getSimplePathParams(ctx, ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
|
simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
|
||||||
for k, v := range simpleParams {
|
for k, v := range simpleParams {
|
||||||
parsedParameters[k] = v
|
parsedParameters[k] = v
|
||||||
}
|
}
|
||||||
@@ -60,11 +89,10 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should we handle the case where there are no matching path params?
|
return globalsAlreadyPopulated, nil
|
||||||
return ReplaceParameters(uri, parsedParameters), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
|
func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
|
||||||
pathParams := make(map[string]string)
|
pathParams := make(map[string]string)
|
||||||
|
|
||||||
if isNil(objType, objValue) {
|
if isNil(objType, objValue) {
|
||||||
|
|||||||
@@ -11,16 +11,40 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams interface{}, globals map[string]map[string]map[string]interface{}) error {
|
func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error {
|
||||||
|
values := url.Values{}
|
||||||
|
|
||||||
|
globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if globals != nil {
|
||||||
|
_, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.URL.RawQuery = values.Encode()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) {
|
||||||
queryParamsStructType := reflect.TypeOf(queryParams)
|
queryParamsStructType := reflect.TypeOf(queryParams)
|
||||||
queryParamsValType := reflect.ValueOf(queryParams)
|
queryParamsValType := reflect.ValueOf(queryParams)
|
||||||
|
|
||||||
values := url.Values{}
|
globalsAlreadyPopulated := []string{}
|
||||||
|
|
||||||
for i := 0; i < queryParamsStructType.NumField(); i++ {
|
for i := 0; i < queryParamsStructType.NumField(); i++ {
|
||||||
fieldType := queryParamsStructType.Field(i)
|
fieldType := queryParamsStructType.Field(i)
|
||||||
valType := queryParamsValType.Field(i)
|
valType := queryParamsValType.Field(i)
|
||||||
|
|
||||||
|
if contains(skipFields, fieldType.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
requestTag := getRequestTag(fieldType)
|
requestTag := getRequestTag(fieldType)
|
||||||
if requestTag != nil {
|
if requestTag != nil {
|
||||||
continue
|
continue
|
||||||
@@ -31,12 +55,18 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
valType = populateFromGlobals(fieldType, valType, "queryParam", globals)
|
if globals != nil {
|
||||||
|
var globalFound bool
|
||||||
|
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals)
|
||||||
|
if globalFound {
|
||||||
|
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if qpTag.Serialization != "" {
|
if qpTag.Serialization != "" {
|
||||||
vals, err := populateSerializedParams(qpTag, fieldType.Type, valType)
|
vals, err := populateSerializedParams(qpTag, fieldType.Type, valType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
for k, v := range vals {
|
for k, v := range vals {
|
||||||
values.Add(k, v)
|
values.Add(k, v)
|
||||||
@@ -44,35 +74,33 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
|
|||||||
} else {
|
} else {
|
||||||
switch qpTag.Style {
|
switch qpTag.Style {
|
||||||
case "deepObject":
|
case "deepObject":
|
||||||
vals := populateDeepObjectParams(req, qpTag, fieldType.Type, valType)
|
vals := populateDeepObjectParams(qpTag, fieldType.Type, valType)
|
||||||
for k, v := range vals {
|
for k, v := range vals {
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
values.Add(k, vv)
|
values.Add(k, vv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "form":
|
case "form":
|
||||||
vals := populateFormParams(req, qpTag, fieldType.Type, valType, ",")
|
vals := populateFormParams(qpTag, fieldType.Type, valType, ",")
|
||||||
for k, v := range vals {
|
for k, v := range vals {
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
values.Add(k, vv)
|
values.Add(k, vv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "pipeDelimited":
|
case "pipeDelimited":
|
||||||
vals := populateFormParams(req, qpTag, fieldType.Type, valType, "|")
|
vals := populateFormParams(qpTag, fieldType.Type, valType, "|")
|
||||||
for k, v := range vals {
|
for k, v := range vals {
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
values.Add(k, vv)
|
values.Add(k, vv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported style: %s", qpTag.Style)
|
return nil, fmt.Errorf("unsupported style: %s", qpTag.Style)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL.RawQuery = values.Encode()
|
return globalsAlreadyPopulated, nil
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) {
|
func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) {
|
||||||
@@ -98,7 +126,7 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl
|
|||||||
return values, nil
|
return values, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
|
func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
|
||||||
values := url.Values{}
|
values := url.Values{}
|
||||||
|
|
||||||
if isNil(objType, objValue) {
|
if isNil(objType, objValue) {
|
||||||
@@ -155,7 +183,7 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.
|
|||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateFormParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
|
func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
|
||||||
return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string {
|
return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string {
|
||||||
qpTag := parseQueryParamTag(fieldType)
|
qpTag := parseQueryParamTag(fieldType)
|
||||||
if qpTag == nil {
|
if qpTag == nil {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ var (
|
|||||||
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`)
|
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func SerializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||||
bodyReader, contentType, err := serializeRequestBody(ctx, request, nullable, optional, requestFieldName, serializationMethod, tag)
|
bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("error serializing request body: %w", err)
|
return nil, "", fmt.Errorf("error serializing request body: %w", err)
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, nullable, op
|
|||||||
return bodyReader, contentType, nil
|
return bodyReader, contentType, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func serializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
|
||||||
requestStructType := reflect.TypeOf(request)
|
requestStructType := reflect.TypeOf(request)
|
||||||
requestValType := reflect.ValueOf(request)
|
requestValType := reflect.ValueOf(request)
|
||||||
|
|
||||||
|
|||||||
@@ -158,23 +158,43 @@ func valToString(val interface{}) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals map[string]map[string]map[string]interface{}) reflect.Value {
|
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) {
|
||||||
if globals != nil && fieldType.Type.Kind() == reflect.Ptr {
|
if globals == nil {
|
||||||
parameters, ok := globals["parameters"]
|
return fieldType, valType, false
|
||||||
if ok {
|
|
||||||
paramsOfType, ok := parameters[paramType]
|
|
||||||
if ok {
|
|
||||||
globalVal, ok := paramsOfType[fieldType.Name]
|
|
||||||
if ok {
|
|
||||||
if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() {
|
|
||||||
valType = reflect.ValueOf(&globalVal)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalsStruct := reflect.TypeOf(globals)
|
||||||
|
globalsStructVal := reflect.ValueOf(globals)
|
||||||
|
|
||||||
|
globalsField, found := globalsStruct.FieldByName(fieldType.Name)
|
||||||
|
if !found {
|
||||||
|
return fieldType, valType, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() {
|
||||||
|
return fieldType, valType, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalsVal := globalsStructVal.FieldByName(fieldType.Name)
|
||||||
|
|
||||||
|
if !globalsVal.IsValid() {
|
||||||
|
return fieldType, valType, false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch paramType {
|
||||||
|
case queryParamTagKey:
|
||||||
|
qpTag := parseQueryParamTag(globalsField)
|
||||||
|
if qpTag == nil {
|
||||||
|
return fieldType, valType, false
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
tag := parseParamTag(paramType, fieldType, "simple", false)
|
||||||
|
if tag == nil {
|
||||||
|
return fieldType, valType, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return valType
|
return globalsField, globalsVal, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isNil(typ reflect.Type, val reflect.Value) bool {
|
func isNil(typ reflect.Type, val reflect.Value) bool {
|
||||||
@@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contains(arr []string, str string) bool {
|
||||||
|
for _, a := range arr {
|
||||||
|
if a == str {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
20
library.go
20
library.go
@@ -54,7 +54,7 @@ func (s *Library) GetFileHash(ctx context.Context, url_ string, type_ *float64)
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -634,7 +634,7 @@ func (s *Library) GetLibraryItems(ctx context.Context, sectionID int64, tag oper
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -729,7 +729,7 @@ func (s *Library) RefreshLibrary(ctx context.Context, sectionID float64) (*opera
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -846,7 +846,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -858,7 +858,7 @@ func (s *Library) SearchLibrary(ctx context.Context, sectionID int64, type_ oper
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,7 +945,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1055,7 +1055,7 @@ func (s *Library) GetMetadataChildren(ctx context.Context, ratingKey float64) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
2
log.go
2
log.go
@@ -55,7 +55,7 @@ func (s *Log) LogLine(ctx context.Context, level operations.Level, message strin
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
media.go
6
media.go
@@ -53,7 +53,7 @@ func (s *Media) MarkPlayed(ctx context.Context, key float64) (*operations.MarkPl
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,21 @@ var GetPinServerList = []string{
|
|||||||
"https://plex.tv/api/v2",
|
"https://plex.tv/api/v2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetPinGlobals struct {
|
||||||
|
// The unique identifier for the client application
|
||||||
|
// This is used to track the client application and its usage
|
||||||
|
// (UUID, serial number, or other number unique per device)
|
||||||
|
//
|
||||||
|
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *GetPinGlobals) GetXPlexClientIdentifier() string {
|
||||||
|
if o == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return o.XPlexClientIdentifier
|
||||||
|
}
|
||||||
|
|
||||||
type GetPinRequest struct {
|
type GetPinRequest struct {
|
||||||
// Determines the kind of code returned by the API call
|
// Determines the kind of code returned by the API call
|
||||||
// Strong codes are used for Pin authentication flows
|
// Strong codes are used for Pin authentication flows
|
||||||
|
|||||||
@@ -10,6 +10,21 @@ var GetTokenServerList = []string{
|
|||||||
"https://plex.tv/api/v2",
|
"https://plex.tv/api/v2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetTokenGlobals struct {
|
||||||
|
// The unique identifier for the client application
|
||||||
|
// This is used to track the client application and its usage
|
||||||
|
// (UUID, serial number, or other number unique per device)
|
||||||
|
//
|
||||||
|
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *GetTokenGlobals) GetXPlexClientIdentifier() string {
|
||||||
|
if o == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return o.XPlexClientIdentifier
|
||||||
|
}
|
||||||
|
|
||||||
type GetTokenRequest struct {
|
type GetTokenRequest struct {
|
||||||
// The PinID to retrieve an access token for
|
// The PinID to retrieve an access token for
|
||||||
PinID string `pathParam:"style=simple,explode=false,name=pinID"`
|
PinID string `pathParam:"style=simple,explode=false,name=pinID"`
|
||||||
|
|||||||
24
playlists.go
24
playlists.go
@@ -54,7 +54,7 @@ func (s *Playlists) CreatePlaylist(ctx context.Context, request operations.Creat
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, playlistID float64) (*op
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ func (s *Playlists) UpdatePlaylist(ctx context.Context, playlistID float64, titl
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -602,7 +602,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,7 +704,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -806,7 +806,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -818,7 +818,7 @@ func (s *Playlists) AddPlaylistContents(ctx context.Context, playlistID float64,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,7 +933,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
plex.go
23
plex.go
@@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/LukeHagar/plexgo/models/sdkerrors"
|
"github.com/LukeHagar/plexgo/models/sdkerrors"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Plex - API Calls that perform operations directly against https://Plex.tv
|
// Plex - API Calls that perform operations directly against https://Plex.tv
|
||||||
@@ -41,6 +40,10 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
|
|||||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globals := operations.GetPinGlobals{
|
||||||
|
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
|
||||||
|
}
|
||||||
|
|
||||||
o := operations.Options{}
|
o := operations.Options{}
|
||||||
supportedOptions := []string{
|
supportedOptions := []string{
|
||||||
operations.SupportedOptionServerURL,
|
operations.SupportedOptionServerURL,
|
||||||
@@ -56,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
|
|||||||
baseURL = *o.ServerURL
|
baseURL = *o.ServerURL
|
||||||
}
|
}
|
||||||
|
|
||||||
opURL, err := url.JoinPath(baseURL, "/pins")
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -68,9 +71,9 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals)
|
utils.PopulateHeaders(ctx, req, request, globals)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +169,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
XPlexClientIdentifier: xPlexClientIdentifier,
|
XPlexClientIdentifier: xPlexClientIdentifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globals := operations.GetTokenGlobals{
|
||||||
|
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
|
||||||
|
}
|
||||||
|
|
||||||
o := operations.Options{}
|
o := operations.Options{}
|
||||||
supportedOptions := []string{
|
supportedOptions := []string{
|
||||||
operations.SupportedOptionServerURL,
|
operations.SupportedOptionServerURL,
|
||||||
@@ -181,7 +188,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
baseURL = *o.ServerURL
|
baseURL = *o.ServerURL
|
||||||
}
|
}
|
||||||
|
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
@@ -193,7 +200,11 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals)
|
utils.PopulateHeaders(ctx, req, request, globals)
|
||||||
|
|
||||||
|
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
|
||||||
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
19
plexapi.go
19
plexapi.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/LukeHagar/plexgo/internal/globals"
|
||||||
"github.com/LukeHagar/plexgo/internal/hooks"
|
"github.com/LukeHagar/plexgo/internal/hooks"
|
||||||
"github.com/LukeHagar/plexgo/internal/utils"
|
"github.com/LukeHagar/plexgo/internal/utils"
|
||||||
"github.com/LukeHagar/plexgo/models/components"
|
"github.com/LukeHagar/plexgo/models/components"
|
||||||
@@ -53,7 +54,7 @@ type sdkConfiguration struct {
|
|||||||
SDKVersion string
|
SDKVersion string
|
||||||
GenVersion string
|
GenVersion string
|
||||||
UserAgent string
|
UserAgent string
|
||||||
Globals map[string]map[string]map[string]interface{}
|
Globals globals.Globals
|
||||||
RetryConfig *utils.RetryConfig
|
RetryConfig *utils.RetryConfig
|
||||||
Hooks *hooks.Hooks
|
Hooks *hooks.Hooks
|
||||||
}
|
}
|
||||||
@@ -259,11 +260,7 @@ func WithSecuritySource(security func(context.Context) (components.Security, err
|
|||||||
// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations
|
// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations
|
||||||
func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption {
|
func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption {
|
||||||
return func(sdk *PlexAPI) {
|
return func(sdk *PlexAPI) {
|
||||||
if _, ok := sdk.sdkConfiguration.Globals["parameters"]["header"]; !ok {
|
sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier
|
||||||
sdk.sdkConfiguration.Globals["parameters"]["header"] = map[string]interface{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
sdk.sdkConfiguration.Globals["parameters"]["header"]["XPlexClientIdentifier"] = xPlexClientIdentifier
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,12 +276,10 @@ func New(opts ...SDKOption) *PlexAPI {
|
|||||||
sdkConfiguration: sdkConfiguration{
|
sdkConfiguration: sdkConfiguration{
|
||||||
Language: "go",
|
Language: "go",
|
||||||
OpenAPIDocVersion: "0.0.3",
|
OpenAPIDocVersion: "0.0.3",
|
||||||
SDKVersion: "0.6.0",
|
SDKVersion: "0.6.3",
|
||||||
GenVersion: "2.292.0",
|
GenVersion: "2.301.3",
|
||||||
UserAgent: "speakeasy-sdk/go 0.6.0 2.292.0 0.0.3 github.com/LukeHagar/plexgo",
|
UserAgent: "speakeasy-sdk/go 0.6.3 2.301.3 0.0.3 github.com/LukeHagar/plexgo",
|
||||||
Globals: map[string]map[string]map[string]interface{}{
|
Globals: globals.Globals{},
|
||||||
"parameters": {},
|
|
||||||
},
|
|
||||||
ServerDefaults: []map[string]string{
|
ServerDefaults: []map[string]string{
|
||||||
{
|
{
|
||||||
"protocol": "http",
|
"protocol": "http",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -685,7 +685,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
|
||||||
opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, s.sdkConfiguration.Globals)
|
opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error generating URL: %w", err)
|
return nil, fmt.Errorf("error generating URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight,
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
video.go
4
video.go
@@ -49,7 +49,7 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
|
||||||
|
|
||||||
if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil {
|
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
|
||||||
return nil, fmt.Errorf("error populating query params: %w", err)
|
return nil, fmt.Errorf("error populating query params: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user