Compare commits

...

6 Commits

Author SHA1 Message Date
speakeasy-github
0de5991239 chore: update dependencies 2024-04-09 00:45:54 +00:00
speakeasybot
0ff88615e0 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.244.0 2024-04-09 00:45:22 +00:00
speakeasy-github
0eb6f2c692 chore: update dependencies 2024-04-03 00:45:14 +00:00
speakeasybot
0adacc0e13 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.235.0 2024-04-03 00:44:28 +00:00
speakeasy-github[bot]
ec6ef7db64 chore: update dependencies 2024-03-29 16:38:18 +00:00
speakeasybot
32a5beaae6 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.228.1 2024-03-29 16:37:36 +00:00
34 changed files with 436 additions and 88 deletions

View File

@@ -1,12 +1,12 @@
lockVersion: 2.0.0 lockVersion: 2.0.0
id: dfa99515-01c0-42eb-9be5-ee212fd03eb3 id: dfa99515-01c0-42eb-9be5-ee212fd03eb3
management: management:
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: 1.227.0 speakeasyVersion: 1.244.0
generationVersion: 2.291.0 generationVersion: 2.301.0
releaseVersion: 0.5.3 releaseVersion: 0.6.2
configChecksum: 518d95abe21d1a64d11134ba40435fa7 configChecksum: acec136a1f3ec962b5f7a52fe3035935
repoURL: https://github.com/LukeHagar/plexgo.git repoURL: https://github.com/LukeHagar/plexgo.git
repoSubDirectory: . repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexgo installationURL: https://github.com/LukeHagar/plexgo
@@ -14,12 +14,13 @@ management:
features: features:
go: go:
constsAndDefaults: 0.1.4 constsAndDefaults: 0.1.4
core: 3.4.5 core: 3.4.6
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.82.9 globalSecurity: 2.82.9
globalServerURLs: 2.82.2 globalServerURLs: 2.82.2
globals: 2.82.1
methodServerURLs: 2.82.1 methodServerURLs: 2.82.1
nameOverrides: 2.81.1 nameOverrides: 2.81.2
responseFormat: 0.1.0 responseFormat: 0.1.0
generatedFiles: generatedFiles:
- server.go - server.go
@@ -55,6 +56,7 @@ generatedFiles:
- internal/utils/retries.go - internal/utils/retries.go
- internal/utils/security.go - internal/utils/security.go
- internal/utils/utils.go - internal/utils/utils.go
- internal/globals/globals.go
- /models/operations/getservercapabilities.go - /models/operations/getservercapabilities.go
- /models/operations/getserverpreferences.go - /models/operations/getserverpreferences.go
- /models/operations/getavailableclients.go - /models/operations/getavailableclients.go
@@ -361,10 +363,12 @@ generatedFiles:
- docs/models/operations/loglineresponse.md - docs/models/operations/loglineresponse.md
- docs/models/operations/logmultilineresponse.md - docs/models/operations/logmultilineresponse.md
- docs/models/operations/enablepapertrailresponse.md - docs/models/operations/enablepapertrailresponse.md
- docs/models/operations/getpinglobals.md
- docs/models/operations/getpinrequest.md - docs/models/operations/getpinrequest.md
- docs/models/operations/location.md - docs/models/operations/location.md
- docs/models/operations/getpinresponsebody.md - docs/models/operations/getpinresponsebody.md
- docs/models/operations/getpinresponse.md - docs/models/operations/getpinresponse.md
- docs/models/operations/gettokenglobals.md
- docs/models/operations/gettokenrequest.md - docs/models/operations/gettokenrequest.md
- docs/models/operations/gettokenresponse.md - docs/models/operations/gettokenresponse.md
- docs/models/operations/queryparamtype.md - docs/models/operations/queryparamtype.md

View File

@@ -33,6 +33,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -184,6 +185,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -234,6 +236,7 @@ func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithServerIndex(0), plexgo.WithServerIndex(0),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -272,6 +275,7 @@ func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithServerURL("{protocol}://{ip}:{port}"), plexgo.WithServerURL("{protocol}://{ip}:{port}"),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -299,14 +303,16 @@ import (
) )
func main() { func main() {
s := plexgo.New() s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"),
var xPlexClientIdentifier string = "<value>" )
var strong *bool = plexgo.Bool(false) var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), xPlexClientIdentifier, strong) res, err := s.Plex.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), strong, xPlexClientIdentifier)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@@ -371,6 +377,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -412,6 +419,59 @@ d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on
``` ```
<!-- End Special Types [types] --> <!-- End Special Types [types] -->
<!-- Start Global Parameters [global-parameters] -->
## Global Parameters
A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set `X-Plex-Client-Identifier` to `"<value>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `GetPin`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
### Available Globals
The following global parameter is available. The required parameter must be set when you initialize the SDK client.
| Name | Type | Required | Description |
| ---- | ---- |:--------:| ----------- |
| XPlexClientIdentifier | string | ✔️ | The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
|
### Example
```go
package main
import (
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"),
)
var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>")
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
<!-- End Global Parameters [global-parameters] -->
<!-- Placeholder for Future Speakeasy SDK Sections --> <!-- Placeholder for Future Speakeasy SDK Sections -->
# Development # Development

View File

@@ -199,3 +199,33 @@ Based on:
- [go v0.5.3] . - [go v0.5.3] .
### Releases ### Releases
- [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - . - [Go v0.5.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.5.3 - .
## 2024-03-29 16:37:06
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.228.1 (2.292.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.0] .
### Releases
- [Go v0.6.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.0 - .
## 2024-04-03 00:44:02
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.235.0 (2.298.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.6.1] .
### Releases
- [Go v0.6.1] https://github.com/LukeHagar/plexgo/releases/tag/v0.6.1 - .
## 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 - .

View File

@@ -12,6 +12,7 @@ import (
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -0,0 +1,8 @@
# GetPinGlobals
## Fields
| Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -5,5 +5,5 @@
| Field | Type | Required | Description | | Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | | `Strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -0,0 +1,8 @@
# GetTokenGlobals
## Fields
| Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -6,4 +6,4 @@
| Field | Type | Required | Description | | Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | | `XPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -36,6 +36,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -83,6 +84,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -32,6 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -88,6 +89,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -33,6 +33,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -85,6 +86,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -133,6 +135,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -186,6 +189,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -239,6 +243,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -31,6 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -87,6 +88,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -39,6 +39,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -94,6 +95,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -147,6 +149,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -234,6 +237,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -288,6 +292,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -360,6 +365,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -414,6 +420,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -484,6 +491,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -538,6 +546,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -590,6 +599,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -642,6 +652,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -33,6 +33,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -111,6 +112,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -162,6 +164,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -31,6 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -82,6 +83,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -134,6 +136,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -44,6 +44,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -98,6 +99,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -154,6 +156,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -206,6 +209,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -258,6 +262,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -319,6 +324,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -374,6 +380,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -427,6 +434,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -486,6 +494,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -27,15 +27,17 @@ import(
) )
func main() { func main() {
s := plexgo.New() s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"),
)
var xPlexClientIdentifier string = "<value>"
var strong *bool = plexgo.Bool(false) var strong *bool = plexgo.Bool(false)
var xPlexClientIdentifier *string = plexgo.String("<value>")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetPin(ctx, xPlexClientIdentifier, strong) res, err := s.Plex.GetPin(ctx, strong, xPlexClientIdentifier)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@@ -50,8 +52,8 @@ func main() {
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | | `strong` | **bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
@@ -79,12 +81,14 @@ import(
) )
func main() { func main() {
s := plexgo.New() s := plexgo.New(
plexgo.WithXPlexClientIdentifier("<value>"),
)
var pinID string = "<value>" var pinID string = "<value>"
var xPlexClientIdentifier string = "<value>" var xPlexClientIdentifier *string = plexgo.String("<value>")
ctx := context.Background() ctx := context.Background()
res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier) res, err := s.Plex.GetToken(ctx, pinID, xPlexClientIdentifier)
@@ -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. | | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | | `xPlexClientIdentifier` | **string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |

View File

@@ -43,6 +43,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -104,6 +105,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -161,6 +163,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -36,6 +36,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -83,6 +84,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -130,6 +132,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -177,6 +180,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -224,6 +228,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -271,6 +276,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -320,6 +326,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -376,6 +383,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -32,6 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -79,6 +80,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -126,6 +128,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -173,6 +176,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -29,6 +29,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -32,6 +32,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -80,6 +81,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
@@ -133,6 +135,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )

View File

@@ -31,6 +31,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()
@@ -91,6 +92,7 @@ import(
func main() { func main() {
s := plexgo.New( s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"), plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("<value>"),
) )
ctx := context.Background() ctx := context.Background()

View File

@@ -12,7 +12,7 @@ generation:
auth: auth:
oAuth2ClientCredentialsEnabled: false oAuth2ClientCredentialsEnabled: false
go: go:
version: 0.5.3 version: 0.6.2
additionalDependencies: {} additionalDependencies: {}
clientServerStatusCodesAsErrors: true clientServerStatusCodesAsErrors: true
flattenGlobalSecurity: true flattenGlobalSecurity: true

View File

@@ -0,0 +1,18 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package globals
type Globals struct {
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *Globals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}

View File

@@ -10,15 +10,34 @@ import (
"strings" "strings"
) )
func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}, globals map[string]map[string]map[string]interface{}) { func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) {
globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{})
if globals != nil {
_ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated)
}
}
func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string {
headerParamsStructType := reflect.TypeOf(headers) headerParamsStructType := reflect.TypeOf(headers)
headerParamsValType := reflect.ValueOf(headers) headerParamsValType := reflect.ValueOf(headers)
globalsAlreadyPopulated := []string{}
for i := 0; i < headerParamsStructType.NumField(); i++ { for i := 0; i < headerParamsStructType.NumField(); i++ {
fieldType := headerParamsStructType.Field(i) fieldType := headerParamsStructType.Field(i)
valType := headerParamsValType.Field(i) valType := headerParamsValType.Field(i)
valType = populateFromGlobals(fieldType, valType, "header", globals) if contains(skipFields, fieldType.Name) {
continue
}
if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) tag := parseParamTag(headerParamTagKey, fieldType, "simple", false)
if tag == nil { if tag == nil {
@@ -27,9 +46,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{}
value := serializeHeader(fieldType.Type, valType, tag.Explode) value := serializeHeader(fieldType.Type, valType, tag.Explode)
if value != "" { if value != "" {
req.Header.Add(tag.ParamName, value) reqHeaders.Add(tag.ParamName, value)
} }
} }
return globalsAlreadyPopulated
} }
func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string {

View File

@@ -16,18 +16,41 @@ import (
"github.com/LukeHagar/plexgo/types" "github.com/LukeHagar/plexgo/types"
) )
func GenerateURL(ctx context.Context, serverURL, path string, pathParams interface{}, globals map[string]map[string]map[string]interface{}) (string, error) { func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) {
uri := strings.TrimSuffix(serverURL, "/") + path uri := strings.TrimSuffix(serverURL, "/") + path
parsedParameters := map[string]string{}
globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{})
if err != nil {
return "", err
}
if globals != nil {
_, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated)
if err != nil {
return "", err
}
}
// TODO should we handle the case where there are no matching path params?
return ReplaceParameters(uri, parsedParameters), nil
}
func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) {
pathParamsStructType := reflect.TypeOf(pathParams) pathParamsStructType := reflect.TypeOf(pathParams)
pathParamsValType := reflect.ValueOf(pathParams) pathParamsValType := reflect.ValueOf(pathParams)
parsedParameters := map[string]string{} globalsAlreadyPopulated := []string{}
for i := 0; i < pathParamsStructType.NumField(); i++ { for i := 0; i < pathParamsStructType.NumField(); i++ {
fieldType := pathParamsStructType.Field(i) fieldType := pathParamsStructType.Field(i)
valType := pathParamsValType.Field(i) valType := pathParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
requestTag := getRequestTag(fieldType) requestTag := getRequestTag(fieldType)
if requestTag != nil { if requestTag != nil {
continue continue
@@ -38,12 +61,18 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
continue continue
} }
valType = populateFromGlobals(fieldType, valType, "pathParam", globals) if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
if ppTag.Serialization != "" { if ppTag.Serialization != "" {
vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) vals, err := populateSerializedParams(ppTag, fieldType.Type, valType)
if err != nil { if err != nil {
return "", err return nil, err
} }
for k, v := range vals { for k, v := range vals {
parsedParameters[k] = url.PathEscape(v) parsedParameters[k] = url.PathEscape(v)
@@ -52,7 +81,7 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
// TODO: support other styles // TODO: support other styles
switch ppTag.Style { switch ppTag.Style {
case "simple": case "simple":
simpleParams := getSimplePathParams(ctx, ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode)
for k, v := range simpleParams { for k, v := range simpleParams {
parsedParameters[k] = v parsedParameters[k] = v
} }
@@ -60,11 +89,10 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa
} }
} }
// TODO should we handle the case where there are no matching path params? return globalsAlreadyPopulated, nil
return ReplaceParameters(uri, parsedParameters), nil
} }
func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string {
pathParams := make(map[string]string) pathParams := make(map[string]string)
if isNil(objType, objValue) { if isNil(objType, objValue) {

View File

@@ -11,16 +11,40 @@ import (
"reflect" "reflect"
) )
func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams interface{}, globals map[string]map[string]map[string]interface{}) error { func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error {
values := url.Values{}
globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{})
if err != nil {
return err
}
if globals != nil {
_, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated)
if err != nil {
return err
}
}
req.URL.RawQuery = values.Encode()
return nil
}
func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) {
queryParamsStructType := reflect.TypeOf(queryParams) queryParamsStructType := reflect.TypeOf(queryParams)
queryParamsValType := reflect.ValueOf(queryParams) queryParamsValType := reflect.ValueOf(queryParams)
values := url.Values{} globalsAlreadyPopulated := []string{}
for i := 0; i < queryParamsStructType.NumField(); i++ { for i := 0; i < queryParamsStructType.NumField(); i++ {
fieldType := queryParamsStructType.Field(i) fieldType := queryParamsStructType.Field(i)
valType := queryParamsValType.Field(i) valType := queryParamsValType.Field(i)
if contains(skipFields, fieldType.Name) {
continue
}
requestTag := getRequestTag(fieldType) requestTag := getRequestTag(fieldType)
if requestTag != nil { if requestTag != nil {
continue continue
@@ -31,12 +55,18 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
continue continue
} }
valType = populateFromGlobals(fieldType, valType, "queryParam", globals) if globals != nil {
var globalFound bool
fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals)
if globalFound {
globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name)
}
}
if qpTag.Serialization != "" { if qpTag.Serialization != "" {
vals, err := populateSerializedParams(qpTag, fieldType.Type, valType) vals, err := populateSerializedParams(qpTag, fieldType.Type, valType)
if err != nil { if err != nil {
return err return nil, err
} }
for k, v := range vals { for k, v := range vals {
values.Add(k, v) values.Add(k, v)
@@ -44,35 +74,33 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int
} else { } else {
switch qpTag.Style { switch qpTag.Style {
case "deepObject": case "deepObject":
vals := populateDeepObjectParams(req, qpTag, fieldType.Type, valType) vals := populateDeepObjectParams(qpTag, fieldType.Type, valType)
for k, v := range vals { for k, v := range vals {
for _, vv := range v { for _, vv := range v {
values.Add(k, vv) values.Add(k, vv)
} }
} }
case "form": case "form":
vals := populateFormParams(req, qpTag, fieldType.Type, valType, ",") vals := populateFormParams(qpTag, fieldType.Type, valType, ",")
for k, v := range vals { for k, v := range vals {
for _, vv := range v { for _, vv := range v {
values.Add(k, vv) values.Add(k, vv)
} }
} }
case "pipeDelimited": case "pipeDelimited":
vals := populateFormParams(req, qpTag, fieldType.Type, valType, "|") vals := populateFormParams(qpTag, fieldType.Type, valType, "|")
for k, v := range vals { for k, v := range vals {
for _, vv := range v { for _, vv := range v {
values.Add(k, vv) values.Add(k, vv)
} }
} }
default: default:
return fmt.Errorf("unsupported style: %s", qpTag.Style) return nil, fmt.Errorf("unsupported style: %s", qpTag.Style)
} }
} }
} }
req.URL.RawQuery = values.Encode() return globalsAlreadyPopulated, nil
return nil
} }
func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) {
@@ -98,7 +126,7 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl
return values, nil return values, nil
} }
func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values {
values := url.Values{} values := url.Values{}
if isNil(objType, objValue) { if isNil(objType, objValue) {
@@ -155,7 +183,7 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.
return values return values
} }
func populateFormParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values {
return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string {
qpTag := parseQueryParamTag(fieldType) qpTag := parseQueryParamTag(fieldType)
if qpTag == nil { if qpTag == nil {

View File

@@ -25,8 +25,8 @@ var (
urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`)
) )
func SerializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
bodyReader, contentType, err := serializeRequestBody(ctx, request, nullable, optional, requestFieldName, serializationMethod, tag) bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag)
if err != nil { if err != nil {
return nil, "", fmt.Errorf("error serializing request body: %w", err) return nil, "", fmt.Errorf("error serializing request body: %w", err)
} }
@@ -38,7 +38,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, nullable, op
return bodyReader, contentType, nil return bodyReader, contentType, nil
} }
func serializeRequestBody(ctx context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) {
requestStructType := reflect.TypeOf(request) requestStructType := reflect.TypeOf(request)
requestValType := reflect.ValueOf(request) requestValType := reflect.ValueOf(request)

View File

@@ -158,23 +158,43 @@ func valToString(val interface{}) string {
} }
} }
func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals map[string]map[string]map[string]interface{}) reflect.Value { func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) {
if globals != nil && fieldType.Type.Kind() == reflect.Ptr { if globals == nil {
parameters, ok := globals["parameters"] return fieldType, valType, false
if ok {
paramsOfType, ok := parameters[paramType]
if ok {
globalVal, ok := paramsOfType[fieldType.Name]
if ok {
if reflect.TypeOf(globalVal).Kind() == fieldType.Type.Elem().Kind() && valType.IsNil() {
valType = reflect.ValueOf(&globalVal)
} }
globalsStruct := reflect.TypeOf(globals)
globalsStructVal := reflect.ValueOf(globals)
globalsField, found := globalsStruct.FieldByName(fieldType.Name)
if !found {
return fieldType, valType, false
} }
if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() {
return fieldType, valType, true
} }
globalsVal := globalsStructVal.FieldByName(fieldType.Name)
if !globalsVal.IsValid() {
return fieldType, valType, false
}
switch paramType {
case queryParamTagKey:
qpTag := parseQueryParamTag(globalsField)
if qpTag == nil {
return fieldType, valType, false
}
default:
tag := parseParamTag(paramType, fieldType, "simple", false)
if tag == nil {
return fieldType, valType, false
} }
} }
return valType return globalsField, globalsVal, true
} }
func isNil(typ reflect.Type, val reflect.Value) bool { func isNil(typ reflect.Type, val reflect.Value) bool {
@@ -192,3 +212,12 @@ func isNil(typ reflect.Type, val reflect.Value) bool {
return false return false
} }
func contains(arr []string, str string) bool {
for _, a := range arr {
if a == str {
return true
}
}
return false
}

View File

@@ -12,17 +12,32 @@ var GetPinServerList = []string{
"https://plex.tv/api/v2", "https://plex.tv/api/v2",
} }
type GetPinRequest struct { type GetPinGlobals struct {
// The unique identifier for the client application // The unique identifier for the client application
// This is used to track the client application and its usage // This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device) // (UUID, serial number, or other number unique per device)
// //
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetPinGlobals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
type GetPinRequest struct {
// Determines the kind of code returned by the API call // Determines the kind of code returned by the API call
// Strong codes are used for Pin authentication flows // Strong codes are used for Pin authentication flows
// Non-Strong codes are used for `Plex.tv/link` // Non-Strong codes are used for `Plex.tv/link`
// //
Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"` Strong *bool `default:"false" queryParam:"style=form,explode=true,name=strong"`
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
} }
func (g GetPinRequest) MarshalJSON() ([]byte, error) { func (g GetPinRequest) MarshalJSON() ([]byte, error) {
@@ -36,13 +51,6 @@ func (g *GetPinRequest) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (o *GetPinRequest) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
func (o *GetPinRequest) GetStrong() *bool { func (o *GetPinRequest) GetStrong() *bool {
if o == nil { if o == nil {
return nil return nil
@@ -50,6 +58,13 @@ func (o *GetPinRequest) GetStrong() *bool {
return o.Strong return o.Strong
} }
func (o *GetPinRequest) GetXPlexClientIdentifier() *string {
if o == nil {
return nil
}
return o.XPlexClientIdentifier
}
type Location struct { type Location struct {
Code *string `json:"code,omitempty"` Code *string `json:"code,omitempty"`
EuropeanUnionMember *bool `json:"european_union_member,omitempty"` EuropeanUnionMember *bool `json:"european_union_member,omitempty"`

View File

@@ -10,6 +10,21 @@ var GetTokenServerList = []string{
"https://plex.tv/api/v2", "https://plex.tv/api/v2",
} }
type GetTokenGlobals struct {
// The unique identifier for the client application
// This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device)
//
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetTokenGlobals) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
type GetTokenRequest struct { type GetTokenRequest struct {
// The PinID to retrieve an access token for // The PinID to retrieve an access token for
PinID string `pathParam:"style=simple,explode=false,name=pinID"` PinID string `pathParam:"style=simple,explode=false,name=pinID"`
@@ -17,7 +32,7 @@ type GetTokenRequest struct {
// This is used to track the client application and its usage // This is used to track the client application and its usage
// (UUID, serial number, or other number unique per device) // (UUID, serial number, or other number unique per device)
// //
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
} }
func (o *GetTokenRequest) GetPinID() string { func (o *GetTokenRequest) GetPinID() string {
@@ -27,9 +42,9 @@ func (o *GetTokenRequest) GetPinID() string {
return o.PinID return o.PinID
} }
func (o *GetTokenRequest) GetXPlexClientIdentifier() string { func (o *GetTokenRequest) GetXPlexClientIdentifier() *string {
if o == nil { if o == nil {
return "" return nil
} }
return o.XPlexClientIdentifier return o.XPlexClientIdentifier
} }

29
plex.go
View File

@@ -12,7 +12,6 @@ import (
"github.com/LukeHagar/plexgo/models/sdkerrors" "github.com/LukeHagar/plexgo/models/sdkerrors"
"io" "io"
"net/http" "net/http"
"net/url"
) )
// Plex - API Calls that perform operations directly against https://Plex.tv // Plex - API Calls that perform operations directly against https://Plex.tv
@@ -28,7 +27,7 @@ func newPlex(sdkConfig sdkConfiguration) *Plex {
// GetPin - Get a Pin // GetPin - Get a Pin
// Retrieve a Pin from Plex.tv for authentication flows // Retrieve a Pin from Plex.tv for authentication flows
func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong *bool, opts ...operations.Option) (*operations.GetPinResponse, error) { func (s *Plex) GetPin(ctx context.Context, strong *bool, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetPinResponse, error) {
hookCtx := hooks.HookContext{ hookCtx := hooks.HookContext{
Context: ctx, Context: ctx,
OperationID: "getPin", OperationID: "getPin",
@@ -37,8 +36,12 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
} }
request := operations.GetPinRequest{ request := operations.GetPinRequest{
XPlexClientIdentifier: xPlexClientIdentifier,
Strong: strong, Strong: strong,
XPlexClientIdentifier: xPlexClientIdentifier,
}
globals := operations.GetPinGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
} }
o := operations.Options{} o := operations.Options{}
@@ -56,7 +59,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
baseURL = *o.ServerURL baseURL = *o.ServerURL
} }
opURL, err := url.JoinPath(baseURL, "/pins") opURL, err := utils.GenerateURL(ctx, baseURL, "/pins", request, globals)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -68,9 +71,9 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request, nil) utils.PopulateHeaders(ctx, req, request, globals)
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err) return nil, fmt.Errorf("error populating query params: %w", err)
} }
@@ -153,7 +156,7 @@ func (s *Plex) GetPin(ctx context.Context, xPlexClientIdentifier string, strong
// GetToken - Get Access Token // GetToken - Get Access Token
// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated // Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier string, opts ...operations.Option) (*operations.GetTokenResponse, error) { func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier *string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
hookCtx := hooks.HookContext{ hookCtx := hooks.HookContext{
Context: ctx, Context: ctx,
OperationID: "getToken", OperationID: "getToken",
@@ -166,6 +169,10 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
XPlexClientIdentifier: xPlexClientIdentifier, XPlexClientIdentifier: xPlexClientIdentifier,
} }
globals := operations.GetTokenGlobals{
XPlexClientIdentifier: s.sdkConfiguration.Globals.XPlexClientIdentifier,
}
o := operations.Options{} o := operations.Options{}
supportedOptions := []string{ supportedOptions := []string{
operations.SupportedOptionServerURL, operations.SupportedOptionServerURL,
@@ -181,7 +188,7 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
baseURL = *o.ServerURL baseURL = *o.ServerURL
} }
opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil) opURL, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, globals)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err) return nil, fmt.Errorf("error generating URL: %w", err)
} }
@@ -193,7 +200,11 @@ func (s *Plex) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request, nil) utils.PopulateHeaders(ctx, req, request, globals)
if err := utils.PopulateQueryParams(ctx, req, request, globals); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err)
}
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req)
if err != nil { if err != nil {

View File

@@ -6,6 +6,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/LukeHagar/plexgo/internal/globals"
"github.com/LukeHagar/plexgo/internal/hooks" "github.com/LukeHagar/plexgo/internal/hooks"
"github.com/LukeHagar/plexgo/internal/utils" "github.com/LukeHagar/plexgo/internal/utils"
"github.com/LukeHagar/plexgo/models/components" "github.com/LukeHagar/plexgo/models/components"
@@ -53,6 +54,7 @@ type sdkConfiguration struct {
SDKVersion string SDKVersion string
GenVersion string GenVersion string
UserAgent string UserAgent string
Globals globals.Globals
RetryConfig *utils.RetryConfig RetryConfig *utils.RetryConfig
Hooks *hooks.Hooks Hooks *hooks.Hooks
} }
@@ -255,6 +257,13 @@ 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) {
sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier
}
}
func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption { func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption {
return func(sdk *PlexAPI) { return func(sdk *PlexAPI) {
sdk.sdkConfiguration.RetryConfig = &retryConfig sdk.sdkConfiguration.RetryConfig = &retryConfig
@@ -267,9 +276,10 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{ sdkConfiguration: sdkConfiguration{
Language: "go", Language: "go",
OpenAPIDocVersion: "0.0.3", OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.5.3", SDKVersion: "0.6.2",
GenVersion: "2.291.0", GenVersion: "2.301.0",
UserAgent: "speakeasy-sdk/go 0.5.3 2.291.0 0.0.3 github.com/LukeHagar/plexgo", UserAgent: "speakeasy-sdk/go 0.6.2 2.301.0 0.0.3 github.com/LukeHagar/plexgo",
Globals: globals.Globals{},
ServerDefaults: []map[string]string{ ServerDefaults: []map[string]string{
{ {
"protocol": "http", "protocol": "http",