diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index bf6e0ce..41c64b3 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: dfa99515-01c0-42eb-9be5-ee212fd03eb3 management: - docChecksum: e34dac84738ebf2d447ea2b9055a6eeb + docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae docVersion: 0.0.3 - speakeasyVersion: 1.227.0 - generationVersion: 2.291.0 - releaseVersion: 0.5.3 - configChecksum: 518d95abe21d1a64d11134ba40435fa7 + speakeasyVersion: 1.228.1 + generationVersion: 2.292.0 + releaseVersion: 0.6.0 + configChecksum: 0a5d37a613eb2b27e32428c43ed96f05 repoURL: https://github.com/LukeHagar/plexgo.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexgo @@ -18,6 +18,7 @@ features: flattening: 2.81.1 globalSecurity: 2.82.9 globalServerURLs: 2.82.2 + globals: 2.82.1 methodServerURLs: 2.82.1 nameOverrides: 2.81.1 responseFormat: 0.1.0 diff --git a/README.md b/README.md index a5cacdf..baf1802 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ import ( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -184,6 +185,7 @@ import ( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -234,6 +236,7 @@ func main() { s := plexgo.New( plexgo.WithServerIndex(0), plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -272,6 +275,7 @@ func main() { s := plexgo.New( plexgo.WithServerURL("{protocol}://{ip}:{port}"), plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -299,14 +303,16 @@ import ( ) func main() { - s := plexgo.New() - - var xPlexClientIdentifier string = "" + s := plexgo.New( + plexgo.WithXPlexClientIdentifier(""), + ) var strong *bool = plexgo.Bool(false) + var xPlexClientIdentifier *string = plexgo.String("") + ctx := context.Background() - res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), xPlexClientIdentifier, strong) + res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), strong, xPlexClientIdentifier) if err != nil { log.Fatal(err) } @@ -371,6 +377,7 @@ import ( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -412,6 +419,59 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on ``` + +## Global Parameters + +A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed. + +For example, you can set `X-Plex-Client-Identifier` to `""` at SDK initialization and then you do not have to pass the same value on calls to operations like `GetPin`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration. + + +### Available Globals + +The following global parameter is available. The required parameter must be set when you initialize the SDK client. + +| Name | Type | Required | Description | +| ---- | ---- |:--------:| ----------- | +| XPlexClientIdentifier | string | ✔️ | The unique identifier for the client application +This is used to track the client application and its usage +(UUID, serial number, or other number unique per device) + | + + +### Example + +```go +package main + +import ( + "context" + "github.com/LukeHagar/plexgo" + "log" +) + +func main() { + s := plexgo.New( + plexgo.WithXPlexClientIdentifier(""), + ) + + var strong *bool = plexgo.Bool(false) + + var xPlexClientIdentifier *string = plexgo.String("") + + ctx := context.Background() + res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier) + if err != nil { + log.Fatal(err) + } + if res.Object != nil { + // handle response + } +} + +``` + + # Development diff --git a/RELEASES.md b/RELEASES.md index d0dc1a1..a5fa9c7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -198,4 +198,14 @@ Based on: ### Generated - [go v0.5.3] . ### Releases -- [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - . \ No newline at end of file +- [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - . + +## 2024-03-29 16:37:06 +### Changes +Based on: +- OpenAPI Doc 0.0.3 +- Speakeasy CLI 1.228.1 (2.292.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.6.0] . +### Releases +- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index ca80a8c..97fce59 100644 --- a/USAGE.md +++ b/USAGE.md @@ -12,6 +12,7 @@ import ( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() diff --git a/activities.go b/activities.go index ef135b0..ed96b92 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/activities/{activityUUID}", request, s.sdkConfiguration.Globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/authentication.go b/authentication.go index 7daea3a..b15e7a0 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/butler.go b/butler.go index 50bc0f8..f876f3e 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/butler/{taskName}", request, s.sdkConfiguration.Globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/docs/models/operations/getpinrequest.md b/docs/models/operations/getpinrequest.md index 7c30038..8a46bf3 100644 --- a/docs/models/operations/getpinrequest.md +++ b/docs/models/operations/getpinrequest.md @@ -5,5 +5,5 @@ | 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)
| -| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| \ No newline at end of file +| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| +| `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | 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/gettokenrequest.md b/docs/models/operations/gettokenrequest.md index d4d7a73..ec99110 100644 --- a/docs/models/operations/gettokenrequest.md +++ b/docs/models/operations/gettokenrequest.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | -| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application
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 +| `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | 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/sdks/activities/README.md b/docs/sdks/activities/README.md index 4befe04..b12dce0 100644 --- a/docs/sdks/activities/README.md +++ b/docs/sdks/activities/README.md @@ -36,6 +36,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -83,6 +84,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/authentication/README.md b/docs/sdks/authentication/README.md index cf6c7d2..a7da5df 100644 --- a/docs/sdks/authentication/README.md +++ b/docs/sdks/authentication/README.md @@ -32,6 +32,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -88,6 +89,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/butler/README.md b/docs/sdks/butler/README.md index c472ca7..7c5a34e 100644 --- a/docs/sdks/butler/README.md +++ b/docs/sdks/butler/README.md @@ -33,6 +33,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -85,6 +86,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -133,6 +135,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -186,6 +189,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -239,6 +243,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/hubs/README.md b/docs/sdks/hubs/README.md index 00b3bb2..8a18861 100644 --- a/docs/sdks/hubs/README.md +++ b/docs/sdks/hubs/README.md @@ -31,6 +31,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -87,6 +88,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/library/README.md b/docs/sdks/library/README.md index 15547c0..f61abe5 100644 --- a/docs/sdks/library/README.md +++ b/docs/sdks/library/README.md @@ -39,6 +39,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -94,6 +95,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -147,6 +149,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -234,6 +237,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -288,6 +292,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -360,6 +365,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -414,6 +420,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -484,6 +491,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -538,6 +546,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -590,6 +599,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -642,6 +652,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() diff --git a/docs/sdks/log/README.md b/docs/sdks/log/README.md index 2dd62ca..a4ca0f2 100644 --- a/docs/sdks/log/README.md +++ b/docs/sdks/log/README.md @@ -33,6 +33,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -111,6 +112,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -162,6 +164,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() diff --git a/docs/sdks/media/README.md b/docs/sdks/media/README.md index f77659c..9055dae 100644 --- a/docs/sdks/media/README.md +++ b/docs/sdks/media/README.md @@ -31,6 +31,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -82,6 +83,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -134,6 +136,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/playlists/README.md b/docs/sdks/playlists/README.md index 50c9ec1..cc55c63 100644 --- a/docs/sdks/playlists/README.md +++ b/docs/sdks/playlists/README.md @@ -44,6 +44,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -98,6 +99,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -154,6 +156,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -206,6 +209,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -258,6 +262,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -319,6 +324,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -374,6 +380,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -427,6 +434,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -486,6 +494,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/plex/README.md b/docs/sdks/plex/README.md index a4680c1..e9df431 100644 --- a/docs/sdks/plex/README.md +++ b/docs/sdks/plex/README.md @@ -27,15 +27,17 @@ import( ) func main() { - s := plexgo.New() + s := plexgo.New( + plexgo.WithXPlexClientIdentifier(""), + ) - var xPlexClientIdentifier string = "" - var strong *bool = plexgo.Bool(false) + var xPlexClientIdentifier *string = plexgo.String("") + ctx := context.Background() - res, err := s.Plex.GetPin(ctx, xPlexClientIdentifier, strong) + res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier) if err != nil { log.Fatal(err) } @@ -50,8 +52,8 @@ func main() { | Parameter | Type | Required | Description | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
| | `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| +| `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | 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)
| | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | @@ -79,12 +81,14 @@ import( ) func main() { - s := plexgo.New() + s := plexgo.New( + plexgo.WithXPlexClientIdentifier(""), + ) var pinID string = "" - var xPlexClientIdentifier string = "" + var xPlexClientIdentifier *string = plexgo.String("") ctx := context.Background() res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier) @@ -103,7 +107,7 @@ func main() { | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | -| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
| +| `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | 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)
| | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | diff --git a/docs/sdks/search/README.md b/docs/sdks/search/README.md index 954d8f9..71e6942 100644 --- a/docs/sdks/search/README.md +++ b/docs/sdks/search/README.md @@ -43,6 +43,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -104,6 +105,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -161,6 +163,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/server/README.md b/docs/sdks/server/README.md index cdcf4aa..82aaa5b 100644 --- a/docs/sdks/server/README.md +++ b/docs/sdks/server/README.md @@ -36,6 +36,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -83,6 +84,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -130,6 +132,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -177,6 +180,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -224,6 +228,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -271,6 +276,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -320,6 +326,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -376,6 +383,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() diff --git a/docs/sdks/sessions/README.md b/docs/sdks/sessions/README.md index 67dbbb0..c544ecc 100644 --- a/docs/sdks/sessions/README.md +++ b/docs/sdks/sessions/README.md @@ -32,6 +32,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -79,6 +80,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -126,6 +128,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -173,6 +176,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/statistics/README.md b/docs/sdks/statistics/README.md index 8cb14f1..51fe78b 100644 --- a/docs/sdks/statistics/README.md +++ b/docs/sdks/statistics/README.md @@ -29,6 +29,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/updater/README.md b/docs/sdks/updater/README.md index f145cde..fea76e1 100644 --- a/docs/sdks/updater/README.md +++ b/docs/sdks/updater/README.md @@ -32,6 +32,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -80,6 +81,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) @@ -133,6 +135,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) diff --git a/docs/sdks/video/README.md b/docs/sdks/video/README.md index 160cfdf..af0b3a1 100644 --- a/docs/sdks/video/README.md +++ b/docs/sdks/video/README.md @@ -31,6 +31,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() @@ -91,6 +92,7 @@ import( func main() { s := plexgo.New( plexgo.WithSecurity(""), + plexgo.WithXPlexClientIdentifier(""), ) ctx := context.Background() diff --git a/gen.yaml b/gen.yaml index 1ea6c99..e7d27cf 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false go: - version: 0.5.3 + version: 0.6.0 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 f77f969..460da4b 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/hubs/sections/{sectionId}", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/library.go b/library.go index a07b770..c012a6f 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/{tag}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/refresh", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/sections/{sectionId}/search", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/library/metadata/{ratingKey}/children", request, s.sdkConfiguration.Globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/log.go b/log.go index c009529..c48727d 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/media.go b/media.go index 0067cf8..8c64af5 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/models/operations/getpin.go b/models/operations/getpin.go index 8a2abc9..e2ae37a 100644 --- a/models/operations/getpin.go +++ b/models/operations/getpin.go @@ -13,16 +13,16 @@ var GetPinServerList = []string{ } type GetPinRequest struct { - // The unique identifier for the client application - // This is used to track the client application and its usage - // (UUID, serial number, or other number unique per device) - // - XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` // Determines the kind of code returned by the API call // Strong codes are used for Pin authentication flows // Non-Strong codes are used for `Plex.tv/link` // Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"` + // The unique identifier for the client application + // This is used to track the client application and its usage + // (UUID, serial number, or other number unique per device) + // + XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` } func (g GetPinRequest) MarshalJSON() ([]byte, error) { @@ -36,13 +36,6 @@ func (g *GetPinRequest) UnmarshalJSON(data []byte) error { return nil } -func (o *GetPinRequest) GetXPlexClientIdentifier() string { - if o == nil { - return "" - } - return o.XPlexClientIdentifier -} - func (o *GetPinRequest) GetStrong() *bool { if o == nil { return nil @@ -50,6 +43,13 @@ func (o *GetPinRequest) GetStrong() *bool { return o.Strong } +func (o *GetPinRequest) GetXPlexClientIdentifier() *string { + if o == nil { + return nil + } + return o.XPlexClientIdentifier +} + type Location struct { Code *string `json:"code,omitempty"` EuropeanUnionMember *bool `json:"european_union_member,omitempty"` diff --git a/models/operations/gettoken.go b/models/operations/gettoken.go index f9d5c34..7c121ea 100644 --- a/models/operations/gettoken.go +++ b/models/operations/gettoken.go @@ -17,7 +17,7 @@ type GetTokenRequest struct { // This is used to track the client application and its usage // (UUID, serial number, or other number unique per device) // - XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` + XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` } func (o *GetTokenRequest) GetPinID() string { @@ -27,9 +27,9 @@ func (o *GetTokenRequest) GetPinID() string { return o.PinID } -func (o *GetTokenRequest) GetXPlexClientIdentifier() string { +func (o *GetTokenRequest) GetXPlexClientIdentifier() *string { if o == nil { - return "" + return nil } return o.XPlexClientIdentifier } diff --git a/playlists.go b/playlists.go index b8a8d1c..3321799 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/playlists/{playlistID}/items", request, s.sdkConfiguration.Globals) 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/plex.go b/plex.go index a47064b..202a0d6 100644 --- a/plex.go +++ b/plex.go @@ -28,7 +28,7 @@ func newPlex(sdkConfig sdkConfiguration) *Plex { // GetPin - Get a Pin // Retrieve a Pin from Plex.tv for authentication flows -func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong *bool, opts ...operations.Option) (*operations.GetPinResponse, error) { +func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetPinResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getPin", @@ -37,8 +37,8 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong } request := operations.GetPinRequest{ - XPlexClientIdentifier: xPlexClientIdentifier, Strong: strong, + XPlexClientIdentifier: xPlexClientIdentifier, } o := operations.Options{} @@ -68,9 +68,9 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - utils.PopulateHeaders(ctx, req, request, nil) + utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals) - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -153,7 +153,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong // GetToken - Get Access Token // Retrieve an Access Token from Plex.tv after the Pin has already been authenticated -func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier string, opts ...operations.Option) (*operations.GetTokenResponse, error) { +func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetTokenResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getToken", @@ -181,7 +181,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, s.sdkConfiguration.Globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } @@ -193,7 +193,7 @@ 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, nil) + utils.PopulateHeaders(ctx, req, request, s.sdkConfiguration.Globals) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { diff --git a/plexapi.go b/plexapi.go index 016cd01..8ca27ba 100644 --- a/plexapi.go +++ b/plexapi.go @@ -53,6 +53,7 @@ type sdkConfiguration struct { SDKVersion string GenVersion string UserAgent string + Globals map[string]map[string]map[string]interface{} RetryConfig *utils.RetryConfig Hooks *hooks.Hooks } @@ -255,6 +256,17 @@ func WithSecuritySource(security func(context.Context) (components.Security, err } } +// WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations +func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption { + return func(sdk *PlexAPI) { + if _, ok := sdk.sdkConfiguration.Globals["parameters"]["header"]; !ok { + sdk.sdkConfiguration.Globals["parameters"]["header"] = map[string]interface{}{} + } + + sdk.sdkConfiguration.Globals["parameters"]["header"]["XPlexClientIdentifier"] = xPlexClientIdentifier + } +} + func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption { return func(sdk *PlexAPI) { sdk.sdkConfiguration.RetryConfig = &retryConfig @@ -267,9 +279,12 @@ func New(opts ...SDKOption) *PlexAPI { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.0.3", - SDKVersion: "0.5.3", - GenVersion: "2.291.0", - UserAgent: "speakeasy-sdk/go 0.5.3 2.291.0 0.0.3 github.com/LukeHagar/plexgo", + SDKVersion: "0.6.0", + GenVersion: "2.292.0", + UserAgent: "speakeasy-sdk/go 0.6.0 2.292.0 0.0.3 github.com/LukeHagar/plexgo", + Globals: map[string]map[string]map[string]interface{}{ + "parameters": {}, + }, ServerDefaults: []map[string]string{ { "protocol": "http", diff --git a/search.go b/search.go index 8b5ffaa..f767754 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/server.go b/server.go index 95ff49a..ee8ed0b 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/sessions.go b/sessions.go index b7f5912..58ed539 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, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/transcode/sessions/{sessionKey}", request, s.sdkConfiguration.Globals) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } diff --git a/statistics.go b/statistics.go index 2e2c84d..42d755c 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/updater.go b/updater.go index d4695ff..ce17752 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } diff --git a/video.go b/video.go index 69a6723..b0dd70e 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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) } @@ -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, nil); err != nil { + if err := utils.PopulateQueryParams(ctx, req, request, s.sdkConfiguration.Globals); err != nil { return nil, fmt.Errorf("error populating query params: %w", err) }