From 0ff88615e06234c4a160cb624284e1ec13269e1a Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 9 Apr 2024 00:45:22 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.244.0 --- .speakeasy/gen.lock | 13 ++++-- RELEASES.md | 12 ++++- activities.go | 2 +- authentication.go | 4 +- butler.go | 4 +- docs/models/operations/getpinglobals.md | 8 ++++ docs/models/operations/gettokenglobals.md | 8 ++++ gen.yaml | 2 +- go.mod | 4 +- hubs.go | 6 +-- internal/globals/globals.go | 18 +++++++ internal/utils/headers.go | 27 +++++++++-- internal/utils/pathparams.go | 44 +++++++++++++---- internal/utils/queryparams.go | 54 +++++++++++++++------ internal/utils/requestbody.go | 6 +-- internal/utils/utils.go | 57 +++++++++++++++++------ library.go | 20 ++++---- log.go | 2 +- media.go | 6 +-- models/operations/getpin.go | 15 ++++++ models/operations/gettoken.go | 15 ++++++ playlists.go | 24 +++++----- plex.go | 23 ++++++--- plexapi.go | 19 +++----- search.go | 6 +-- server.go | 2 +- sessions.go | 2 +- statistics.go | 2 +- updater.go | 4 +- video.go | 4 +- 30 files changed, 302 insertions(+), 111 deletions(-) create mode 100644 docs/models/operations/getpinglobals.md create mode 100644 docs/models/operations/gettokenglobals.md create mode 100644 internal/globals/globals.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 7967c64..67ad43f 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: dfa99515-01c0-42eb-9be5-ee212fd03eb3 management: docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae docVersion: 0.0.3 - speakeasyVersion: 1.235.0 - generationVersion: 2.298.0 - releaseVersion: 0.6.1 - configChecksum: d8f185571a23470089a80d835fcabcbb + speakeasyVersion: 1.244.0 + generationVersion: 2.301.0 + releaseVersion: 0.6.2 + configChecksum: acec136a1f3ec962b5f7a52fe3035935 repoURL: https://github.com/LukeHagar/plexgo.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexgo @@ -14,7 +14,7 @@ management: features: go: constsAndDefaults: 0.1.4 - core: 3.4.5 + core: 3.4.6 flattening: 2.81.1 globalSecurity: 2.82.9 globalServerURLs: 2.82.2 @@ -56,6 +56,7 @@ generatedFiles: - internal/utils/retries.go - internal/utils/security.go - internal/utils/utils.go + - internal/globals/globals.go - /models/operations/getservercapabilities.go - /models/operations/getserverpreferences.go - /models/operations/getavailableclients.go @@ -362,10 +363,12 @@ generatedFiles: - docs/models/operations/loglineresponse.md - docs/models/operations/logmultilineresponse.md - docs/models/operations/enablepapertrailresponse.md + - docs/models/operations/getpinglobals.md - docs/models/operations/getpinrequest.md - docs/models/operations/location.md - docs/models/operations/getpinresponsebody.md - docs/models/operations/getpinresponse.md + - docs/models/operations/gettokenglobals.md - docs/models/operations/gettokenrequest.md - docs/models/operations/gettokenresponse.md - docs/models/operations/queryparamtype.md diff --git a/RELEASES.md b/RELEASES.md index f0f92c3..7bb65eb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -218,4 +218,14 @@ Based on: ### Generated - [go v0.6.1] . ### Releases -- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - . \ No newline at end of file +- [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 - . \ No newline at end of file diff --git a/activities.go b/activities.go index ed96b92..ef135b0 100644 --- a/activities.go +++ b/activities.go @@ -153,7 +153,7 @@ func (s *Activities) CancelServerActivities(ctx context.Context, activityUUID st } 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 { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/authentication.go b/authentication.go index b15e7a0..7daea3a 100644 --- a/authentication.go +++ b/authentication.go @@ -54,7 +54,7 @@ func (s *Authentication) GetTransientToken(ctx context.Context, type_ operations req.Header.Set("Accept", "application/json") 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) } @@ -158,7 +158,7 @@ func (s *Authentication) GetSourceConnectionInformation(ctx context.Context, sou req.Header.Set("Accept", "application/json") 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) } diff --git a/butler.go b/butler.go index f876f3e..50bc0f8 100644 --- a/butler.go +++ b/butler.go @@ -345,7 +345,7 @@ func (s *Butler) StartTask(ctx context.Context, taskName operations.TaskName) (* } 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 { 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()) - 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 { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/docs/models/operations/getpinglobals.md b/docs/models/operations/getpinglobals.md new file mode 100644 index 0000000..f58c592 --- /dev/null +++ b/docs/models/operations/getpinglobals.md @@ -0,0 +1,8 @@ +# GetPinGlobals + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | 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)
| \ No newline at end of file diff --git a/docs/models/operations/gettokenglobals.md b/docs/models/operations/gettokenglobals.md new file mode 100644 index 0000000..803d687 --- /dev/null +++ b/docs/models/operations/gettokenglobals.md @@ -0,0 +1,8 @@ +# GetTokenGlobals + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | 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)
| \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index ed76a4e..a2f676c 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false go: - version: 0.6.1 + version: 0.6.2 additionalDependencies: {} clientServerStatusCodesAsErrors: true flattenGlobalSecurity: true diff --git a/go.mod b/go.mod index 3478755..fef7c63 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,10 @@ + module github.com/LukeHagar/plexgo go 1.20 require ( github.com/cenkalti/backoff/v4 v4.2.0 - github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 + github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 + github.com/spyzhov/ajson v0.8.0 ) diff --git a/hubs.go b/hubs.go index 460da4b..f77f969 100644 --- a/hubs.go +++ b/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("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) } @@ -158,7 +158,7 @@ func (s *Hubs) GetLibraryHubs(ctx context.Context, sectionID float64, count *flo } 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 { 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("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) } diff --git a/internal/globals/globals.go b/internal/globals/globals.go new file mode 100644 index 0000000..c53a33a --- /dev/null +++ b/internal/globals/globals.go @@ -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 +} diff --git a/internal/utils/headers.go b/internal/utils/headers.go index 734f96b..0249876 100644 --- a/internal/utils/headers.go +++ b/internal/utils/headers.go @@ -10,15 +10,34 @@ import ( "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) headerParamsValType := reflect.ValueOf(headers) + globalsAlreadyPopulated := []string{} + for i := 0; i < headerParamsStructType.NumField(); i++ { fieldType := headerParamsStructType.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) if tag == nil { @@ -27,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{} value := serializeHeader(fieldType.Type, valType, tag.Explode) if value != "" { - req.Header.Add(tag.ParamName, value) + reqHeaders.Add(tag.ParamName, value) } } + + return globalsAlreadyPopulated } func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { diff --git a/internal/utils/pathparams.go b/internal/utils/pathparams.go index 2782862..73e4ad9 100644 --- a/internal/utils/pathparams.go +++ b/internal/utils/pathparams.go @@ -16,18 +16,41 @@ import ( "github.com/LukeHagar/plexgo/types" ) -func GenerateURL(ctx context.Context, serverURL, path string, pathParams interface{}, globals map[string]map[string]map[string]interface{}) (string, error) { +func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { uri := strings.TrimSuffix(serverURL, "/") + path + parsedParameters := map[string]string{} + + globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{}) + if err != nil { + return "", err + } + + if globals != nil { + _, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated) + if err != nil { + return "", err + } + } + + // TODO should we handle the case where there are no matching path params? + return ReplaceParameters(uri, parsedParameters), nil +} + +func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) { pathParamsStructType := reflect.TypeOf(pathParams) pathParamsValType := reflect.ValueOf(pathParams) - parsedParameters := map[string]string{} + globalsAlreadyPopulated := []string{} for i := 0; i < pathParamsStructType.NumField(); i++ { fieldType := pathParamsStructType.Field(i) valType := pathParamsValType.Field(i) + if contains(skipFields, fieldType.Name) { + continue + } + requestTag := getRequestTag(fieldType) if requestTag != nil { continue @@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa continue } - valType = populateFromGlobals(fieldType, valType, "pathParam", globals) + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } if ppTag.Serialization != "" { vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) if err != nil { - return "", err + return nil, err } for k, v := range vals { parsedParameters[k] = url.PathEscape(v) @@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa // TODO: support other styles switch ppTag.Style { case "simple": - simpleParams := getSimplePathParams(ctx, ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) + simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) for k, v := range simpleParams { parsedParameters[k] = v } @@ -60,11 +89,10 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa } } - // TODO should we handle the case where there are no matching path params? - return ReplaceParameters(uri, parsedParameters), nil + return globalsAlreadyPopulated, nil } -func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { +func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { pathParams := make(map[string]string) if isNil(objType, objValue) { diff --git a/internal/utils/queryparams.go b/internal/utils/queryparams.go index 0e94bce..8d1bf47 100644 --- a/internal/utils/queryparams.go +++ b/internal/utils/queryparams.go @@ -11,16 +11,40 @@ import ( "reflect" ) -func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams interface{}, globals map[string]map[string]map[string]interface{}) error { +func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { + values := url.Values{} + + globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{}) + if err != nil { + return err + } + + if globals != nil { + _, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated) + if err != nil { + return err + } + } + + req.URL.RawQuery = values.Encode() + + return nil +} + +func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { queryParamsStructType := reflect.TypeOf(queryParams) queryParamsValType := reflect.ValueOf(queryParams) - values := url.Values{} + globalsAlreadyPopulated := []string{} for i := 0; i < queryParamsStructType.NumField(); i++ { fieldType := queryParamsStructType.Field(i) valType := queryParamsValType.Field(i) + if contains(skipFields, fieldType.Name) { + continue + } + requestTag := getRequestTag(fieldType) if requestTag != nil { continue @@ -31,12 +55,18 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int continue } - valType = populateFromGlobals(fieldType, valType, "queryParam", globals) + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } if qpTag.Serialization != "" { vals, err := populateSerializedParams(qpTag, fieldType.Type, valType) if err != nil { - return err + return nil, err } for k, v := range vals { values.Add(k, v) @@ -44,35 +74,33 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int } else { switch qpTag.Style { case "deepObject": - vals := populateDeepObjectParams(req, qpTag, fieldType.Type, valType) + vals := populateDeepObjectParams(qpTag, fieldType.Type, valType) for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "form": - vals := populateFormParams(req, qpTag, fieldType.Type, valType, ",") + vals := populateFormParams(qpTag, fieldType.Type, valType, ",") for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "pipeDelimited": - vals := populateFormParams(req, qpTag, fieldType.Type, valType, "|") + vals := populateFormParams(qpTag, fieldType.Type, valType, "|") for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } default: - return fmt.Errorf("unsupported style: %s", qpTag.Style) + return nil, fmt.Errorf("unsupported style: %s", qpTag.Style) } } } - req.URL.RawQuery = values.Encode() - - return nil + return globalsAlreadyPopulated, nil } func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { @@ -98,7 +126,7 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl return values, nil } -func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { +func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { values := url.Values{} if isNil(objType, objValue) { @@ -155,7 +183,7 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect. return values } -func populateFormParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { qpTag := parseQueryParamTag(fieldType) if qpTag == nil { diff --git a/internal/utils/requestbody.go b/internal/utils/requestbody.go index 322b8b3..cfb2ba6 100644 --- a/internal/utils/requestbody.go +++ b/internal/utils/requestbody.go @@ -25,8 +25,8 @@ var ( urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) ) -func SerializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { - bodyReader, contentType, err := serializeRequestBody(ctx, request, nullable, optional, requestFieldName, serializationMethod, tag) +func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag) if err != nil { return nil, "", fmt.Errorf("error serializing request body: %w", err) } @@ -38,7 +38,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, nullable, op return bodyReader, contentType, nil } -func serializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { +func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { requestStructType := reflect.TypeOf(request) requestValType := reflect.ValueOf(request) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 5508c5f..a35dc9b 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -158,23 +158,43 @@ func valToString(val interface{}) string { } } -func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals map[string]map[string]map[string]interface{}) reflect.Value { - if globals != nil && fieldType.Type.Kind() == reflect.Ptr { - parameters, ok := globals["parameters"] - if ok { - paramsOfType, ok := parameters[paramType] - if ok { - globalVal, ok := paramsOfType[fieldType.Name] - if ok { - if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() { - valType = reflect.ValueOf(&globalVal) - } - } - } +func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) { + if globals == nil { + return fieldType, valType, false + } + + globalsStruct := reflect.TypeOf(globals) + globalsStructVal := reflect.ValueOf(globals) + + globalsField, found := globalsStruct.FieldByName(fieldType.Name) + if !found { + return fieldType, valType, false + } + + if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() { + return fieldType, valType, true + } + + globalsVal := globalsStructVal.FieldByName(fieldType.Name) + + if !globalsVal.IsValid() { + return fieldType, valType, false + } + + switch paramType { + case queryParamTagKey: + qpTag := parseQueryParamTag(globalsField) + if qpTag == nil { + return fieldType, valType, false + } + default: + tag := parseParamTag(paramType, fieldType, "simple", false) + if tag == nil { + return fieldType, valType, false } } - return valType + return globalsField, globalsVal, true } func isNil(typ reflect.Type, val reflect.Value) bool { @@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool { return false } + +func contains(arr []string, str string) bool { + for _, a := range arr { + if a == str { + return true + } + } + return false +} diff --git a/library.go b/library.go index c012a6f..a07b770 100644 --- a/library.go +++ b/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("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) } @@ -401,7 +401,7 @@ func (s *Library) GetLibrary(ctx context.Context, sectionID float64, includeDeta } 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 { 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("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) } @@ -515,7 +515,7 @@ func (s *Library) DeleteLibrary(ctx context.Context, sectionID float64) (*operat } 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 { 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()) - 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 { 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()) - 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 { 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()) - 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 { 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("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) } @@ -945,7 +945,7 @@ func (s *Library) GetMetadata(ctx context.Context, ratingKey float64) (*operatio } 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 { 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()) - 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 { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/log.go b/log.go index c48727d..c009529 100644 --- a/log.go +++ b/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("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) } diff --git a/media.go b/media.go index 8c64af5..0067cf8 100644 --- a/media.go +++ b/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("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) } @@ -156,7 +156,7 @@ func (s *Media) MarkUnplayed(ctx context.Context, key float64) (*operations.Mark req.Header.Set("Accept", "application/json") 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) } @@ -261,7 +261,7 @@ func (s *Media) UpdatePlayProgress(ctx context.Context, key string, time float64 req.Header.Set("Accept", "application/json") 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) } diff --git a/models/operations/getpin.go b/models/operations/getpin.go index e2ae37a..215cee8 100644 --- a/models/operations/getpin.go +++ b/models/operations/getpin.go @@ -12,6 +12,21 @@ var GetPinServerList = []string{ "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 { // Determines the kind of code returned by the API call // Strong codes are used for Pin authentication flows diff --git a/models/operations/gettoken.go b/models/operations/gettoken.go index 7c121ea..5a184a6 100644 --- a/models/operations/gettoken.go +++ b/models/operations/gettoken.go @@ -10,6 +10,21 @@ var GetTokenServerList = []string{ "https://plex.tv/api/v2", } +type GetTokenGlobals struct { + // The unique identifier for the client application + // This is used to track the client application and its usage + // (UUID, serial number, or other number unique per device) + // + XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` +} + +func (o *GetTokenGlobals) GetXPlexClientIdentifier() string { + if o == nil { + return "" + } + return o.XPlexClientIdentifier +} + type GetTokenRequest struct { // The PinID to retrieve an access token for PinID string `pathParam:"style=simple,explode=false,name=pinID"` diff --git a/playlists.go b/playlists.go index 3321799..b8a8d1c 100644 --- a/playlists.go +++ b/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("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) } @@ -169,7 +169,7 @@ func (s *Playlists) GetPlaylists(ctx context.Context, playlistType *operations.P req.Header.Set("Accept", "application/json") 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) } @@ -272,7 +272,7 @@ func (s *Playlists) GetPlaylist(ctx context.Context, playlistID float64) (*opera } 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 { 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()) - 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 { 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()) - 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 { 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("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) } @@ -590,7 +590,7 @@ func (s *Playlists) GetPlaylistContents(ctx context.Context, playlistID float64, } 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 { 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("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) } @@ -704,7 +704,7 @@ func (s *Playlists) ClearPlaylistContents(ctx context.Context, playlistID float6 } 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 { 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()) - 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 { 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("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) } @@ -933,7 +933,7 @@ func (s *Playlists) UploadPlaylist(ctx context.Context, path string, force opera req.Header.Set("Accept", "application/json") 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) } diff --git a/plex.go b/plex.go index 202a0d6..5f19222 100644 --- a/plex.go +++ b/plex.go @@ -12,7 +12,6 @@ import ( "github.com/LukeHagar/plexgo/models/sdkerrors" "io" "net/http" - "net/url" ) // Plex - API Calls that perform operations directly against https://Plex.tv @@ -41,6 +40,10 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier * XPlexClientIdentifier: xPlexClientIdentifier, } + globals := operations.GetPinGlobals{ + XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier, + } + o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionServerURL, @@ -56,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier * baseURL = *o.ServerURL } - opURL, err := url.JoinPath(baseURL, "/pins") + opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -68,9 +71,9 @@ func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier * req.Header.Set("Accept", "application/json") 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) } @@ -166,6 +169,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier XPlexClientIdentifier: xPlexClientIdentifier, } + globals := operations.GetTokenGlobals{ + XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier, + } + o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionServerURL, @@ -181,7 +188,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, s.sdkConfiguration.Globals) + opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals) if err != nil { 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("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) if err != nil { diff --git a/plexapi.go b/plexapi.go index afcee7a..3321e95 100644 --- a/plexapi.go +++ b/plexapi.go @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/LukeHagar/plexgo/internal/globals" "github.com/LukeHagar/plexgo/internal/hooks" "github.com/LukeHagar/plexgo/internal/utils" "github.com/LukeHagar/plexgo/models/components" @@ -53,7 +54,7 @@ type sdkConfiguration struct { SDKVersion string GenVersion string UserAgent string - Globals map[string]map[string]map[string]interface{} + Globals globals.Globals RetryConfig *utils.RetryConfig 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 func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption { return func(sdk *PlexAPI) { - if _, ok := sdk.sdkConfiguration.Globals["parameters"]["header"]; !ok { - sdk.sdkConfiguration.Globals["parameters"]["header"] = map[string]interface{}{} - } - - sdk.sdkConfiguration.Globals["parameters"]["header"]["XPlexClientIdentifier"] = xPlexClientIdentifier + sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier } } @@ -279,12 +276,10 @@ func New(opts ...SDKOption) *PlexAPI { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.0.3", - SDKVersion: "0.6.1", - GenVersion: "2.298.0", - UserAgent: "speakeasy-sdk/go 0.6.1 2.298.0 0.0.3 github.com/LukeHagar/plexgo", - Globals: map[string]map[string]map[string]interface{}{ - "parameters": {}, - }, + SDKVersion: "0.6.2", + GenVersion: "2.301.0", + UserAgent: "speakeasy-sdk/go 0.6.2 2.301.0 0.0.3 github.com/LukeHagar/plexgo", + Globals: globals.Globals{}, ServerDefaults: []map[string]string{ { "protocol": "http", diff --git a/search.go b/search.go index f767754..8b5ffaa 100644 --- a/search.go +++ b/search.go @@ -67,7 +67,7 @@ func (s *Search) PerformSearch(ctx context.Context, query string, sectionID *flo req.Header.Set("Accept", "application/json") 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) } @@ -175,7 +175,7 @@ func (s *Search) PerformVoiceSearch(ctx context.Context, query string, sectionID req.Header.Set("Accept", "application/json") 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) } @@ -278,7 +278,7 @@ func (s *Search) GetSearchResults(ctx context.Context, query string) (*operation req.Header.Set("Accept", "application/json") 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) } diff --git a/server.go b/server.go index ee8ed0b..95ff49a 100644 --- a/server.go +++ b/server.go @@ -685,7 +685,7 @@ func (s *Server) GetResizedPhoto(ctx context.Context, request operations.GetResi req.Header.Set("Accept", "application/json") 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) } diff --git a/sessions.go b/sessions.go index 58ed539..b7f5912 100644 --- a/sessions.go +++ b/sessions.go @@ -359,7 +359,7 @@ func (s *Sessions) StopTranscodeSession(ctx context.Context, sessionKey string) } 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 { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/statistics.go b/statistics.go index 42d755c..2e2c84d 100644 --- a/statistics.go +++ b/statistics.go @@ -53,7 +53,7 @@ func (s *Statistics) GetStatistics(ctx context.Context, timespan *int64) (*opera req.Header.Set("Accept", "application/json") 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) } diff --git a/updater.go b/updater.go index ce17752..d4695ff 100644 --- a/updater.go +++ b/updater.go @@ -160,7 +160,7 @@ func (s *Updater) CheckForUpdates(ctx context.Context, download *operations.Down req.Header.Set("Accept", "application/json") 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) } @@ -264,7 +264,7 @@ func (s *Updater) ApplyUpdates(ctx context.Context, tonight *operations.Tonight, req.Header.Set("Accept", "application/json") 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) } diff --git a/video.go b/video.go index b0dd70e..69a6723 100644 --- a/video.go +++ b/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("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) } @@ -148,7 +148,7 @@ func (s *Video) StartUniversalTranscode(ctx context.Context, request operations. req.Header.Set("Accept", "application/json") 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) }